mirror of
https://github.com/servo/servo.git
synced 2025-09-06 04:58:21 +01:00
Update web-platform-tests to revision 132d12daea699ce266324e79eecbe59b10e56502
This commit is contained in:
parent
527d874bc1
commit
fe00a63040
1004 changed files with 18598 additions and 92770 deletions
|
@ -662,42 +662,48 @@ IdlArray.prototype.is_json_type = function(type)
|
|||
};
|
||||
|
||||
function exposure_set(object, default_set) {
|
||||
var exposed = object.extAttrs.filter(function(a) { return a.name == "Exposed" });
|
||||
if (exposed.length > 1) {
|
||||
var exposed = object.extAttrs && object.extAttrs.filter(a => a.name === "Exposed");
|
||||
if (exposed && exposed.length > 1) {
|
||||
throw new IdlHarnessError(
|
||||
`Multiple 'Exposed' extended attributes on ${object.name}`);
|
||||
}
|
||||
|
||||
if (exposed.length === 0) {
|
||||
return default_set;
|
||||
let result = default_set || ["Window"];
|
||||
if (result && !(result instanceof Set)) {
|
||||
result = new Set(result);
|
||||
}
|
||||
|
||||
var set = exposed[0].rhs.value;
|
||||
// Could be a list or a string.
|
||||
if (typeof set == "string") {
|
||||
set = [ set ];
|
||||
if (exposed && exposed.length) {
|
||||
var set = exposed[0].rhs.value;
|
||||
// Could be a list or a string.
|
||||
if (typeof set == "string") {
|
||||
set = [ set ];
|
||||
}
|
||||
result = new Set(set);
|
||||
}
|
||||
return set;
|
||||
if (result && result.has("Worker")) {
|
||||
result.delete("Worker");
|
||||
result.add("DedicatedWorker");
|
||||
result.add("ServiceWorker");
|
||||
result.add("SharedWorker");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function exposed_in(globals) {
|
||||
if ('document' in self) {
|
||||
return globals.indexOf("Window") >= 0;
|
||||
return globals.has("Window");
|
||||
}
|
||||
if ('DedicatedWorkerGlobalScope' in self &&
|
||||
self instanceof DedicatedWorkerGlobalScope) {
|
||||
return globals.indexOf("Worker") >= 0 ||
|
||||
globals.indexOf("DedicatedWorker") >= 0;
|
||||
return globals.has("DedicatedWorker");
|
||||
}
|
||||
if ('SharedWorkerGlobalScope' in self &&
|
||||
self instanceof SharedWorkerGlobalScope) {
|
||||
return globals.indexOf("Worker") >= 0 ||
|
||||
globals.indexOf("SharedWorker") >= 0;
|
||||
return globals.has("SharedWorker");
|
||||
}
|
||||
if ('ServiceWorkerGlobalScope' in self &&
|
||||
self instanceof ServiceWorkerGlobalScope) {
|
||||
return globals.indexOf("Worker") >= 0 ||
|
||||
globals.indexOf("ServiceWorker") >= 0;
|
||||
return globals.has("ServiceWorker");
|
||||
}
|
||||
throw new IdlHarnessError("Unexpected global object");
|
||||
}
|
||||
|
@ -737,27 +743,7 @@ IdlArray.prototype.test = function()
|
|||
|
||||
// First merge in all the partial interfaces and implements statements we
|
||||
// encountered.
|
||||
this.partials.forEach(function(parsed_idl)
|
||||
{
|
||||
if (!(parsed_idl.name in this.members)
|
||||
|| !(this.members[parsed_idl.name] instanceof IdlInterface
|
||||
|| this.members[parsed_idl.name] instanceof IdlDictionary))
|
||||
{
|
||||
throw new IdlHarnessError(`Partial ${parsed_idl.type} ${parsed_idl.name} with no original ${parsed_idl.type}`);
|
||||
}
|
||||
if (parsed_idl.extAttrs)
|
||||
{
|
||||
parsed_idl.extAttrs.forEach(function(extAttr)
|
||||
{
|
||||
this.members[parsed_idl.name].extAttrs.push(extAttr);
|
||||
}.bind(this));
|
||||
}
|
||||
parsed_idl.members.forEach(function(member)
|
||||
{
|
||||
this.members[parsed_idl.name].members.push(new IdlInterfaceMember(member));
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
this.partials = [];
|
||||
this.collapse_partials();
|
||||
|
||||
for (var lhs in this["implements"])
|
||||
{
|
||||
|
@ -814,7 +800,7 @@ IdlArray.prototype.test = function()
|
|||
return;
|
||||
}
|
||||
|
||||
var globals = exposure_set(member, ["Window"]);
|
||||
var globals = exposure_set(member);
|
||||
member.exposed = exposed_in(globals);
|
||||
member.exposureSet = globals;
|
||||
}.bind(this));
|
||||
|
@ -833,6 +819,78 @@ IdlArray.prototype.test = function()
|
|||
}
|
||||
};
|
||||
|
||||
//@}
|
||||
IdlArray.prototype.collapse_partials = function()
|
||||
//@{
|
||||
{
|
||||
const testedPartials = new Map();
|
||||
this.partials.forEach(function(parsed_idl)
|
||||
{
|
||||
const originalExists = parsed_idl.name in this.members
|
||||
&& (this.members[parsed_idl.name] instanceof IdlInterface
|
||||
|| this.members[parsed_idl.name] instanceof IdlDictionary);
|
||||
|
||||
let partialTestName = parsed_idl.name;
|
||||
if (!parsed_idl.untested) {
|
||||
// Ensure unique test name in case of multiple partials.
|
||||
let partialTestCount = 1;
|
||||
if (testedPartials.has(parsed_idl.name)) {
|
||||
partialTestCount += testedPartials.get(parsed_idl.name);
|
||||
partialTestName = `${partialTestName}[${partialTestCount}]`;
|
||||
}
|
||||
testedPartials.set(parsed_idl.name, partialTestCount);
|
||||
|
||||
test(function () {
|
||||
assert_true(originalExists, `Original ${parsed_idl.type} should be defined`);
|
||||
}.bind(this), `Partial ${parsed_idl.type} ${partialTestName}: original ${parsed_idl.type} defined`);
|
||||
}
|
||||
if (!originalExists) {
|
||||
// Not good.. but keep calm and carry on.
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsed_idl.extAttrs)
|
||||
{
|
||||
// Special-case "Exposed". Must be a subset of original interface's exposure.
|
||||
// Exposed on a partial is the equivalent of having the same Exposed on all nested members.
|
||||
// See https://github.com/heycam/webidl/issues/154 for discrepency between Exposed and
|
||||
// other extended attributes on partial interfaces.
|
||||
const exposureAttr = parsed_idl.extAttrs.find(a => a.name === "Exposed");
|
||||
if (exposureAttr) {
|
||||
if (!parsed_idl.untested) {
|
||||
test(function () {
|
||||
const partialExposure = exposure_set(parsed_idl);
|
||||
const memberExposure = exposure_set(this.members[parsed_idl.name]);
|
||||
partialExposure.forEach(name => {
|
||||
if (!memberExposure || !memberExposure.has(name)) {
|
||||
throw new IdlHarnessError(
|
||||
`Partial ${parsed_idl.name} ${parsed_idl.type} is exposed to '${name}', the original ${parsed_idl.type} is not.`);
|
||||
}
|
||||
});
|
||||
}.bind(this), `Partial ${parsed_idl.type} ${partialTestName}: valid exposure set`);
|
||||
}
|
||||
parsed_idl.members.forEach(function (member) {
|
||||
member.extAttrs.push(exposureAttr);
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
parsed_idl.extAttrs.forEach(function(extAttr)
|
||||
{
|
||||
// "Exposed" already handled above.
|
||||
if (extAttr.name === "Exposed") {
|
||||
return;
|
||||
}
|
||||
this.members[parsed_idl.name].extAttrs.push(extAttr);
|
||||
}.bind(this));
|
||||
}
|
||||
parsed_idl.members.forEach(function(member)
|
||||
{
|
||||
this.members[parsed_idl.name].members.push(new IdlInterfaceMember(member));
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
this.partials = [];
|
||||
}
|
||||
|
||||
//@}
|
||||
IdlArray.prototype.assert_type_is = function(value, type)
|
||||
//@{
|
||||
|
@ -1529,7 +1587,7 @@ IdlInterface.prototype.test_self = function()
|
|||
if (this.is_callback()) {
|
||||
throw new IdlHarnessError("Invalid IDL: LegacyWindowAlias extended attribute on non-interface " + this.name);
|
||||
}
|
||||
if (this.exposureSet.indexOf("Window") === -1) {
|
||||
if (!this.exposureSet.has("Window")) {
|
||||
throw new IdlHarnessError("Invalid IDL: LegacyWindowAlias extended attribute on " + this.name + " which is not exposed in Window");
|
||||
}
|
||||
// TODO: when testing of [NoInterfaceObject] interfaces is supported,
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>idlharness: Partial dictionary</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/WebIDLParser.js"></script>
|
||||
<script src="/resources/idlharness.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>Verify the series of sub-tests that are executed for "partial" dictionary objects.</p>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
// No original existence
|
||||
(() => {
|
||||
const idlArray = new IdlArray();
|
||||
idlArray.add_idls('partial dictionary A {};');
|
||||
idlArray.test();
|
||||
})();
|
||||
|
||||
// Multiple partials existence
|
||||
(() => {
|
||||
const idlArray = new IdlArray();
|
||||
idlArray.add_untested_idls('partial dictionary B {};');
|
||||
idlArray.add_idls('partial dictionary B {};');
|
||||
idlArray.add_idls('partial dictionary B {};');
|
||||
idlArray.add_idls('partial dictionary B {};');
|
||||
idlArray.add_idls('dictionary B {};');
|
||||
idlArray.test();
|
||||
})();
|
||||
</script>
|
||||
<script type="text/json" id="expected">
|
||||
{
|
||||
"summarized_status": {
|
||||
"status_string": "OK",
|
||||
"message": null
|
||||
},
|
||||
"summarized_tests": [
|
||||
{
|
||||
"name": "Partial dictionary A: original dictionary defined",
|
||||
"status_string": "FAIL",
|
||||
"properties": {},
|
||||
"message": "assert_true: Original dictionary should be defined expected true got false"
|
||||
},
|
||||
{
|
||||
"name": "Partial dictionary B: original dictionary defined",
|
||||
"status_string": "PASS",
|
||||
"properties": {},
|
||||
"message": null
|
||||
},
|
||||
{
|
||||
"name": "Partial dictionary B[2]: original dictionary defined",
|
||||
"status_string": "PASS",
|
||||
"properties": {},
|
||||
"message": null
|
||||
},
|
||||
{
|
||||
"name": "Partial dictionary B[3]: original dictionary defined",
|
||||
"status_string": "PASS",
|
||||
"properties": {},
|
||||
"message": null
|
||||
}
|
||||
],
|
||||
"type": "complete"
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -0,0 +1,110 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>idlharness: Partail interface</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/WebIDLParser.js"></script>
|
||||
<script src="/resources/idlharness.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>Verify the series of sub-tests that are executed for "partial" interface objects.</p>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
// No original existence
|
||||
(() => {
|
||||
const idlArray = new IdlArray();
|
||||
idlArray.add_idls('partial interface A {};');
|
||||
idlArray.test();
|
||||
})();
|
||||
|
||||
// Valid exposure (Note: Worker -> {Shared,Dedicated,Service}Worker)
|
||||
(() => {
|
||||
const idlArray = new IdlArray();
|
||||
idlArray.add_untested_idls(`
|
||||
[Exposed=(Worker)]
|
||||
interface B {};
|
||||
|
||||
[Exposed=(DedicatedWorker, ServiceWorker, SharedWorker)]
|
||||
interface C {};`);
|
||||
idlArray.add_idls(`
|
||||
[Exposed=(DedicatedWorker, ServiceWorker, SharedWorker)]
|
||||
partial interface B {};
|
||||
|
||||
[Exposed=(Worker)]
|
||||
partial interface C {};`);
|
||||
idlArray.collapse_partials();
|
||||
})();
|
||||
|
||||
// Invalid exposure
|
||||
(() => {
|
||||
const idlArray = new IdlArray();
|
||||
idlArray.add_untested_idls(`
|
||||
[Exposed=(Window, ServiceWorker)]
|
||||
interface D {};`);
|
||||
idlArray.add_idls(`
|
||||
[Exposed=(DedicatedWorker)]
|
||||
partial interface D {};`);
|
||||
idlArray.collapse_partials();
|
||||
})();
|
||||
</script>
|
||||
<script type="text/json" id="expected">
|
||||
{
|
||||
"summarized_status": {
|
||||
"status_string": "OK",
|
||||
"message": null
|
||||
},
|
||||
"summarized_tests": [
|
||||
{
|
||||
"name": "Partial interface A: original interface defined",
|
||||
"status_string": "FAIL",
|
||||
"properties": {},
|
||||
"message": "assert_true: Original interface should be defined expected true got false"
|
||||
},
|
||||
{
|
||||
"name": "Partial interface B: original interface defined",
|
||||
"status_string": "PASS",
|
||||
"properties": {},
|
||||
"message": null
|
||||
},
|
||||
{
|
||||
"name": "Partial interface B: valid exposure set",
|
||||
"status_string": "PASS",
|
||||
"properties": {},
|
||||
"message": null
|
||||
},
|
||||
{
|
||||
"name": "Partial interface C: original interface defined",
|
||||
"status_string": "PASS",
|
||||
"properties": {},
|
||||
"message": null
|
||||
},
|
||||
{
|
||||
"name": "Partial interface C: valid exposure set",
|
||||
"status_string": "PASS",
|
||||
"properties": {},
|
||||
"message": null
|
||||
},
|
||||
{
|
||||
"name": "Partial interface D: original interface defined",
|
||||
"status_string": "PASS",
|
||||
"properties": {},
|
||||
"message": null
|
||||
},
|
||||
{
|
||||
"name": "Partial interface D: valid exposure set",
|
||||
"status_string": "FAIL",
|
||||
"properties": {},
|
||||
"message": "Partial D interface is exposed to 'DedicatedWorker', the original interface is not."
|
||||
}
|
||||
],
|
||||
"type": "complete"
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -33,12 +33,6 @@ test(() => {
|
|||
let members = idlArray.members["A"].members.map(m => m.name);
|
||||
assert_array_equals(members, ["B", "C"], 'A should contain B, C');
|
||||
}, 'Partial dictionaries');
|
||||
|
||||
test(() => {
|
||||
let idlArray = new IdlArray();
|
||||
idlArray.add_idls('partial dictionary D {};');
|
||||
idlArray.assert_throws('Partial dictionary D with no original dictionary', i => i.test());
|
||||
}, 'Partial-only dictionary definition')
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
|
|
@ -29,28 +29,15 @@
|
|||
test(function() {
|
||||
assert_equals(typeof WebIDL2.parse("interface Foo {};"), "object");
|
||||
}, 'WebIDL2 parse method should produce an AST for correct WebIDL');
|
||||
for (let type of ['dictionary', 'interface']) {
|
||||
test(function() {
|
||||
test(function () {
|
||||
try {
|
||||
let i = new IdlArray();
|
||||
i.add_untested_idls(`partial ${type} A {};`);
|
||||
i.assert_throws(new IdlHarnessError(`Partial ${type} A with no original ${type}`), i => i.test());
|
||||
}, `assert_throws should handle ${type} IdlHarnessError`);
|
||||
test(function() {
|
||||
let i = new IdlArray();
|
||||
i.add_untested_idls(`partial ${type} A {};`);
|
||||
i.assert_throws(`Partial ${type} A with no original ${type}`, i => i.test());
|
||||
}, `assert_throws should handle ${type} IdlHarnessError from message`);
|
||||
test(function () {
|
||||
try {
|
||||
let i = new IdlArray();
|
||||
i.add_untested_idls(`${type} A {};`);
|
||||
i.assert_throws(`Partial ${type} A with no original ${type}`, i => i.test());
|
||||
} catch (e) {
|
||||
assert_true(e instanceof IdlHarnessError);
|
||||
}
|
||||
}, `assert_throws should throw if no ${type} IdlHarnessError thrown`);
|
||||
}
|
||||
i.add_untested_idls(`interface C {};`);
|
||||
i.assert_throws('Anything', i => i.test());
|
||||
} catch (e) {
|
||||
assert_true(e instanceof IdlHarnessError);
|
||||
}
|
||||
}, `assert_throws should throw if no IdlHarnessError thrown`);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue