mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35:33 +01:00
Wrap more of the referrer-policy tests in testharness.js.
This commit is contained in:
parent
bffe2a699e
commit
3cd6df1ef9
30 changed files with 540 additions and 583 deletions
|
@ -17,35 +17,33 @@
|
|||
<div class="styled"></div>
|
||||
|
||||
<script>
|
||||
var css_test = async_test("Image from imported stylesheet (external).");
|
||||
var id = token();
|
||||
var css_url = location.protocol + "//www1." + location.hostname + ":" + location.port +
|
||||
"/referrer-policy/generic/subresource/stylesheet.py?id=" + id +
|
||||
"&import-rule" + "&type=image";
|
||||
var url_prefix = location.protocol + "//" + location.hostname + ":" + location.port;
|
||||
var css_referrer = url_prefix +
|
||||
"/referrer-policy/generic/subresource/stylesheet.py?id=" + id +
|
||||
"&type=image";
|
||||
var img_url = url_prefix + "/referrer-policy/generic/subresource/image.py" +
|
||||
"?id=" + id + "&report-headers";
|
||||
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 +
|
||||
"&import-rule" + "&type=image";
|
||||
var url_prefix = location.protocol + "//" + location.hostname + ":" + location.port;
|
||||
var css_referrer = url_prefix +
|
||||
"/referrer-policy/generic/subresource/stylesheet.py?id=" + id +
|
||||
"&type=image";
|
||||
var img_url = url_prefix + "/referrer-policy/generic/subresource/image.py" +
|
||||
"?id=" + id + "&report-headers";
|
||||
|
||||
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() {
|
||||
assert_own_property(message, "headers");
|
||||
assert_own_property(message, "referrer");
|
||||
assert_equals(message.referrer, css_referrer);
|
||||
});
|
||||
css_test.done();
|
||||
}),
|
||||
1000);
|
||||
};
|
||||
document.head.appendChild(link);
|
||||
var link = document.createElement("link");
|
||||
link.href = css_url;
|
||||
link.rel = "stylesheet";
|
||||
link.onload = 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();
|
||||
}, null, null, css_test);
|
||||
}, 1000);
|
||||
};
|
||||
document.head.appendChild(link);
|
||||
}, "Image from imported stylesheet (external).");
|
||||
</script>
|
||||
|
||||
<div id="log"></div>
|
||||
|
|
|
@ -16,30 +16,28 @@
|
|||
<div class="styled"></div>
|
||||
|
||||
<script>
|
||||
var css_test = async_test("Image from external stylesheet.");
|
||||
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;
|
||||
var img_url = url_prefix + "/referrer-policy/generic/subresource/image.py" +
|
||||
"?id=" + id + "&report-headers";
|
||||
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;
|
||||
var img_url = url_prefix + "/referrer-policy/generic/subresource/image.py" +
|
||||
"?id=" + id + "&report-headers";
|
||||
|
||||
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() {
|
||||
assert_own_property(message, "headers");
|
||||
assert_own_property(message, "referrer");
|
||||
assert_equals(message.referrer, css_url);
|
||||
});
|
||||
css_test.done();
|
||||
}),
|
||||
1000);
|
||||
};
|
||||
document.head.appendChild(link);
|
||||
var link = document.createElement("link");
|
||||
link.href = css_url;
|
||||
link.rel = "stylesheet";
|
||||
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();
|
||||
}, null, null, css_test);
|
||||
}, 1000);
|
||||
});
|
||||
document.head.appendChild(link);
|
||||
}, "Image from external stylesheet.");
|
||||
</script>
|
||||
|
||||
<div id="log"></div>
|
||||
|
|
|
@ -16,25 +16,23 @@
|
|||
<div class="styled"></div>
|
||||
|
||||
<script>
|
||||
var css_test = async_test("Image from inline styles.");
|
||||
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";
|
||||
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() {
|
||||
assert_own_property(message, "headers");
|
||||
assert_own_property(message, "referrer");
|
||||
assert_equals(message.referrer, location.origin + "/");
|
||||
});
|
||||
css_test.done();
|
||||
}),
|
||||
1000);
|
||||
</script>
|
||||
var div = document.querySelector("div.styled");
|
||||
div.style = "content:url(" + css_url + ")";
|
||||
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();
|
||||
}, null, null, css_test);
|
||||
}, 1000);
|
||||
}, "Image from inline styles.");
|
||||
</script>
|
||||
|
||||
<div id="log"></div>
|
||||
</body>
|
||||
|
|
|
@ -17,28 +17,26 @@
|
|||
<div class="styled"></div>
|
||||
|
||||
<script>
|
||||
var css_test = async_test("Image from imported stylesheet (internal).");
|
||||
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;
|
||||
var img_url = url_prefix + "image.py?report-headers&id=" + id;
|
||||
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;
|
||||
var img_url = url_prefix + "image.py?report-headers&id=" + id;
|
||||
|
||||
var style = document.createElement("style");
|
||||
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() {
|
||||
assert_own_property(message, "headers");
|
||||
assert_own_property(message, "referrer");
|
||||
assert_equals(message.referrer, css_url);
|
||||
});
|
||||
css_test.done();
|
||||
}),
|
||||
1000);
|
||||
</script>
|
||||
var style = document.createElement("style");
|
||||
style.type = 'text/css';
|
||||
style.appendChild(document.createTextNode("@import url('" + css_url + "');"));
|
||||
document.head.appendChild(style);
|
||||
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();
|
||||
}, null, null, css_test);
|
||||
}, 1000);
|
||||
}, "Image from imported stylesheet (internal).");
|
||||
</script>
|
||||
|
||||
<div id="log"></div>
|
||||
</body>
|
||||
|
|
|
@ -16,27 +16,25 @@
|
|||
<div class="styled"></div>
|
||||
|
||||
<script>
|
||||
var css_test = async_test("Image from internal stylesheet.");
|
||||
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";
|
||||
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 style = document.createElement("style");
|
||||
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() {
|
||||
assert_own_property(message, "headers");
|
||||
assert_own_property(message, "referrer");
|
||||
assert_equals(message.referrer, location.origin + "/");
|
||||
});
|
||||
css_test.done();
|
||||
}),
|
||||
1000);
|
||||
</script>
|
||||
var style = document.createElement("style");
|
||||
style.type = 'text/css';
|
||||
style.appendChild(document.createTextNode("div.styled::before { content:url(" + css_url + ")}"));
|
||||
document.head.appendChild(style);
|
||||
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();
|
||||
}, null, null, css_test);
|
||||
}, 1000);
|
||||
}, "Image from internal stylesheet.");
|
||||
</script>
|
||||
|
||||
<div id="log"></div>
|
||||
</body>
|
||||
|
|
|
@ -14,24 +14,22 @@
|
|||
the referrer and referrer policy from the document.</p>
|
||||
|
||||
<script>
|
||||
var css_test = async_test("Image from presentation attributes.");
|
||||
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";
|
||||
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() {
|
||||
assert_own_property(message, "headers");
|
||||
assert_own_property(message, "referrer");
|
||||
assert_equals(message.referrer, location.origin + "/");
|
||||
});
|
||||
css_test.done();
|
||||
}),
|
||||
1000);
|
||||
</script>
|
||||
document.body.background = css_url;
|
||||
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();
|
||||
}, null, null, css_test);
|
||||
}, 1000);
|
||||
}, "Image from presentation attributes.");
|
||||
</script>
|
||||
|
||||
<div id="log"></div>
|
||||
</body>
|
||||
|
|
|
@ -17,26 +17,24 @@
|
|||
<div class="styled"></div>
|
||||
|
||||
<script>
|
||||
var css_test = async_test("Image from external stylesheet (from ProcessingInstruction).");
|
||||
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;
|
||||
var img_url = url_prefix + "/referrer-policy/generic/subresource/image.py" +
|
||||
"?id=" + id + "&report-headers";
|
||||
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;
|
||||
var img_url = url_prefix + "/referrer-policy/generic/subresource/image.py" +
|
||||
"?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() {
|
||||
assert_own_property(message, "headers");
|
||||
assert_own_property(message, "referrer");
|
||||
assert_equals(message.referrer, css_url);
|
||||
});
|
||||
css_test.done();
|
||||
}),
|
||||
1000);
|
||||
document.insertBefore(processingInstruction, document.firstChild);
|
||||
var processingInstruction = document.createProcessingInstruction("xml-stylesheet", "href=\"" + css_url + "\" type=\"text/css\"");
|
||||
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();
|
||||
}, null, null, css_test);
|
||||
}, 1000);
|
||||
document.insertBefore(processingInstruction, document.firstChild);
|
||||
}, "Image from external stylesheet (from ProcessingInstruction).");
|
||||
</script>
|
||||
|
||||
<div id="log"></div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue