diff --git a/tests/boomerang-test-framework.js b/tests/boomerang-test-framework.js index 8458d2187..21bf77af1 100644 --- a/tests/boomerang-test-framework.js +++ b/tests/boomerang-test-framework.js @@ -262,7 +262,17 @@ assert.isString(tf.lastBeacon().v); done(); - } + }; + + t.canSetCookies = function() { + var testCookieName = "test_cookie"; + + // set a cookie + document.cookie = [testCookieName + "=true", "path=/", "domain=" + location.hostname].join("; "); + + // determine if it was set OK + return (" " + document.cookie + ";").indexOf(" " + testCookieName + "=") !== -1; + }; window.BOOMR_test = t; diff --git a/tests/page-templates/04-page-params/04-custom-dimensions-cookies.js b/tests/page-templates/04-page-params/04-custom-dimensions-cookies.js index b411e2023..996594437 100644 --- a/tests/page-templates/04-page-params/04-custom-dimensions-cookies.js +++ b/tests/page-templates/04-page-params/04-custom-dimensions-cookies.js @@ -5,12 +5,6 @@ describe("e2e/04-page-params/04-custom-dimensions-cookies", function() { var tf = BOOMR.plugins.TestFramework; var t = BOOMR_test; - // set a cookie - document.cookie = ["test_cookie=true", "path=/", "domain=" + location.hostname].join("; "); - - // determine if it was set OK - var cookieSetOK = (" " + document.cookie + ";").indexOf(" test_cookie=") !== -1; - it("Should pass basic beacon validation", function(done) { t.validateBeaconWasSent(done); }); @@ -21,14 +15,14 @@ describe("e2e/04-page-params/04-custom-dimensions-cookies", function() { }); it("Should be have custom dimension 2 - Cookie - If cookies can be set (on a domain or in PhantomJS)", function() { - if (cookieSetOK) { + if (t.canSetCookies()) { var b = tf.lastBeacon(); assert.equal(b["cdim.CD2"], "true"); } }); it("Should be missing custom dimension 2 - Cookie - If cookies can't be set (on localhost or an IP)", function() { - if (!cookieSetOK) { + if (!t.canSetCookies()) { var b = tf.lastBeacon(); assert.equal(b["cdim.CD2"], undefined); }