Skip to content

Commit 87feb3a

Browse files
committed
test: add web-locks WPT
1 parent 949b24d commit 87feb3a

38 files changed

+2193
-83
lines changed

lib/internal/worker/locks.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ ObjectDefineProperties(LockManager.prototype, {
521521
});
522522

523523
module.exports = {
524+
Lock,
524525
LockManager,
525526
locks: ObjectCreate(LockManager.prototype)
526527
};

test/fixtures/wpt/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ Last update:
1313
- console: https://github.com/web-platform-tests/wpt/tree/3b1f72e99a/console
1414
- encoding: https://github.com/web-platform-tests/wpt/tree/1821fb5f77/encoding
1515
- url: https://github.com/web-platform-tests/wpt/tree/09d8830be1/url
16-
- resources: https://github.com/web-platform-tests/wpt/tree/001e50de41/resources
17-
- interfaces: https://github.com/web-platform-tests/wpt/tree/8719553b2d/interfaces
16+
- resources: https://github.com/web-platform-tests/wpt/tree/351a99782b/resources
17+
- interfaces: https://github.com/web-platform-tests/wpt/tree/c37c28b8a8/interfaces
1818
- html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/2c5c3c4c27/html/webappapis/microtask-queuing
1919
- html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/264f12bc7b/html/webappapis/timers
2020
- hr-time: https://github.com/web-platform-tests/wpt/tree/a5d1774ecf/hr-time
2121
- common: https://github.com/web-platform-tests/wpt/tree/4dacb6e2ff/common
2222
- dom/abort: https://github.com/web-platform-tests/wpt/tree/7caa3de747/dom/abort
23+
- web-locks: https://github.com/web-platform-tests/wpt/tree/e2ddf48b78/web-locks
2324

2425
[Web Platform Tests]: https://github.com/web-platform-tests/wpt
2526
[`git node wpt`]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md#git-node-wpt

test/fixtures/wpt/interfaces/dom.idl

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface Event {
99

1010
readonly attribute DOMString type;
1111
readonly attribute EventTarget? target;
12-
readonly attribute EventTarget? srcElement; // historical
12+
readonly attribute EventTarget? srcElement; // legacy
1313
readonly attribute EventTarget? currentTarget;
1414
sequence<EventTarget> composedPath();
1515

@@ -20,20 +20,20 @@ interface Event {
2020
readonly attribute unsigned short eventPhase;
2121

2222
undefined stopPropagation();
23-
attribute boolean cancelBubble; // historical alias of .stopPropagation
23+
attribute boolean cancelBubble; // legacy alias of .stopPropagation()
2424
undefined stopImmediatePropagation();
2525

2626
readonly attribute boolean bubbles;
2727
readonly attribute boolean cancelable;
28-
attribute boolean returnValue; // historical
28+
attribute boolean returnValue; // legacy
2929
undefined preventDefault();
3030
readonly attribute boolean defaultPrevented;
3131
readonly attribute boolean composed;
3232

3333
[LegacyUnforgeable] readonly attribute boolean isTrusted;
3434
readonly attribute DOMHighResTimeStamp timeStamp;
3535

36-
undefined initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); // historical
36+
undefined initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); // legacy
3737
};
3838

3939
dictionary EventInit {
@@ -43,7 +43,7 @@ dictionary EventInit {
4343
};
4444

4545
partial interface Window {
46-
[Replaceable] readonly attribute any event; // historical
46+
[Replaceable] readonly attribute any event; // legacy
4747
};
4848

4949
[Exposed=(Window,Worker)]
@@ -52,7 +52,7 @@ interface CustomEvent : Event {
5252

5353
readonly attribute any detail;
5454

55-
undefined initCustomEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional any detail = null); // historical
55+
undefined initCustomEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional any detail = null); // legacy
5656
};
5757

5858
dictionary CustomEventInit : EventInit {
@@ -79,6 +79,7 @@ dictionary EventListenerOptions {
7979
dictionary AddEventListenerOptions : EventListenerOptions {
8080
boolean passive = false;
8181
boolean once = false;
82+
AbortSignal signal;
8283
};
8384

8485
[Exposed=(Window,Worker)]
@@ -201,14 +202,14 @@ interface Node : EventTarget {
201202
const unsigned short ATTRIBUTE_NODE = 2;
202203
const unsigned short TEXT_NODE = 3;
203204
const unsigned short CDATA_SECTION_NODE = 4;
204-
const unsigned short ENTITY_REFERENCE_NODE = 5; // historical
205-
const unsigned short ENTITY_NODE = 6; // historical
205+
const unsigned short ENTITY_REFERENCE_NODE = 5; // legacy
206+
const unsigned short ENTITY_NODE = 6; // legacy
206207
const unsigned short PROCESSING_INSTRUCTION_NODE = 7;
207208
const unsigned short COMMENT_NODE = 8;
208209
const unsigned short DOCUMENT_NODE = 9;
209210
const unsigned short DOCUMENT_TYPE_NODE = 10;
210211
const unsigned short DOCUMENT_FRAGMENT_NODE = 11;
211-
const unsigned short NOTATION_NODE = 12; // historical
212+
const unsigned short NOTATION_NODE = 12; // legacy
212213
readonly attribute unsigned short nodeType;
213214
readonly attribute DOMString nodeName;
214215

@@ -232,7 +233,7 @@ interface Node : EventTarget {
232233

233234
[CEReactions, NewObject] Node cloneNode(optional boolean deep = false);
234235
boolean isEqualNode(Node? otherNode);
235-
boolean isSameNode(Node? otherNode); // historical alias of ===
236+
boolean isSameNode(Node? otherNode); // legacy alias of ===
236237

237238
const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01;
238239
const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02;
@@ -266,8 +267,8 @@ interface Document : Node {
266267
readonly attribute USVString documentURI;
267268
readonly attribute DOMString compatMode;
268269
readonly attribute DOMString characterSet;
269-
readonly attribute DOMString charset; // historical alias of .characterSet
270-
readonly attribute DOMString inputEncoding; // historical alias of .characterSet
270+
readonly attribute DOMString charset; // legacy alias of .characterSet
271+
readonly attribute DOMString inputEncoding; // legacy alias of .characterSet
271272
readonly attribute DOMString contentType;
272273

273274
readonly attribute DocumentType? doctype;
@@ -290,7 +291,7 @@ interface Document : Node {
290291
[NewObject] Attr createAttribute(DOMString localName);
291292
[NewObject] Attr createAttributeNS(DOMString? namespace, DOMString qualifiedName);
292293

293-
[NewObject] Event createEvent(DOMString interface); // historical
294+
[NewObject] Event createEvent(DOMString interface); // legacy
294295

295296
[NewObject] Range createRange();
296297

@@ -372,14 +373,14 @@ interface Element : Node {
372373

373374
Element? closest(DOMString selectors);
374375
boolean matches(DOMString selectors);
375-
boolean webkitMatchesSelector(DOMString selectors); // historical alias of .matches
376+
boolean webkitMatchesSelector(DOMString selectors); // legacy alias of .matches
376377

377378
HTMLCollection getElementsByTagName(DOMString qualifiedName);
378379
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
379380
HTMLCollection getElementsByClassName(DOMString classNames);
380381

381-
[CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // historical
382-
undefined insertAdjacentText(DOMString where, DOMString data); // historical
382+
[CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // legacy
383+
undefined insertAdjacentText(DOMString where, DOMString data); // legacy
383384
};
384385

385386
dictionary ShadowRootInit {
@@ -545,14 +546,14 @@ callback interface NodeFilter {
545546
const unsigned long SHOW_ATTRIBUTE = 0x2;
546547
const unsigned long SHOW_TEXT = 0x4;
547548
const unsigned long SHOW_CDATA_SECTION = 0x8;
548-
const unsigned long SHOW_ENTITY_REFERENCE = 0x10; // historical
549-
const unsigned long SHOW_ENTITY = 0x20; // historical
549+
const unsigned long SHOW_ENTITY_REFERENCE = 0x10; // legacy
550+
const unsigned long SHOW_ENTITY = 0x20; // legacy
550551
const unsigned long SHOW_PROCESSING_INSTRUCTION = 0x40;
551552
const unsigned long SHOW_COMMENT = 0x80;
552553
const unsigned long SHOW_DOCUMENT = 0x100;
553554
const unsigned long SHOW_DOCUMENT_TYPE = 0x200;
554555
const unsigned long SHOW_DOCUMENT_FRAGMENT = 0x400;
555-
const unsigned long SHOW_NOTATION = 0x800; // historical
556+
const unsigned long SHOW_NOTATION = 0x800; // legacy
556557

557558
unsigned short acceptNode(Node node);
558559
};

test/fixtures/wpt/interfaces/html.idl

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,8 +1701,7 @@ interface Window : EventTarget {
17011701

17021702
// the user agent
17031703
readonly attribute Navigator navigator;
1704-
[SecureContext] readonly attribute ApplicationCache applicationCache;
1705-
readonly attribute boolean originIsolated;
1704+
readonly attribute boolean originAgentCluster;
17061705

17071706
// user prompts
17081707
undefined alert();
@@ -1801,39 +1800,6 @@ interface BeforeUnloadEvent : Event {
18011800
attribute DOMString returnValue;
18021801
};
18031802

1804-
[SecureContext,
1805-
Exposed=Window]
1806-
interface ApplicationCache : EventTarget {
1807-
1808-
// update status
1809-
const unsigned short UNCACHED = 0;
1810-
const unsigned short IDLE = 1;
1811-
const unsigned short CHECKING = 2;
1812-
const unsigned short DOWNLOADING = 3;
1813-
const unsigned short UPDATEREADY = 4;
1814-
const unsigned short OBSOLETE = 5;
1815-
readonly attribute unsigned short status;
1816-
1817-
// updates
1818-
undefined update();
1819-
undefined abort();
1820-
undefined swapCache();
1821-
1822-
// events
1823-
attribute EventHandler onchecking;
1824-
attribute EventHandler onerror;
1825-
attribute EventHandler onnoupdate;
1826-
attribute EventHandler ondownloading;
1827-
attribute EventHandler onprogress;
1828-
attribute EventHandler onupdateready;
1829-
attribute EventHandler oncached;
1830-
attribute EventHandler onobsolete;
1831-
};
1832-
1833-
interface mixin NavigatorOnLine {
1834-
readonly attribute boolean onLine;
1835-
};
1836-
18371803
[Exposed=(Window,Worker)]
18381804
interface ErrorEvent : Event {
18391805
constructor(DOMString type, optional ErrorEventInit eventInitDict = {});
@@ -2048,6 +2014,10 @@ interface mixin NavigatorLanguage {
20482014
readonly attribute FrozenArray<DOMString> languages;
20492015
};
20502016

2017+
interface mixin NavigatorOnLine {
2018+
readonly attribute boolean onLine;
2019+
};
2020+
20512021
interface mixin NavigatorContentUtils {
20522022
[SecureContext] undefined registerProtocolHandler(DOMString scheme, USVString url);
20532023
[SecureContext] undefined unregisterProtocolHandler(DOMString scheme, USVString url);
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// GENERATED CONTENT - DO NOT EDIT
2+
// Content was automatically extracted by Reffy into webref
3+
// (https://github.com/w3c/webref)
4+
// Source: Web Locks API (https://wicg.github.io/web-locks/)
5+
6+
[SecureContext]
7+
interface mixin NavigatorLocks {
8+
readonly attribute LockManager locks;
9+
};
10+
Navigator includes NavigatorLocks;
11+
WorkerNavigator includes NavigatorLocks;
12+
13+
[SecureContext, Exposed=(Window,Worker)]
14+
interface LockManager {
15+
Promise<any> request(DOMString name,
16+
LockGrantedCallback callback);
17+
Promise<any> request(DOMString name,
18+
LockOptions options,
19+
LockGrantedCallback callback);
20+
21+
Promise<LockManagerSnapshot> query();
22+
};
23+
24+
callback LockGrantedCallback = Promise<any> (Lock? lock);
25+
26+
enum LockMode { "shared", "exclusive" };
27+
28+
dictionary LockOptions {
29+
LockMode mode = "exclusive";
30+
boolean ifAvailable = false;
31+
boolean steal = false;
32+
AbortSignal signal;
33+
};
34+
35+
dictionary LockManagerSnapshot {
36+
sequence<LockInfo> held;
37+
sequence<LockInfo> pending;
38+
};
39+
40+
dictionary LockInfo {
41+
DOMString name;
42+
LockMode mode;
43+
DOMString clientId;
44+
};
45+
46+
[SecureContext, Exposed=(Window,Worker)]
47+
interface Lock {
48+
readonly attribute DOMString name;
49+
readonly attribute LockMode mode;
50+
};

test/fixtures/wpt/resources/testdriver-actions.js

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,12 @@
281281
* pointer source
282282
* @returns {Actions}
283283
*/
284-
pointerDown: function({button=this.ButtonType.LEFT, sourceName=null}={}) {
284+
pointerDown: function({button=this.ButtonType.LEFT, sourceName=null,
285+
width, height, pressure, tangentialPressure,
286+
tiltX, tiltY, twist, altitudeAngle, azimuthAngle}={}) {
285287
let source = this.getSource("pointer", sourceName);
286-
source.pointerDown(this, button);
288+
source.pointerDown(this, button, width, height, pressure, tangentialPressure,
289+
tiltX, tiltY, twist, altitudeAngle, azimuthAngle);
287290
return this;
288291
},
289292

@@ -314,9 +317,13 @@
314317
* @returns {Actions}
315318
*/
316319
pointerMove: function(x, y,
317-
{origin="viewport", duration, sourceName=null}={}) {
320+
{origin="viewport", duration, sourceName=null,
321+
width, height, pressure, tangentialPressure,
322+
tiltX, tiltY, twist, altitudeAngle, azimuthAngle}={}) {
318323
let source = this.getSource("pointer", sourceName);
319-
source.pointerMove(this, x, y, duration, origin);
324+
source.pointerMove(this, x, y, duration, origin, width, height, pressure,
325+
tangentialPressure, tiltX, tiltY, twist, altitudeAngle,
326+
azimuthAngle);
320327
return this;
321328
},
322329

@@ -424,6 +431,38 @@
424431
this.actions = new Map();
425432
}
426433

434+
function setPointerProperties(action, width, height, pressure, tangentialPressure,
435+
tiltX, tiltY, twist, altitudeAngle, azimuthAngle) {
436+
if (width) {
437+
action.width = width;
438+
}
439+
if (height) {
440+
action.height = height;
441+
}
442+
if (pressure) {
443+
action.pressure = pressure;
444+
}
445+
if (tangentialPressure) {
446+
action.tangentialPressure = tangentialPressure;
447+
}
448+
if (tiltX) {
449+
action.tiltX = tiltX;
450+
}
451+
if (tiltY) {
452+
action.tiltY = tiltY;
453+
}
454+
if (twist) {
455+
action.twist = twist;
456+
}
457+
if (altitudeAngle) {
458+
action.altitudeAngle = altitudeAngle;
459+
}
460+
if (azimuthAngle) {
461+
action.azimuthAngle = azimuthAngle;
462+
}
463+
return action;
464+
}
465+
427466
PointerSource.prototype = {
428467
serialize: function(tickCount) {
429468
if (!this.actions.size) {
@@ -441,12 +480,16 @@
441480
return data;
442481
},
443482

444-
pointerDown: function(actions, button) {
483+
pointerDown: function(actions, button, width, height, pressure, tangentialPressure,
484+
tiltX, tiltY, twist, altitudeAngle, azimuthAngle) {
445485
let tick = actions.tickIdx;
446486
if (this.actions.has(tick)) {
447487
tick = actions.addTick().tickIdx;
448488
}
449-
this.actions.set(tick, {type: "pointerDown", button});
489+
let actionProperties = setPointerProperties({type: "pointerDown", button}, width, height,
490+
pressure, tangentialPressure, tiltX, tiltY,
491+
twist, altitudeAngle, azimuthAngle);
492+
this.actions.set(tick, actionProperties);
450493
},
451494

452495
pointerUp: function(actions, button) {
@@ -457,15 +500,20 @@
457500
this.actions.set(tick, {type: "pointerUp", button});
458501
},
459502

460-
pointerMove: function(actions, x, y, duration, origin) {
503+
pointerMove: function(actions, x, y, duration, origin, width, height, pressure,
504+
tangentialPressure, tiltX, tiltY, twist, altitudeAngle, azimuthAngle) {
461505
let tick = actions.tickIdx;
462506
if (this.actions.has(tick)) {
463507
tick = actions.addTick().tickIdx;
464508
}
465-
this.actions.set(tick, {type: "pointerMove", x, y, origin});
509+
let moveAction = {type: "pointerMove", x, y, origin};
466510
if (duration) {
467-
this.actions.get(tick).duration = duration;
511+
moveAction.duration = duration;
468512
}
513+
let actionProperties = setPointerProperties(moveAction, width, height, pressure,
514+
tangentialPressure, tiltX, tiltY, twist,
515+
altitudeAngle, azimuthAngle);
516+
this.actions.set(tick, actionProperties);
469517
},
470518

471519
addPause: function(actions, duration) {

0 commit comments

Comments
 (0)