mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue