mirror of
https://github.com/servo/servo.git
synced 2025-08-11 00:15:32 +01:00
Update web-platform-tests to revision 8a2ceb5f18911302b7a5c1cd2791f4ab50ad4326
This commit is contained in:
parent
462c272380
commit
1f531f66ea
5377 changed files with 174916 additions and 84369 deletions
100
tests/wpt/web-platform-tests/resources/sriharness.js
Normal file
100
tests/wpt/web-platform-tests/resources/sriharness.js
Normal file
|
@ -0,0 +1,100 @@
|
|||
var SRIScriptTest = function(pass, name, src, integrityValue, crossoriginValue, nonce) {
|
||||
this.pass = pass;
|
||||
this.name = "Script: " + name;
|
||||
this.src = src;
|
||||
this.integrityValue = integrityValue;
|
||||
this.crossoriginValue = crossoriginValue;
|
||||
this.nonce = nonce;
|
||||
}
|
||||
|
||||
SRIScriptTest.prototype.execute = function() {
|
||||
var test = async_test(this.name);
|
||||
var e = document.createElement("script");
|
||||
e.src = this.src;
|
||||
e.setAttribute("integrity", this.integrityValue);
|
||||
if(this.crossoriginValue) {
|
||||
e.setAttribute("crossorigin", this.crossoriginValue);
|
||||
}
|
||||
if(this.nonce) {
|
||||
e.setAttribute("nonce", this.nonce);
|
||||
}
|
||||
if(this.pass) {
|
||||
e.addEventListener("load", function() {test.done()});
|
||||
e.addEventListener("error", function() {
|
||||
test.step(function(){ assert_unreached("Good load fired error handler.") })
|
||||
});
|
||||
} else {
|
||||
e.addEventListener("load", function() {
|
||||
test.step(function() { assert_unreached("Bad load succeeded.") })
|
||||
});
|
||||
e.addEventListener("error", function() {test.done()});
|
||||
}
|
||||
document.body.appendChild(e);
|
||||
};
|
||||
|
||||
// <link> tests
|
||||
// Style tests must be done synchronously because they rely on the presence
|
||||
// and absence of global style, which can affect later tests. Thus, instead
|
||||
// of executing them one at a time, the style tests are implemented as a
|
||||
// queue that builds up a list of tests, and then executes them one at a
|
||||
// time.
|
||||
var SRIStyleTest = function(queue, pass, name, attrs, customCallback, altPassValue) {
|
||||
this.pass = pass;
|
||||
this.name = "Style: " + name;
|
||||
this.customCallback = customCallback || function () {};
|
||||
this.attrs = attrs || {};
|
||||
this.passValue = altPassValue || "rgb(255, 255, 0)";
|
||||
|
||||
this.test = async_test(this.name);
|
||||
|
||||
this.queue = queue;
|
||||
this.queue.push(this);
|
||||
}
|
||||
|
||||
SRIStyleTest.prototype.execute = function() {
|
||||
var that = this;
|
||||
var container = document.getElementById("container");
|
||||
while (container.hasChildNodes()) {
|
||||
container.removeChild(container.firstChild);
|
||||
}
|
||||
|
||||
var test = this.test;
|
||||
|
||||
var div = document.createElement("div");
|
||||
div.className = "testdiv";
|
||||
var e = document.createElement("link");
|
||||
this.attrs.rel = this.attrs.rel || "stylesheet";
|
||||
for (var key in this.attrs) {
|
||||
if (this.attrs.hasOwnProperty(key)) {
|
||||
e.setAttribute(key, this.attrs[key]);
|
||||
}
|
||||
}
|
||||
|
||||
if(this.pass) {
|
||||
e.addEventListener("load", function() {
|
||||
test.step(function() {
|
||||
var background = window.getComputedStyle(div, null).getPropertyValue("background-color");
|
||||
assert_equals(background, that.passValue);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
e.addEventListener("error", function() {
|
||||
test.step(function(){ assert_unreached("Good load fired error handler.") })
|
||||
});
|
||||
} else {
|
||||
e.addEventListener("load", function() {
|
||||
test.step(function() { assert_unreached("Bad load succeeded.") })
|
||||
});
|
||||
e.addEventListener("error", function() {
|
||||
test.step(function() {
|
||||
var background = window.getComputedStyle(div, null).getPropertyValue("background-color");
|
||||
assert_not_equals(background, that.passValue);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
}
|
||||
container.appendChild(div);
|
||||
container.appendChild(e);
|
||||
this.customCallback(e, container);
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue