forked from bluesmoon/boomerang
-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work around minification that breaks in IE8 and quirks mode
- Loading branch information
1 parent
61290ed
commit 603d5da
Showing
8 changed files
with
133 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 2 additions & 36 deletions
38
tests/page-template-snippets/boomerangDelayedSnippetNoScript.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,3 @@ | ||
(function(){ | ||
if (window.BOOMR && window.BOOMR.version) { return; } | ||
var dom,doc,where,iframe = document.createElement("iframe"),win = window; | ||
window.BOOMR_script_delay = true; | ||
|
||
function boomerangSaveLoadTime(e) { | ||
win.BOOMR_onload=(e && e.timeStamp) || new Date().getTime(); | ||
} | ||
if (win.addEventListener) { | ||
win.addEventListener("load", boomerangSaveLoadTime, false); | ||
} else if (win.attachEvent) { | ||
win.attachEvent("onload", boomerangSaveLoadTime); | ||
} | ||
|
||
iframe.src = "javascript:void(0)"; | ||
iframe.title = ""; iframe.role = "presentation"; | ||
(iframe.frameElement || iframe).style.cssText = "width:0;height:0;border:0;display:none;"; | ||
where = document.getElementsByTagName("script")[0]; | ||
where.parentNode.insertBefore(iframe, where); | ||
|
||
try { | ||
doc = iframe.contentWindow.document; | ||
} catch(e) { | ||
dom = document.domain; | ||
iframe.src="javascript:var d=document.open();d.domain='"+dom+"';void(0);"; | ||
doc = iframe.contentWindow.document; | ||
} | ||
doc.open()._l = function() { | ||
var js = this.createElement("script"); | ||
if (dom) { this.domain = dom; } | ||
js.id = "boomr-if-as"; | ||
js.src = "/delay?delay=3000&file=build/boomerang-latest-debug.js&rnd=" + Math.random(); | ||
BOOMR_lstart=new Date().getTime(); | ||
this.body.appendChild(js); | ||
}; | ||
doc.write('<body onload="document._l();">'); | ||
doc.close(); | ||
})(); | ||
<%= boomerangSnippetNoScript %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<script> | ||
<%= boomerangSnippetMinNoScript %> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
window.BOOMR_script_minified = true; | ||
|
||
<%= boomerangSnippetNoScript %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<%= header %> | ||
<%= boomerangSnippetMin %> | ||
<script src="13-onload-minified.js" type="text/javascript"></script> | ||
<script> | ||
BOOMR_test.init({ | ||
ResourceTiming: { | ||
enabled: false | ||
}, | ||
testAfterOnBeacon: true | ||
}); | ||
</script> | ||
<%= footer %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/*eslint-env mocha*/ | ||
/*global BOOMR_test,assert*/ | ||
|
||
describe("e2e/00-basic/13-onload-minified", function() { | ||
var tf = BOOMR.plugins.TestFramework; | ||
|
||
it("Should have sent a beacon", function() { | ||
// ensure we fired a beacon ('beacon') | ||
assert.isTrue(tf.fired_onbeacon); | ||
}); | ||
|
||
it("Should have fired 'beacon' with a beacon payload", function() { | ||
// ensure the data was sent to 'beacon' | ||
assert.isObject(tf.lastBeacon()); | ||
}); | ||
|
||
it("Should have set basic beacon properties", function() { | ||
assert.isString(tf.lastBeacon().v); | ||
}); | ||
|
||
it("Should have set dom.* properties", function() { | ||
assert.isNumber(tf.lastBeacon()["dom.img"], "dom.img"); | ||
assert.isNumber(tf.lastBeacon()["dom.ln"], "dom.ln"); | ||
assert.isNumber(tf.lastBeacon()["dom.script"], "dom.script"); | ||
assert.isNumber(tf.lastBeacon()["dom.sz"], "dom.sz"); | ||
|
||
if (BOOMR_test.isResourceTimingSupported()) { | ||
assert.isNumber(tf.lastBeacon()["dom.doms"], "dom.doms"); | ||
assert.isNumber(tf.lastBeacon()["dom.res"], "dom.res"); | ||
} | ||
}); | ||
|
||
it("Should have set mem.* properties", function() { | ||
if ((window.performance && window.performance.memory) || | ||
(window.console && window.console.memory)) { | ||
assert.isNumber(tf.lastBeacon()["mem.total"], "mem.total"); | ||
assert.isNumber(tf.lastBeacon()["mem.used"], "mem.used"); | ||
|
||
// Might not exist except recent builds | ||
if (tf.lastBeacon()["mem.limit"]) { | ||
assert.isNumber(tf.lastBeacon()["mem.limit"], "mem.limit"); | ||
} | ||
} | ||
}); | ||
|
||
it("Should have set RT properties", function() { | ||
assert.isString(tf.lastBeacon().u, "u"); | ||
|
||
assert.isNumber(tf.lastBeacon()["rt.bstart"], "rt.bstart"); | ||
assert.isNumber(tf.lastBeacon()["rt.end"], "rt.end"); | ||
/* SOASTA PRIVATE START */ | ||
assert.isString(tf.lastBeacon()["rt.si"], "rt.si"); | ||
assert.isNumber(tf.lastBeacon()["rt.sl"], "rt.sl"); | ||
assert.isNumber(tf.lastBeacon()["rt.ss"], "rt.ss"); | ||
/* SOASTA PRIVATE END */ | ||
assert.isString(tf.lastBeacon()["rt.start"], "rt.start"); | ||
|
||
// optional | ||
if (typeof tf.lastBeacon()["rt.tstart"] !== "undefined") { | ||
assert.isNumber(tf.lastBeacon()["rt.tstart"], "rt.tstart"); | ||
} | ||
}); | ||
|
||
it("Should have set scr.* properties", function() { | ||
var s = window.screen; | ||
assert.isString(tf.lastBeacon()["scr.bpp"], "scr.bpp"); | ||
assert.isString(tf.lastBeacon()["scr.xy"], "scr.xy"); | ||
|
||
// only if we have orientation | ||
if (s && s.orientation) { | ||
assert.isString(tf.lastBeacon()["scr.orn"], "scr.orn"); | ||
} | ||
|
||
// only if we have pixel ratio | ||
if (window.devicePixelRatio && window.devicePixelRatio > 1) { | ||
assert.isNumber(tf.lastBeacon()["scr.dpx"], "scr.dpx"); | ||
} | ||
}); | ||
|
||
it("Should have set LOGN / SOASTA properties", function() { | ||
assert.isString(tf.lastBeacon()["h.key"], "h.key"); | ||
}); | ||
|
||
it("Should have set vis.* properties", function() { | ||
assert.isString(tf.lastBeacon()["vis.st"], "vis.st"); | ||
}); | ||
|
||
it("Should have set Page ID (pid)", function() { | ||
assert.isString(tf.lastBeacon().pid, "pid"); | ||
}); | ||
|
||
it("Should have set nocookie=1", function() { | ||
assert.equal(tf.lastBeacon().nocookie, "1"); | ||
}); | ||
}); |