зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1399780 - Add a test that referrerpolicy attributes are honoured correctly in speculative loading r=ckerschb
MozReview-Commit-ID: 6wU7RMEghjx --HG-- extra : rebase_source : cd0496d6e0f7f479d3f7e138fb6873d76cb79bdb
This commit is contained in:
Родитель
a9ea7d485f
Коммит
49b7f047bb
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Test whether the speculative parser should use the referrerpolicy attribute
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1399780
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script type="text/javascript" src="file_bug704320_preload_common.js"></script>
|
||||
<script language="javascript" type="text/javascript">
|
||||
// interfere doc.write(meta referrer) to the down side preloads
|
||||
document.write("<meta name='referrer' content='unsafe-url'>");
|
||||
</script>
|
||||
|
||||
<link rel="stylesheet"
|
||||
href="http://example.com/tests/dom/base/test/bug704320_counter.sjs?type=css"
|
||||
onload="incrementLoad2('link', 2);"
|
||||
referrerpolicy="origin"/>
|
||||
|
||||
<img src="http://example.com/tests/dom/base/test/bug704320_counter.sjs?type=img"
|
||||
onload="incrementLoad2('img', 2);"
|
||||
referrerpolicy="origin"/>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -108,6 +108,7 @@ support-files =
|
|||
file_bug687859-http.js^headers^
|
||||
file_bug687859-inherit.js
|
||||
file_bug692434.xml
|
||||
file_bug704320_preload_attr.html
|
||||
file_bug704320_preload_common.js
|
||||
file_bug704320_preload_reuse.html
|
||||
file_bug704320_preload_noreuse.html
|
||||
|
|
|
@ -47,6 +47,17 @@ var tests = (function*() {
|
|||
// check the second test
|
||||
yield checkResults(finalizePreloadReuse);
|
||||
|
||||
// reset the counter
|
||||
yield resetCounter();
|
||||
|
||||
// load the third test frame
|
||||
// it will call back into this function via postMessage when it finishes loading.
|
||||
// and continue beyond the yield.
|
||||
yield iframe.src = 'file_bug704320_preload_attr.html';
|
||||
|
||||
// check the third test
|
||||
yield checkResults(finalizePreloadReferrerPolicyAttr);
|
||||
|
||||
// complete.
|
||||
SimpleTest.finish();
|
||||
})();
|
||||
|
@ -121,6 +132,34 @@ function finalizePreloadReuse(results) {
|
|||
advance();
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the third test: a test where preload requests of image, style
|
||||
* should use referrerpolicy attribute and we expect the preloads should not
|
||||
* be reused
|
||||
*/
|
||||
function finalizePreloadReferrerPolicyAttr(results) {
|
||||
var expected = {'css': {'count': 1, 'referrers': ['origin']},
|
||||
'img': {'count': 1, 'referrers': ['origin']}};
|
||||
|
||||
for (var x in expected) {
|
||||
ok(x in results, "some " + x + " loads required in results object.");
|
||||
|
||||
is(results[x].count, expected[x].count,
|
||||
"Expected " + expected[x].count + " loads for " + x + " requests.");
|
||||
|
||||
// 'origin' is required
|
||||
ok(results[x].referrers.indexOf('origin') >= 0,
|
||||
"One load for " + x + " should have had 'origin' referrer.");
|
||||
|
||||
// no other values should be in the referrers.
|
||||
is(results[x].referrers.indexOf('none'), -1,
|
||||
"No loads for " + x + " should have a missing referrer.");
|
||||
is(results[x].referrers.indexOf('full'), -1,
|
||||
"No loads for " + x + " should have an 'full' referrer.")
|
||||
}
|
||||
|
||||
advance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Grabs the results via XHR and passes to checker.
|
||||
|
|
Загрузка…
Ссылка в новой задаче