Wrap more of the referrer-policy tests in testharness.js.

This commit is contained in:
Josh Matthews 2018-12-20 16:14:15 -05:00
parent bffe2a699e
commit 3cd6df1ef9
30 changed files with 540 additions and 583 deletions

View file

@ -650073,67 +650073,67 @@
"support"
],
"referrer-policy/css-integration/child-css/external-import-stylesheet.html": [
"a2d3e8ced0412b97422847d4d81c1403cf9ae52c",
"40f4234ad48d19162cefae933fd0f53a72ff0c19",
"testharness"
],
"referrer-policy/css-integration/child-css/internal-import-stylesheet.html": [
"aebf5031484b799989d6b6a9dd72a5bc28575214",
"30c5ea2903094af38dea9a7a565255d178069178",
"testharness"
],
"referrer-policy/css-integration/child-css/processing-instruction.html": [
"b6333e2c7b248c3f3b863bd06f1c99abd472f162",
"52a0ded42a185ed5ff6f449879e0ce50f8255868",
"testharness"
],
"referrer-policy/css-integration/css-test-helper.js": [
"f5886dbbcbe358438dfbac45c5a0127e9e990ad4",
"788df16a456b83a23de662b710c200042a1e7254",
"support"
],
"referrer-policy/css-integration/font-face/external-import-stylesheet.html": [
"c344c56c5bf322f35e8d8c74427d80391e6637d3",
"80e3587ad62f040f2cfb28645437fcbc0e66b415",
"testharness"
],
"referrer-policy/css-integration/font-face/external-stylesheet.html": [
"24e4bb99900a556cb0b44144a25c9f8249224eb7",
"a91eb3fe758299229040466deb2d1b0263f77197",
"testharness"
],
"referrer-policy/css-integration/font-face/internal-import-stylesheet.html": [
"54e2383423cab8679635d05c256c32e27a94c024",
"a637082a4ce7dff612b223fc8a4c2195db300013",
"testharness"
],
"referrer-policy/css-integration/font-face/internal-stylesheet.html": [
"b3869bcebdcdadea3e50d7e8713c853d46ba4816",
"eebd864bc56725b79c1f29c0597466574e2af091",
"testharness"
],
"referrer-policy/css-integration/font-face/processing-instruction.html": [
"89ee918e24e14b8ea5d35a7dfaf09610eb89ee11",
"bfc42d9fcbe355514c7bf72ac087d7159439824e",
"testharness"
],
"referrer-policy/css-integration/image/external-import-stylesheet.html": [
"0023af31b17ee883e6e9fe6cdd8f09b8eacf83d1",
"80c71b0e215b547d664aee8757d70188c012a9c0",
"testharness"
],
"referrer-policy/css-integration/image/external-stylesheet.html": [
"d14769db4a1221bb6e220aa594c4a3b6bab97aa1",
"ba7497b97de6911c149b423bf25305123e97150e",
"testharness"
],
"referrer-policy/css-integration/image/inline-style.html": [
"42128ae062093c0e8feb5d90ab62a6cb281cf8e9",
"758b6d91852f67d4e47726815804a5e366fe534d",
"testharness"
],
"referrer-policy/css-integration/image/internal-import-stylesheet.html": [
"90003547f4d4e2048cc33f7125d756d42507140d",
"24aa1858304a2130624589b0a64c6f9ec9cac5a1",
"testharness"
],
"referrer-policy/css-integration/image/internal-stylesheet.html": [
"943108d66e4b273a6d3be30b2ea8a0edb0490c7b",
"f4567885e1f1e215487a11f1023d117517cd88b8",
"testharness"
],
"referrer-policy/css-integration/image/presentation-attribute.html": [
"78401d3ec16866f1e51618bdb5cb028f5eea8490",
"d0a4d96f84c8e48ea5daf5699c7b04bbc877ba86",
"testharness"
],
"referrer-policy/css-integration/image/processing-instruction.html": [
"1ca18547dd54c4707250f400999a041f16f77ddf",
"926147be489a85164758dcf644c715e4a5c02de6",
"testharness"
],
"referrer-policy/css-integration/svg/external-stylesheet.html": [
@ -650157,7 +650157,7 @@
"testharness"
],
"referrer-policy/generic/common.js": [
"f9bbe42b914c46822ec8b74aacd849789723dd72",
"a16691bccb2543ad68b81e9a16fa261d3cce6a9f",
"support"
],
"referrer-policy/generic/iframe-inheritance.html": [
@ -650209,11 +650209,11 @@
"support"
],
"referrer-policy/generic/referrer-policy-test-case.js": [
"4641683cd850da86279dcd062aaf868d346aa2bd",
"2385cc2a1c4e51a2855299e42b69ac12362cd699",
"support"
],
"referrer-policy/generic/sandboxed-iframe-with-opaque-origin.html": [
"8fee77f836378ec137c3bf0d554f4def83a5caba",
"1b2b12bf6910e075338462de577dc4228f52a21f",
"testharness"
],
"referrer-policy/generic/sanity-checker.js": [
@ -650221,7 +650221,7 @@
"support"
],
"referrer-policy/generic/subresource-test/area-navigate.html": [
"bca7e479fa2ca41505bc73cf74c6e518efa7e947",
"3eb824521b7801c518a7b36218075eb3d74bd639",
"testharness"
],
"referrer-policy/generic/subresource-test/attr-referrer-invalid-value.html": [
@ -650229,31 +650229,31 @@
"testharness"
],
"referrer-policy/generic/subresource-test/fetch-messaging.html": [
"046b29e9a3e94753c1a552732b0f44d2883a011d",
"edb159d9eb1cf5eed6af249a40f70d9ecd079d68",
"testharness"
],
"referrer-policy/generic/subresource-test/iframe-messaging.html": [
"a3e55707c26f95624baaa54b8778d641cd756d72",
"606e18b281f6c3498573dc9bfaefefca1390026a",
"testharness"
],
"referrer-policy/generic/subresource-test/image-decoding.html": [
"448f12b1348fa77aaaebd52b2c3ee6ae9c73a5f6",
"9c50ea6619389dad8ad81c4c2afbeb8030b176db",
"testharness"
],
"referrer-policy/generic/subresource-test/link-navigate.html": [
"45e502004d4b640d0b2194e48d060b8d3cc3f120",
"95582f65bac8a3b478cc8cd4fe9b883fb507237f",
"testharness"
],
"referrer-policy/generic/subresource-test/script-messaging.html": [
"09c5db6193fed52c60edc2526609c3d501c45da8",
"f73f4406df20694480f82570ed8674fe283ea375",
"testharness"
],
"referrer-policy/generic/subresource-test/worker-messaging.html": [
"6d34366b943ad2b3b15f08179a58ef5227c675d0",
"fd7591882e91e7265fd740b9018248d21f13b5b9",
"testharness"
],
"referrer-policy/generic/subresource-test/xhr-messaging.html": [
"09f69140098a16bd66a117cf6187fedc862d9233",
"6ef4a9cfd4b98c3562fe7ef6e04eb931073166de",
"testharness"
],
"referrer-policy/generic/subresource/__init__.py": [
@ -650381,7 +650381,7 @@
"support"
],
"referrer-policy/generic/unsupported-csp-referrer-directive.html": [
"9627d16559903b5202f842f3c3355a2e7005f65c",
"475efa55091778e747fa36030f7b422b89d6d4b9",
"testharness"
],
"referrer-policy/no-referrer-when-downgrade/attr-referrer/cross-origin/http-http/a-tag/no-redirect/insecure-protocol.http.html": [

View file

@ -1,3 +0,0 @@
[unsupported-csp-referrer-directive.html]
type: testharness
disabled: https://github.com/servo/servo/issues/4767

View file

@ -16,7 +16,7 @@
<div class="styled"></div>
<script>
let css_test = async_test("Child css from external stylesheet.");
async_test(function(css_test) {
let id = token();
let url_prefix = location.protocol + "//www1." + location.hostname + ":" + location.port;
let css_url = url_prefix +
@ -29,18 +29,16 @@
link.href = css_url;
link.rel = "stylesheet";
link.onload = function() {
css_test.step_timeout(
queryXhr.bind(this, check_url,
function(message) {
css_test.step(function() {
css_test.step_timeout(function() {
queryXhr(check_url, function(message) {
assert_own_property(message, "headers");
assert_equals(message.referrer, undefined);
});
css_test.done();
}),
1000);
}, null, null, css_test);
}, 1000);
};
document.head.appendChild(link);
}, "Child css from external stylesheet.");
</script>
<div id="log"></div>

View file

@ -16,7 +16,7 @@
<div class="styled"></div>
<script>
let css_test = async_test("Child css from internal stylesheet.");
async_test(function(css_test) {
let id = token();
let url_prefix = location.protocol + "//www1." + location.hostname + ":" + location.port;
let css_url = url_prefix + "/referrer-policy/generic/subresource/stylesheet.py?id=" + id + "&import-rule";
@ -27,17 +27,15 @@
style.type = 'text/css';
style.appendChild(document.createTextNode("@import url('" + css_url + "');"));
document.head.appendChild(style);
css_test.step_timeout(
queryXhr.bind(this, check_url,
function(message) {
css_test.step(function() {
css_test.step_timeout(function() {
queryXhr(check_url, function(message) {
assert_own_property(message, "headers");
assert_own_property(message, "referrer");
assert_equals(message.referrer, css_url);
});
css_test.done();
}),
1000);
}, null, null, css_test);
}, 1000);
}, "Child css from internal stylesheet.");
</script>
<div id="log"></div>

View file

@ -15,7 +15,7 @@
<div class="styled"></div>
<script>
let css_test = async_test("Child css via a ProcessingInstruction.");
async_test(function(css_test) {
let id = token();
let url_prefix = location.protocol + "//www1." + location.hostname + ":" +
location.port +
@ -28,18 +28,16 @@
let processingInstruction =
document.createProcessingInstruction(
"xml-stylesheet", "href=\"" +css_url + "\" type=\"text/css\"");
css_test.step_timeout(
queryXhr.bind(this, check_url,
function(message) {
css_test.step(function() {
css_test.step_timeout(function() {
queryXhr(check_url, function(message) {
assert_own_property(message, "headers");
assert_own_property(message, "referrer");
assert_equals(message.referrer, expected);
});
css_test.done();
}),
1000);
}, null, null, css_test);
}, 1000);
document.insertBefore(processingInstruction, document.firstChild);
}, "Child css via a ProcessingInstruction.");
</script>
<div id="log"></div>

View file

@ -33,22 +33,18 @@ function runSvgTests(testProperties, testDescription, testFunction) {
property: property,
};
testFunction(current);
current.test.step(function() { testFunction(current) });
let check_url = url_prefix + "svg.py" + "?id=" + current.id +
"&report-headers";
current.test.step_timeout(
queryXhr.bind(this, check_url,
function(message) {
current.test.step(function() {
current.test.step_timeout(function() {
queryXhr(check_url, function(message) {
assert_own_property(message, "headers");
assert_own_property(message, "referrer");
assert_equals(message.referrer, current.expected);
});
current.test.done();
}),
800);
}, null, null, current.test);
}, 800);
};
add_result_callback(runNextTest);

View file

@ -17,7 +17,7 @@
<div class="styled"></div>
<script>
let css_test = async_test("Font from imported stylesheet (external).");
async_test(function(css_test) {
let id = token();
let css_url = location.protocol + "//www1." + location.hostname + ":" +
location.port +
@ -33,19 +33,17 @@
link.href = css_url;
link.rel = "stylesheet";
link.onload = function() {
css_test.step_timeout(
queryXhr.bind(this, font_url,
function(message) {
css_test.step(function() {
css_test.step_timeout(function() {
queryXhr(font_url, function(message) {
assert_own_property(message, "headers");
assert_own_property(message, "referrer");
assert_equals(message.referrer, css_referrer);
});
css_test.done();
}),
1000);
}, null, null, css_test);
}, 1000);
};
document.head.appendChild(link);
}, "Font from imported stylesheet (external).");
</script>
<div id="log"></div>

View file

@ -16,7 +16,7 @@
<div class="styled"></div>
<script>
let css_test = async_test("Font from external stylesheet.");
async_test(function(css_test) {
let id = token();
let url_prefix = location.protocol + "//www1." + location.hostname + ":" + location.port;
let css_url = url_prefix + "/referrer-policy/generic/subresource/stylesheet.py?id=" + id + "&type=font";
@ -27,19 +27,17 @@
link.href = css_url;
link.rel = "stylesheet";
link.onload = function() {
css_test.step_timeout(
queryXhr.bind(this, font_url,
function(message) {
css_test.step(function() {
css_test.step_timeout(function() {
queryXhr(font_url, function(message) {
assert_own_property(message, "headers");
assert_own_property(message, "referrer");
assert_equals(message.referrer, css_url);
});
css_test.done();
}),
1000);
}, null, null, css_test);
}, 1000);
};
document.head.appendChild(link);
}, "Font from external stylesheet.");
</script>
<div id="log"></div>

View file

@ -17,7 +17,7 @@
<div class="styled"></div>
<script>
let css_test = async_test("Font from imported stylesheet (internal).");
async_test(function(css_test) {
let id = token();
let url_prefix = location.protocol + "//www1." + location.hostname + ":" +
location.port + "/referrer-policy/generic/subresource/";
@ -27,17 +27,15 @@
let style = document.createElement("style");
style.textContent = "@import url('" + css_url + "');";
document.head.appendChild(style);
css_test.step_timeout(
queryXhr.bind(this, font_url,
function(message) {
css_test.step(function() {
css_test.step_timeout(function() {
queryXhr(font_url, function(message) {
assert_own_property(message, "headers");
assert_own_property(message, "referrer");
assert_equals(message.referrer, css_url);
});
css_test.done();
}),
1000);
}, null, null, css_test);
}, 1000);
}, "Font from imported stylesheet (internal).");
</script>
<div id="log"></div>

View file

@ -16,7 +16,7 @@
<div class="styled"></div>
<script>
let css_test = async_test("Font from internal stylesheet.");
async_test(function(css_test) {
let id = token();
let css_url = location.protocol + "//www1." + location.hostname + ":" +
location.port +
@ -27,17 +27,15 @@
let style = document.createElement("style");
style.textContent = "@font-face { font-family: 'wpt'; font-style: normal; font-weight: normal; src: url(" + css_url + "); format('truetype'); } body { font-family: 'wpt';}";
document.head.appendChild(style);
css_test.step_timeout(
queryXhr.bind(this, font_url,
function(message) {
css_test.step(function() {
css_test.step_timeout(function() {
queryXhr(font_url, function(message) {
assert_own_property(message, "headers");
assert_own_property(message, "referrer");
assert_equals(message.referrer, location.origin + "/");
});
css_test.done();
}),
1000);
}, null, null, css_test);
}, 1000);
}, "Font from internal stylesheet.");
</script>
<div id="log"></div>

View file

@ -17,7 +17,7 @@
<div class="styled"></div>
<script>
let css_test = async_test("Font from external stylesheet (from ProcessingInstruction).");
async_test(function(css_test) {
let id = token();
let url_prefix = location.protocol + "//www1." + location.hostname + ":" + location.port;
let css_url = url_prefix +
@ -32,18 +32,16 @@
let processingInstruction =
document.createProcessingInstruction(
"xml-stylesheet", "href=\"" + css_url + "\" type=\"text/css\"");
css_test.step_timeout(
queryXhr.bind(this, font_url,
function(message) {
css_test.step(function() {
css_test.step_timeout(function() {
queryXhr(font_url, function(message) {
assert_own_property(message, "headers");
assert_own_property(message, "referrer");
assert_equals(message.referrer, expected);
});
css_test.done();
}),
1000);
}, null, null, css_test);
}, 1000);
document.insertBefore(processingInstruction, document.firstChild);
}, "Font from external stylesheet (from ProcessingInstruction).");
</script>
<div id="log"></div>

View file

@ -17,7 +17,7 @@
<div class="styled"></div>
<script>
var css_test = async_test("Image from imported stylesheet (external).");
async_test(function(css_test) {
var id = token();
var css_url = location.protocol + "//www1." + location.hostname + ":" + location.port +
"/referrer-policy/generic/subresource/stylesheet.py?id=" + id +
@ -33,19 +33,17 @@
link.href = css_url;
link.rel = "stylesheet";
link.onload = function() {
css_test.step_timeout(
queryXhr.bind(this, img_url,
function(message) {
css_test.step(function() {
css_test.step_timeout(function() {
queryXhr(img_url, function(message) {
assert_own_property(message, "headers");
assert_own_property(message, "referrer");
assert_equals(message.referrer, css_referrer);
});
css_test.done();
}),
1000);
}, null, null, css_test);
}, 1000);
};
document.head.appendChild(link);
}, "Image from imported stylesheet (external).");
</script>
<div id="log"></div>

View file

@ -16,7 +16,7 @@
<div class="styled"></div>
<script>
var css_test = async_test("Image from external stylesheet.");
async_test(function(css_test) {
var id = token();
var url_prefix = location.protocol + "//www1." + location.hostname + ":" + location.port;
var css_url = url_prefix + "/referrer-policy/generic/subresource/stylesheet.py?id=" + id;
@ -26,20 +26,18 @@
var link = document.createElement("link");
link.href = css_url;
link.rel = "stylesheet";
link.onload = function() {
css_test.step_timeout(
queryXhr.bind(this, img_url,
function(message) {
css_test.step(function() {
link.onload = css_test.step_func(function() {
css_test.step_timeout(function() {
queryXhr(img_url, function(message) {
assert_own_property(message, "headers");
assert_own_property(message, "referrer");
assert_equals(message.referrer, css_url);
});
css_test.done();
}),
1000);
};
}, null, null, css_test);
}, 1000);
});
document.head.appendChild(link);
}, "Image from external stylesheet.");
</script>
<div id="log"></div>

View file

@ -16,24 +16,22 @@
<div class="styled"></div>
<script>
var css_test = async_test("Image from inline styles.");
async_test(function(css_test) {
var id = token();
var css_url = location.protocol + "//www1." + location.hostname + ":" + location.port + "/referrer-policy/generic/subresource/image.py" + "?id=" + id;
var img_url = css_url + "&report-headers";
var div = document.querySelector("div.styled");
div.style = "content:url(" + css_url + ")";
css_test.step_timeout(
queryXhr.bind(this, img_url,
function(message) {
css_test.step(function() {
css_test.step_timeout(function() {
queryXhr(img_url, function(message) {
assert_own_property(message, "headers");
assert_own_property(message, "referrer");
assert_equals(message.referrer, location.origin + "/");
});
css_test.done();
}),
1000);
}, null, null, css_test);
}, 1000);
}, "Image from inline styles.");
</script>
<div id="log"></div>

View file

@ -17,7 +17,7 @@
<div class="styled"></div>
<script>
var css_test = async_test("Image from imported stylesheet (internal).");
async_test(function(css_test) {
var id = token();
var url_prefix = location.protocol + "//www1." + location.hostname + ":" + location.port + "/referrer-policy/generic/subresource/";
var css_url = url_prefix + "stylesheet.py?id=" + id;
@ -27,17 +27,15 @@
style.type = 'text/css';
style.appendChild(document.createTextNode("@import url('" + css_url + "');"));
document.head.appendChild(style);
css_test.step_timeout(
queryXhr.bind(this, img_url,
function(message) {
css_test.step(function() {
css_test.step_timeout(function() {
queryXhr(img_url, function(message) {
assert_own_property(message, "headers");
assert_own_property(message, "referrer");
assert_equals(message.referrer, css_url);
});
css_test.done();
}),
1000);
}, null, null, css_test);
}, 1000);
}, "Image from imported stylesheet (internal).");
</script>
<div id="log"></div>

View file

@ -16,7 +16,7 @@
<div class="styled"></div>
<script>
var css_test = async_test("Image from internal stylesheet.");
async_test(function(css_test) {
var id = token();
var css_url = location.protocol + "//www1." + location.hostname + ":" + location.port + "/referrer-policy/generic/subresource/image.py" + "?id=" + id;
var img_url = css_url + "&report-headers";
@ -25,17 +25,15 @@
style.type = 'text/css';
style.appendChild(document.createTextNode("div.styled::before { content:url(" + css_url + ")}"));
document.head.appendChild(style);
css_test.step_timeout(
queryXhr.bind(this, img_url,
function(message) {
css_test.step(function() {
css_test.step_timeout(function() {
queryXhr(img_url, function(message) {
assert_own_property(message, "headers");
assert_own_property(message, "referrer");
assert_equals(message.referrer, location.origin + "/");
});
css_test.done();
}),
1000);
}, null, null, css_test);
}, 1000);
}, "Image from internal stylesheet.");
</script>
<div id="log"></div>

View file

@ -14,23 +14,21 @@
the referrer and referrer policy from the document.</p>
<script>
var css_test = async_test("Image from presentation attributes.");
async_test(function(css_test) {
var id = token();
var css_url = location.protocol + "//www1." + location.hostname + ":" + location.port + "/referrer-policy/generic/subresource/image.py" + "?id=" + id;
var img_url = css_url + "&report-headers";
document.body.background = css_url;
css_test.step_timeout(
queryXhr.bind(this, img_url,
function(message) {
css_test.step(function() {
css_test.step_timeout(function() {
queryXhr(img_url, function(message) {
assert_own_property(message, "headers");
assert_own_property(message, "referrer");
assert_equals(message.referrer, location.origin + "/");
});
css_test.done();
}),
1000);
}, null, null, css_test);
}, 1000);
}, "Image from presentation attributes.");
</script>
<div id="log"></div>

View file

@ -17,7 +17,7 @@
<div class="styled"></div>
<script>
var css_test = async_test("Image from external stylesheet (from ProcessingInstruction).");
async_test(function(css_test) {
var id = token();
var url_prefix = location.protocol + "//www1." + location.hostname + ":" + location.port;
var css_url = url_prefix + "/referrer-policy/generic/subresource/stylesheet.py?id=" + id;
@ -25,18 +25,16 @@
"?id=" + id + "&report-headers";
var processingInstruction = document.createProcessingInstruction("xml-stylesheet", "href=\"" + css_url + "\" type=\"text/css\"");
css_test.step_timeout(
queryXhr.bind(this, img_url,
function(message) {
css_test.step(function() {
css_test.step_timeout(function() {
queryXhr(img_url, function(message) {
assert_own_property(message, "headers");
assert_own_property(message, "referrer");
assert_equals(message.referrer, css_url);
});
css_test.done();
}),
1000);
}, null, null, css_test);
}, 1000);
document.insertBefore(processingInstruction, document.firstChild);
}, "Image from external stylesheet (from ProcessingInstruction).");
</script>
<div id="log"></div>

View file

@ -99,15 +99,15 @@ function wrapResult(url, server_data) {
}
}
function queryIframe(url, callback, referrer_policy) {
var iframe = appendIframeToBody(url, referrer_policy);
var listener = function(event) {
function queryIframe(url, callback, attributes, referrer_policy, test) {
var iframe = appendIframeToBody(url, attributes);
var listener = test.step_func(function(event) {
if (event.source != iframe.contentWindow)
return;
callback(event.data, url);
window.removeEventListener("message", listener);
}
});
window.addEventListener("message", listener);
}
@ -122,12 +122,12 @@ function queryImage(url, callback, attributes, referrerPolicy, test) {
var noSrcDocPolicy = new Promise((resolve, reject) => {
var iframeWithoutOwnPolicy = document.createElement('iframe');
iframeWithoutOwnPolicy.srcdoc = "Hello, world.";
iframeWithoutOwnPolicy.onload = function () {
iframeWithoutOwnPolicy.onload = test.step_func(function () {
var nextUrl = url + "&cache_destroyer2=" + (new Date()).getTime();
loadImageInWindow(nextUrl, function (img) {
loadImageInWindow(nextUrl, test.step_func(function (img) {
resolve(decodeImageData(extractImageData(img)));
}, attributes, iframeWithoutOwnPolicy.contentWindow);
};
}), attributes, iframeWithoutOwnPolicy.contentWindow);
});
document.body.appendChild(iframeWithoutOwnPolicy);
});
@ -137,19 +137,19 @@ function queryImage(url, callback, attributes, referrerPolicy, test) {
var iframeWithOwnPolicy = document.createElement('iframe');
iframeWithOwnPolicy.srcdoc = "<meta name='referrer' content='" + iframePolicy + "'>Hello world.";
iframeWithOwnPolicy.onload = function () {
iframeWithOwnPolicy.onload = test.step_func(function () {
var nextUrl = url + "&cache_destroyer3=" + (new Date()).getTime();
loadImageInWindow(nextUrl, function (img) {
loadImageInWindow(nextUrl, test.step_func(function (img) {
resolve(decodeImageData(extractImageData(img)));
}, null, iframeWithOwnPolicy.contentWindow);
};
}), null, iframeWithOwnPolicy.contentWindow);
});
document.body.appendChild(iframeWithOwnPolicy);
});
var pagePolicy = new Promise((resolve, reject) => {
loadImageInWindow(url, function (img) {
loadImageInWindow(url, test.step_func(function (img) {
resolve(decodeImageData(extractImageData(img)));
}, attributes, window);
}), attributes, window);
});
Promise.all([noSrcDocPolicy, srcDocPolicy, pagePolicy]).then(test.step_func(values => {
@ -159,52 +159,52 @@ function queryImage(url, callback, attributes, referrerPolicy, test) {
}));
}
function queryXhr(url, callback) {
function queryXhr(url, callback, attributes, referrer_policy, test) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onreadystatechange = function(e) {
if (this.readyState == 4 && this.status == 200) {
var server_data = JSON.parse(this.responseText);
xhr.onreadystatechange = test.step_func(function(e) {
if (xhr.readyState == 4 && xhr.status == 200) {
var server_data = JSON.parse(xhr.responseText);
callback(wrapResult(url, server_data), url);
}
};
});
xhr.send();
}
function queryWorker(url, callback) {
function queryWorker(url, callback, attributes, referrer_policy, test) {
var worker = new Worker(url);
worker.onmessage = function(event) {
worker.onmessage = test.step_func(function(event) {
var server_data = event.data;
callback(wrapResult(url, server_data), url);
};
}
function queryModuleWorkerTopLevel(url, callback) {
var worker = new Worker(url, {type: "module"});
worker.onmessage = function(event) {
var server_data = event.data;
callback(wrapResult(url, server_data), url);
};
}
function querySharedWorker(url, callback) {
var worker = new SharedWorker(url);
worker.port.onmessage = function(event) {
var server_data = event.data;
callback(wrapResult(url, server_data), url);
};
}
function queryFetch(url, callback) {
fetch(url).then(function(response) {
response.json().then(function(server_data) {
callback(wrapResult(url, server_data), url);
});
}
function queryModuleWorkerTopLevel(url, callback, attributes, referrer_policy, test) {
var worker = new Worker(url, {type: "module"});
worker.onmessage = test.step_func(function(event) {
var server_data = event.data;
callback(wrapResult(url, server_data), url);
});
}
function querySharedWorker(url, callback, attributes, referrer_policy, test) {
var worker = new SharedWorker(url);
worker.port.onmessage = test.step_func(function(event) {
var server_data = event.data;
callback(wrapResult(url, server_data), url);
});
}
function queryFetch(url, callback, attributes, referrer_policy, test) {
fetch(url).then(test.step_func(function(response) {
response.json().then(test.step_func(function(server_data) {
callback(wrapResult(url, server_data), url);
}));
})
);
}
function queryNavigable(element, url, callback, attributes) {
function queryNavigable(element, url, callback, attributes, test) {
var navigable = element
navigable.href = url;
navigable.target = "helper-iframe";
@ -220,42 +220,41 @@ function queryNavigable(element, url, callback, attributes) {
}
}
var listener = function(event) {
var listener = test.step_func(function(event) {
if (event.source != helperIframe.contentWindow)
return;
callback(event.data, url);
window.removeEventListener("message", listener);
}
});
window.addEventListener("message", listener);
navigable.click();
}
function queryLink(url, callback, referrer_policy) {
function queryLink(url, callback, attributes, referrer_policy, test) {
var a = document.createElement("a");
a.innerHTML = "Link to subresource";
document.body.appendChild(a);
queryNavigable(a, url, callback, referrer_policy)
queryNavigable(a, url, callback, attributes, test)
}
function queryAreaLink(url, callback, referrer_policy) {
function queryAreaLink(url, callback, attributes, referrer_policy, test) {
var area = document.createElement("area");
// TODO(kristijanburnik): Append to map and add image.
document.body.appendChild(area);
queryNavigable(area, url, callback, referrer_policy)
queryNavigable(area, url, callback, attributes, test)
}
function queryScript(url, callback, attributes, referrer_policy) {
function queryScript(url, callback, attributes, referrer_policy, test) {
var script = document.createElement("script");
script.src = url;
script.referrerPolicy = referrer_policy;
var listener = function(event) {
var listener = test.step_func(function(event) {
var server_data = event.data;
callback(wrapResult(url, server_data), url);
window.removeEventListener("message", listener);
}
});
window.addEventListener("message", listener);
document.body.appendChild(script);

View file

@ -96,12 +96,12 @@ function ReferrerPolicyTestCase(scenario, testDescription, sanityChecker) {
},
start: function() {
async_test(function(test) {
t._constructSubresourceUrl();
t._constructExpectedReferrerUrl();
var test = async_test(t._testDescription);
t._invokeSubresource(function(result) {
t._invokeSubresource(test.step_func(function(result) {
// Check if the result is in valid format. NOOP in release.
sanityChecker.checkSubresourceResult(
test, t._scenario, t._subresourceUrl, result);
@ -119,8 +119,8 @@ function ReferrerPolicyTestCase(scenario, testDescription, sanityChecker) {
}, "Reported Referrer URL is as expected: " + t._scenario.referrer_url);
test.done();
}, test);
}), test);
}, t._testDescription);
}
}

View file

@ -13,7 +13,7 @@
<h1>Referrer Policy: A document with an opaque origin doesn't send referrers</h1>
<script>
function testSandboxedIframe(description, sandboxAttributes, expectedReferrer) {
var test = async_test(description);
async_test(function(test) {
window.addEventListener("message", test.step_func((msg) => {
if (msg.data.description === description) {
assert_equals(msg.data.referrer, expectedReferrer);
@ -30,9 +30,11 @@
var urlPath = "/referrer-policy/generic/subresource/xhr.py";
var url = "${location.protocol}//www1.${location.hostname}:${location.port}" + urlPath;
queryXhr(url, (msg) => {
parent.postMessage({referrer: msg.referrer, description: "${description}"}, "*")});
parent.postMessage({referrer: msg.referrer, description: "${description}"}, "*")
}, null, null, test);
</` + "script>";
document.body.appendChild(iframe);
}, description);
}
testSandboxedIframe("Sandboxed iframe with opaque origin doesn't send referrers.", "allow-scripts", undefined);

View file

@ -16,7 +16,7 @@
<pre id="received_message">Running...</pre>
<script>
var messaging_test = async_test("Area is responding with HTTP headers");
async_test(function(messaging_test) {
var urlPath = '/referrer-policy/generic/subresource/document.py';
var url = location.protocol + "//www1." + location.hostname + ":" + location.port +
urlPath;
@ -26,12 +26,11 @@
pre.innerHTML = "";
pre.innerHTML += url + ":\n\n";
pre.innerHTML += JSON.stringify(headers, null, 2) + "\n\n"
messaging_test.step(function() {
assert_own_property(headers, "host")
assert_own_property(headers, "connection")
});
messaging_test.done();
});
}, null, null, messaging_test);
}, "Area is responding with HTTP headers");
</script>
<div id="log"></div>

View file

@ -24,7 +24,7 @@
if (!window.fetch)
return;
var fetch_test = async_test("Fetch is responding with HTTP headers");
async_test(function(fetch_test) {
var urlPath = '/referrer-policy/generic/subresource/xhr.py';
var url = location.protocol + "//" + location.hostname + ":" +
location.port + urlPath;
@ -34,12 +34,11 @@
pre.innerHTML = "";
pre.innerHTML += url + ":\n\n";
pre.innerHTML += JSON.stringify(headers, null, 2) + "\n\n";
fetch_test.step(function() {
assert_own_property(headers, "host")
assert_own_property(headers, "connection")
});
fetch_test.done();
});
}, null, null, fetch_test);
}, "Fetch is responding with HTTP headers");
})();
</script>

View file

@ -16,7 +16,7 @@
<pre id="received_message">Running...</pre>
<script>
var messaging_test = async_test("Iframe is responding with HTTP headers");
async_test(function(messaging_test) {
var urlPath = '/referrer-policy/generic/subresource/document.py';
var url = location.protocol + "//www1." + location.hostname + ":" + location.port +
urlPath;
@ -26,12 +26,11 @@
pre.innerHTML = "";
pre.innerHTML += url + ":\n\n";
pre.innerHTML += JSON.stringify(headers, null, 2) + "\n\n"
messaging_test.step(function() {
assert_own_property(headers, "host")
assert_own_property(headers, "connection")
});
messaging_test.done();
});
}, null, null, messaging_test);
}, "Iframe is responding with HTTP headers");
</script>
<div id="log"></div>

View file

@ -16,7 +16,7 @@
<pre id="received_message">Running...</pre>
<script>
var messaging_test = async_test("Image is encoding headers as JSON.");
async_test(function(messaging_test) {
var urlPath = '/referrer-policy/generic/subresource/image.py';
var url = location.protocol + "//www1." + location.hostname + ":" + location.port +
urlPath + "?cache_destroyer=" + (new Date()).getTime();
@ -26,12 +26,11 @@
pre.innerHTML = "";
pre.innerHTML += url + ":\n\n";
pre.innerHTML += JSON.stringify(headers, null, 2) + "\n\n"
messaging_test.step(function() {
assert_own_property(headers, "host")
assert_own_property(headers, "connection")
});
messaging_test.done();
}, null, "always", messaging_test);
}, "Image is encoding headers as JSON.");
</script>
<div id="log"></div>

View file

@ -16,7 +16,7 @@
<pre id="received_message">Running...</pre>
<script>
var messaging_test = async_test("Link is responding with HTTP headers");
async_test(function(messaging_test) {
var urlPath = '/referrer-policy/generic/subresource/document.py';
var url = location.protocol + "//www1." + location.hostname + ":" + location.port +
urlPath;
@ -26,12 +26,11 @@
pre.innerHTML = "";
pre.innerHTML += url + ":\n\n";
pre.innerHTML += JSON.stringify(headers, null, 2) + "\n\n"
messaging_test.step(function() {
assert_own_property(headers, "host")
assert_own_property(headers, "connection")
});
messaging_test.done();
});
}, null, null, messaging_test);
}, "Link is responding with HTTP headers");
</script>
<div id="log"></div>

View file

@ -16,7 +16,7 @@
<pre id="received_message">Running...</pre>
<script>
var messaging_test = async_test("Script is responding with HTTP headers");
async_test(function(messaging_test) {
var urlPath = '/referrer-policy/generic/subresource/script.py';
var url = location.protocol + "//www1." + location.hostname + ":" + location.port +
urlPath;
@ -26,12 +26,11 @@
pre.innerHTML = "";
pre.innerHTML += url + ":\n\n";
pre.innerHTML += JSON.stringify(headers, null, 2) + "\n\n"
messaging_test.step(function() {
assert_own_property(headers, "host")
assert_own_property(headers, "connection")
});
messaging_test.done();
});
}, null, null, messaging_test);
}, "Script is responding with HTTP headers");
</script>
<div id="log"></div>

View file

@ -16,7 +16,7 @@
<pre id="received_message">Running...</pre>
<script>
var messaging_test = async_test("Worker is responding with HTTP headers");
async_test(function(messaging_test) {
var urlPath = '/referrer-policy/generic/subresource/worker.py';
var url = location.protocol + "//" + location.hostname + ":" +
location.port + urlPath;
@ -26,12 +26,11 @@
pre.innerHTML = "";
pre.innerHTML += url + ":\n\n";
pre.innerHTML += JSON.stringify(headers, null, 2) + "\n\n"
messaging_test.step(function() {
assert_own_property(headers, "host")
assert_own_property(headers, "connection")
});
messaging_test.done();
});
}, null, null, messaging_test);
}, "Worker is responding with HTTP headers");
</script>
<div id="log"></div>

View file

@ -16,7 +16,7 @@
<pre id="received_message">Running...</pre>
<script>
var messaging_test = async_test("XHR is responding with HTTP headers");
async_test(function(messaging_test) {
var urlPath = '/referrer-policy/generic/subresource/xhr.py';
var url = location.protocol + "//www1." + location.hostname + ":" + location.port +
urlPath;
@ -26,12 +26,11 @@
pre.innerHTML = "";
pre.innerHTML += url + ":\n\n";
pre.innerHTML += JSON.stringify(headers, null, 2) + "\n\n"
messaging_test.step(function() {
assert_own_property(headers, "host")
assert_own_property(headers, "connection")
});
messaging_test.done();
});
}, null, null, messaging_test);
}, "XHR is responding with HTTP headers");
</script>
<div id="log"></div>

View file

@ -15,14 +15,15 @@
<pre id="received_message">Running...</pre>
<script>
var test = async_test("Image has a referrer despite CSP 'referrer' directive");
async_test(function(test) {
var urlPath = '/referrer-policy/generic/subresource/image.py?cache_destroyer=' + (new Date()).getTime();
var url = location.protocol + "//www1." + location.hostname + ":" + location.port +
urlPath;
queryImage(url, test.step_func(function(message) {
queryImage(url, function(message) {
assert_equals(message.referrer, document.location.href);
test.done();
}), null, 'always', test);
}, null, 'always', test);
}, "Image has a referrer despite CSP 'referrer' directive");
</script>
<div id="log"></div>