Skip to content

Commit

Permalink
ResourceTiming: Add iframe and subdocument to initiatorType
Browse files Browse the repository at this point in the history
  • Loading branch information
jzyang authored and nicjansma committed Apr 4, 2018
1 parent bc89347 commit 94b92e5
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plugins/restiming.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ see: http://www.w3.org/TR/resource-timing/
// sendBeacon: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon
"beacon": 8,
// Fetch API: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
"fetch": 9
"fetch": 9,
"iframe": "a",
// IE11 and Edge (some versions) send "subdocument" instead of "iframe"
"subdocument": "a"
};

// https://html.spec.whatwg.org/multipage/links.html#linkTypes
Expand Down
16 changes: 16 additions & 0 deletions tests/page-templates/06-bugs/issue-606.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<%= header %>
<script src="../../vendor/resourcetiming-compression/src/resourcetiming-decompression.js" type="text/javascript"></script>
<%= boomerangSnippet %>
<script src="issue-606.js" type="text/javascript"></script>
<link rel="stylesheet" href="support/09.css" />
<iframe src="support/92542-iframe.html"></iframe>
<script>
BOOMR_test.init({
testAfterOnBeacon: true,
ResourceTiming: {
enabled: true,
trackedResourceTypes: ["css", "iframe", "subdocument"]
}
});
</script>
<%= footer %>
29 changes: 29 additions & 0 deletions tests/page-templates/06-bugs/issue-606.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*eslint-env mocha*/
/*global BOOMR_test,assert*/

describe("e2e/06-bug/issue-606", function() {
var t = BOOMR_test;
var tf = BOOMR.plugins.TestFramework;

it("Should pass basic beacon validation", function(done) {
t.validateBeaconWasSent(done);
});

it("Should only have one iframe and one CSS in the filter (if ResourceTiming is supported)", function() {
if (t.isResourceTimingSupported()) {
var b = tf.lastBeacon();

var resources = ResourceTimingDecompression.decompressResources(JSON.parse(b.restiming));

assert.equal(resources.length, 2);

// find our iframe
assert.equal(resources[0].initiatorType, "other");
assert.include(resources[0].name, "support/92542-iframe.html");

// find our css
assert.equal(resources[1].initiatorType, "css");
assert.include(resources[1].name, "support/img.jpg");
}
});
});
3 changes: 3 additions & 0 deletions tests/page-templates/06-bugs/support/09.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background-image: url("img.jpg")
}

0 comments on commit 94b92e5

Please sign in to comment.