Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve idlharness-ShadowRealm integration #49342

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions compression/idlharness-shadowrealm.window.js

This file was deleted.

1 change: 1 addition & 0 deletions compression/idlharness.https.any.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
// META: global=window,dedicatedworker,shadowrealm-in-window

'use strict';

Expand Down
6 changes: 0 additions & 6 deletions console/idlharness-shadowrealm.window.js

This file was deleted.

1 change: 1 addition & 0 deletions console/idlharness.any.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
// META: global=window,dedicatedworker,shadowrealm-in-window

// https://console.spec.whatwg.org/

Expand Down
3 changes: 0 additions & 3 deletions dom/idlharness-shadowrealm.window.js

This file was deleted.

2 changes: 1 addition & 1 deletion dom/idlharness.any.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// META: global=worker
// META: global=worker,shadowrealm-in-window
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
// META: timeout=long
Expand Down
3 changes: 0 additions & 3 deletions encoding/idlharness-shadowrealm.window.js

This file was deleted.

2 changes: 1 addition & 1 deletion encoding/idlharness.any.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// META: global=window,worker
// META: global=window,worker,shadowrealm-in-window
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js

Expand Down
3 changes: 0 additions & 3 deletions hr-time/idlharness-shadowrealm.window.js

This file was deleted.

6 changes: 5 additions & 1 deletion hr-time/idlharness.any.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// META: global=window,worker
// META: global=window,worker,shadowrealm-in-window
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
// META: timeout=long
Expand All @@ -11,6 +11,10 @@ idl_test(
['hr-time'],
['html', 'dom'],
async idl_array => {
if (self.GLOBAL.isShadowRealm()) {
return;
}

if (self.GLOBAL.isWorker()) {
idl_array.add_objects({ WorkerGlobalScope: ['self'] });
} else {
Expand Down
3 changes: 0 additions & 3 deletions html/dom/idlharness-shadowrealm.window.js

This file was deleted.

13 changes: 8 additions & 5 deletions html/dom/idlharness.worker.js → html/dom/idlharness.any.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
"use strict";
// META: global=dedicatedworker,shadowrealm-in-window
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js

importScripts("/resources/testharness.js");
importScripts("/resources/WebIDLParser.js", "/resources/idlharness.js");
"use strict";

idl_test(
["html"],
["wai-aria", "dom", "cssom", "touch-events", "uievents", "performance-timeline"],
idlArray => {
if (self.GLOBAL.isShadowRealm()) {
return;
}

idlArray.add_untested_idls('typedef Window WindowProxy;');
idlArray.add_objects({
WorkerLocation: ['self.location'],
Expand All @@ -18,5 +23,3 @@ idl_test(
});
}
);

done();
3 changes: 0 additions & 3 deletions performance-timeline/idlharness-shadowrealm.window.js

This file was deleted.

6 changes: 5 additions & 1 deletion performance-timeline/idlharness.any.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// META: global=window,worker
// META: global=window,worker,shadowrealm-in-window
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js

Expand All @@ -10,6 +10,10 @@ idl_test(
['performance-timeline'],
['hr-time', 'dom'],
async idl_array => {
if (self.GLOBAL.isShadowRealm()) {
return;
}

idl_array.add_objects({
Performance: ['performance'],
PerformanceObserver: ['observer'],
Expand Down
52 changes: 0 additions & 52 deletions resources/idlharness-shadowrealm.js

This file was deleted.

19 changes: 16 additions & 3 deletions resources/idlharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ IdlArray.prototype.test = function()

Object.getOwnPropertyNames(this.members).forEach(function(memberName) {
var member = this.members[memberName];
if (!(member instanceof IdlInterface)) {
if (!(member instanceof IdlInterface || member instanceof IdlNamespace)) {
return;
}

Expand Down Expand Up @@ -1421,7 +1421,7 @@ IdlInterface.prototype.test = function()
if (!this.untested)
{
subsetTestByKey(this.name, test, function() {
assert_false(this.name in self);
assert_false(this.name in self, this.name + " interface should not exist");
}.bind(this), this.name + " interface: existence and properties of interface object");
}
return;
Expand Down Expand Up @@ -3451,6 +3451,17 @@ IdlNamespace.prototype.test_self = function ()

IdlNamespace.prototype.test = function ()
{
// If the namespace object is not exposed, only test that. Members can't be
ptomato marked this conversation as resolved.
Show resolved Hide resolved
// tested either
if (!this.exposed) {
if (!this.untested) {
subsetTestByKey(this.name, test, function() {
assert_false(this.name in self, this.name + " namespace should not exist");
}.bind(this), this.name + " namespace: existence and properties of namespace object");
}
return;
}

if (!this.untested) {
this.test_self();
}
Expand Down Expand Up @@ -3498,7 +3509,7 @@ function idl_test(srcs, deps, idl_setup_func) {
"require-exposed"
];
return Promise.all(
srcs.concat(deps).map(fetch_spec))
srcs.concat(deps).map(globalThis.fetch_spec))
.then(function(results) {
const astArray = results.map(result =>
WebIDL2.parse(result.idl, { sourceName: result.spec })
Expand Down Expand Up @@ -3539,9 +3550,11 @@ function idl_test(srcs, deps, idl_setup_func) {
});
}, 'idl_test setup');
}
globalThis.idl_test = idl_test;

/**
* fetch_spec is a shorthand for a Promise that fetches the spec's content.
* Note: ShadowRealm-specific implementation in testharness-shadowrealm-inner.js
*/
function fetch_spec(spec) {
var url = '/interfaces/' + spec + '.idl';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@
namespace baz {
DOMString LongStory(any hero, DOMString... details);
DOMString ShortStory(DOMString... details);
};`);
};
[Exposed=Worker]
namespace Absent {
undefined Lies();
};
`);
idlArray.test();
</script>
<script type="text/json" id="expected">
Expand Down Expand Up @@ -233,6 +238,12 @@
"status_string": "PASS",
"properties": {},
"message": null
},
{
"name": "Absent namespace: existence and properties of namespace object",
"status_string": "PASS",
"properties": {},
"message": null
}
],
"type": "complete"
Expand Down
11 changes: 11 additions & 0 deletions resources/testharness-shadowrealm-inner.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ globalThis.setShadowRealmGlobalProperties = function (queryString, fetchAdaptor)
return new Promise(executor).then((s) => JSON.parse(s));
};

// Used only by idlharness.js
globalThis.fetch_spec = (spec) => {
const resource = `/interfaces/${spec}.idl`;
const executor = fetchAdaptor(resource);
return new Promise(executor).then(
idl => ({ spec, idl }),
() => {
throw new IdlHarnessError(`Error fetching ${resource}.`);
});
}

globalThis.location = { search: queryString };
};

Expand Down
3 changes: 0 additions & 3 deletions streams/idlharness-shadowrealm.window.js

This file was deleted.

2 changes: 1 addition & 1 deletion streams/idlharness.any.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// META: global=window,worker
// META: global=window,worker,shadowrealm-in-window
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
// META: timeout=long
Expand Down
3 changes: 0 additions & 3 deletions url/idlharness-shadowrealm.window.js

This file was deleted.

1 change: 1 addition & 0 deletions url/idlharness.any.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
// META: global=window,dedicatedworker,shadowrealm-in-window

idl_test(
['url'],
Expand Down
3 changes: 0 additions & 3 deletions user-timing/idlharness-shadowrealm.window.js

This file was deleted.

6 changes: 5 additions & 1 deletion user-timing/idlharness.any.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// META: global=window,worker
// META: global=window,worker,shadowrealm-in-window
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
// META: timeout=long
Expand All @@ -11,6 +11,10 @@ idl_test(
['user-timing'],
['hr-time', 'performance-timeline', 'dom'],
idl_array => {
if (self.GLOBAL.isShadowRealm()) {
return;
}

try {
performance.mark('test');
performance.measure('test');
Expand Down
3 changes: 0 additions & 3 deletions wasm/jsapi/idlharness-shadowrealm.window.js

This file was deleted.

1 change: 1 addition & 0 deletions wasm/jsapi/idlharness.any.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
// META: script=../resources/load_wasm.js
// META: global=window,dedicatedworker,shadowrealm-in-window

'use strict';

Expand Down
13 changes: 0 additions & 13 deletions webidl/idlharness-shadowrealm.window.js

This file was deleted.

1 change: 1 addition & 0 deletions webidl/idlharness.any.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
// META: global=window,dedicatedworker,shadowrealm-in-window

"use strict";

Expand Down