Skip to content

Commit

Permalink
Added BOOMR_test.canSetCookie()
Browse files Browse the repository at this point in the history
  • Loading branch information
nicjansma committed Apr 24, 2015
1 parent 5169c80 commit 53a7639
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 11 additions & 1 deletion tests/boomerang-test-framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand All @@ -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);
}
Expand Down

0 comments on commit 53a7639

Please sign in to comment.