Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test: add web-locks WPT
  • Loading branch information
targos committed Dec 14, 2020
commit 87feb3a4cffe1e9f2723ce6bff94807504fc7248
1 change: 1 addition & 0 deletions lib/internal/worker/locks.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ ObjectDefineProperties(LockManager.prototype, {
});

module.exports = {
Lock,
LockManager,
locks: ObjectCreate(LockManager.prototype)
Comment thread
aduh95 marked this conversation as resolved.
Outdated
};
5 changes: 3 additions & 2 deletions test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ Last update:
- console: https://github.com/web-platform-tests/wpt/tree/3b1f72e99a/console
- encoding: https://github.com/web-platform-tests/wpt/tree/1821fb5f77/encoding
- url: https://github.com/web-platform-tests/wpt/tree/09d8830be1/url
- resources: https://github.com/web-platform-tests/wpt/tree/001e50de41/resources
- interfaces: https://github.com/web-platform-tests/wpt/tree/8719553b2d/interfaces
- resources: https://github.com/web-platform-tests/wpt/tree/351a99782b/resources
- interfaces: https://github.com/web-platform-tests/wpt/tree/c37c28b8a8/interfaces
- html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/2c5c3c4c27/html/webappapis/microtask-queuing
- html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/264f12bc7b/html/webappapis/timers
- hr-time: https://github.com/web-platform-tests/wpt/tree/a5d1774ecf/hr-time
- common: https://github.com/web-platform-tests/wpt/tree/4dacb6e2ff/common
- dom/abort: https://github.com/web-platform-tests/wpt/tree/7caa3de747/dom/abort
- web-locks: https://github.com/web-platform-tests/wpt/tree/e2ddf48b78/web-locks

[Web Platform Tests]: https://github.com/web-platform-tests/wpt
[`git node wpt`]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md#git-node-wpt
39 changes: 20 additions & 19 deletions test/fixtures/wpt/interfaces/dom.idl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Event {

readonly attribute DOMString type;
readonly attribute EventTarget? target;
readonly attribute EventTarget? srcElement; // historical
readonly attribute EventTarget? srcElement; // legacy
readonly attribute EventTarget? currentTarget;
sequence<EventTarget> composedPath();

Expand All @@ -20,20 +20,20 @@ interface Event {
readonly attribute unsigned short eventPhase;

undefined stopPropagation();
attribute boolean cancelBubble; // historical alias of .stopPropagation
attribute boolean cancelBubble; // legacy alias of .stopPropagation()
undefined stopImmediatePropagation();

readonly attribute boolean bubbles;
readonly attribute boolean cancelable;
attribute boolean returnValue; // historical
attribute boolean returnValue; // legacy
undefined preventDefault();
readonly attribute boolean defaultPrevented;
readonly attribute boolean composed;

[LegacyUnforgeable] readonly attribute boolean isTrusted;
readonly attribute DOMHighResTimeStamp timeStamp;

undefined initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); // historical
undefined initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); // legacy
};

dictionary EventInit {
Expand All @@ -43,7 +43,7 @@ dictionary EventInit {
};

partial interface Window {
[Replaceable] readonly attribute any event; // historical
[Replaceable] readonly attribute any event; // legacy
};

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

readonly attribute any detail;

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

dictionary CustomEventInit : EventInit {
Expand All @@ -79,6 +79,7 @@ dictionary EventListenerOptions {
dictionary AddEventListenerOptions : EventListenerOptions {
boolean passive = false;
boolean once = false;
AbortSignal signal;
};

[Exposed=(Window,Worker)]
Expand Down Expand Up @@ -201,14 +202,14 @@ interface Node : EventTarget {
const unsigned short ATTRIBUTE_NODE = 2;
const unsigned short TEXT_NODE = 3;
const unsigned short CDATA_SECTION_NODE = 4;
const unsigned short ENTITY_REFERENCE_NODE = 5; // historical
const unsigned short ENTITY_NODE = 6; // historical
const unsigned short ENTITY_REFERENCE_NODE = 5; // legacy
const unsigned short ENTITY_NODE = 6; // legacy
const unsigned short PROCESSING_INSTRUCTION_NODE = 7;
const unsigned short COMMENT_NODE = 8;
const unsigned short DOCUMENT_NODE = 9;
const unsigned short DOCUMENT_TYPE_NODE = 10;
const unsigned short DOCUMENT_FRAGMENT_NODE = 11;
const unsigned short NOTATION_NODE = 12; // historical
const unsigned short NOTATION_NODE = 12; // legacy
readonly attribute unsigned short nodeType;
readonly attribute DOMString nodeName;

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

[CEReactions, NewObject] Node cloneNode(optional boolean deep = false);
boolean isEqualNode(Node? otherNode);
boolean isSameNode(Node? otherNode); // historical alias of ===
boolean isSameNode(Node? otherNode); // legacy alias of ===

const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01;
const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02;
Expand Down Expand Up @@ -266,8 +267,8 @@ interface Document : Node {
readonly attribute USVString documentURI;
readonly attribute DOMString compatMode;
readonly attribute DOMString characterSet;
readonly attribute DOMString charset; // historical alias of .characterSet
readonly attribute DOMString inputEncoding; // historical alias of .characterSet
readonly attribute DOMString charset; // legacy alias of .characterSet
readonly attribute DOMString inputEncoding; // legacy alias of .characterSet
readonly attribute DOMString contentType;

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

[NewObject] Event createEvent(DOMString interface); // historical
[NewObject] Event createEvent(DOMString interface); // legacy

[NewObject] Range createRange();

Expand Down Expand Up @@ -372,14 +373,14 @@ interface Element : Node {

Element? closest(DOMString selectors);
boolean matches(DOMString selectors);
boolean webkitMatchesSelector(DOMString selectors); // historical alias of .matches
boolean webkitMatchesSelector(DOMString selectors); // legacy alias of .matches

HTMLCollection getElementsByTagName(DOMString qualifiedName);
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
HTMLCollection getElementsByClassName(DOMString classNames);

[CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // historical
undefined insertAdjacentText(DOMString where, DOMString data); // historical
[CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // legacy
undefined insertAdjacentText(DOMString where, DOMString data); // legacy
};

dictionary ShadowRootInit {
Expand Down Expand Up @@ -545,14 +546,14 @@ callback interface NodeFilter {
const unsigned long SHOW_ATTRIBUTE = 0x2;
const unsigned long SHOW_TEXT = 0x4;
const unsigned long SHOW_CDATA_SECTION = 0x8;
const unsigned long SHOW_ENTITY_REFERENCE = 0x10; // historical
const unsigned long SHOW_ENTITY = 0x20; // historical
const unsigned long SHOW_ENTITY_REFERENCE = 0x10; // legacy
const unsigned long SHOW_ENTITY = 0x20; // legacy
const unsigned long SHOW_PROCESSING_INSTRUCTION = 0x40;
const unsigned long SHOW_COMMENT = 0x80;
const unsigned long SHOW_DOCUMENT = 0x100;
const unsigned long SHOW_DOCUMENT_TYPE = 0x200;
const unsigned long SHOW_DOCUMENT_FRAGMENT = 0x400;
const unsigned long SHOW_NOTATION = 0x800; // historical
const unsigned long SHOW_NOTATION = 0x800; // legacy

unsigned short acceptNode(Node node);
};
Expand Down
40 changes: 5 additions & 35 deletions test/fixtures/wpt/interfaces/html.idl
Original file line number Diff line number Diff line change
Expand Up @@ -1701,8 +1701,7 @@ interface Window : EventTarget {

// the user agent
readonly attribute Navigator navigator;
[SecureContext] readonly attribute ApplicationCache applicationCache;
readonly attribute boolean originIsolated;
readonly attribute boolean originAgentCluster;

// user prompts
undefined alert();
Expand Down Expand Up @@ -1801,39 +1800,6 @@ interface BeforeUnloadEvent : Event {
attribute DOMString returnValue;
};

[SecureContext,
Exposed=Window]
interface ApplicationCache : EventTarget {

// update status
const unsigned short UNCACHED = 0;
const unsigned short IDLE = 1;
const unsigned short CHECKING = 2;
const unsigned short DOWNLOADING = 3;
const unsigned short UPDATEREADY = 4;
const unsigned short OBSOLETE = 5;
readonly attribute unsigned short status;

// updates
undefined update();
undefined abort();
undefined swapCache();

// events
attribute EventHandler onchecking;
attribute EventHandler onerror;
attribute EventHandler onnoupdate;
attribute EventHandler ondownloading;
attribute EventHandler onprogress;
attribute EventHandler onupdateready;
attribute EventHandler oncached;
attribute EventHandler onobsolete;
};

interface mixin NavigatorOnLine {
readonly attribute boolean onLine;
};

[Exposed=(Window,Worker)]
interface ErrorEvent : Event {
constructor(DOMString type, optional ErrorEventInit eventInitDict = {});
Expand Down Expand Up @@ -2048,6 +2014,10 @@ interface mixin NavigatorLanguage {
readonly attribute FrozenArray<DOMString> languages;
};

interface mixin NavigatorOnLine {
readonly attribute boolean onLine;
};

interface mixin NavigatorContentUtils {
[SecureContext] undefined registerProtocolHandler(DOMString scheme, USVString url);
[SecureContext] undefined unregisterProtocolHandler(DOMString scheme, USVString url);
Expand Down
50 changes: 50 additions & 0 deletions test/fixtures/wpt/interfaces/web-locks.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// GENERATED CONTENT - DO NOT EDIT
// Content was automatically extracted by Reffy into webref
// (https://github.com/w3c/webref)
// Source: Web Locks API (https://wicg.github.io/web-locks/)

[SecureContext]
interface mixin NavigatorLocks {
readonly attribute LockManager locks;
};
Navigator includes NavigatorLocks;
WorkerNavigator includes NavigatorLocks;

[SecureContext, Exposed=(Window,Worker)]
interface LockManager {
Promise<any> request(DOMString name,
LockGrantedCallback callback);
Promise<any> request(DOMString name,
LockOptions options,
LockGrantedCallback callback);

Promise<LockManagerSnapshot> query();
};

callback LockGrantedCallback = Promise<any> (Lock? lock);

enum LockMode { "shared", "exclusive" };

dictionary LockOptions {
LockMode mode = "exclusive";
boolean ifAvailable = false;
boolean steal = false;
AbortSignal signal;
};

dictionary LockManagerSnapshot {
sequence<LockInfo> held;
sequence<LockInfo> pending;
};

dictionary LockInfo {
DOMString name;
LockMode mode;
DOMString clientId;
};

[SecureContext, Exposed=(Window,Worker)]
interface Lock {
readonly attribute DOMString name;
readonly attribute LockMode mode;
};
66 changes: 57 additions & 9 deletions test/fixtures/wpt/resources/testdriver-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,12 @@
* pointer source
* @returns {Actions}
*/
pointerDown: function({button=this.ButtonType.LEFT, sourceName=null}={}) {
pointerDown: function({button=this.ButtonType.LEFT, sourceName=null,
width, height, pressure, tangentialPressure,
tiltX, tiltY, twist, altitudeAngle, azimuthAngle}={}) {
let source = this.getSource("pointer", sourceName);
source.pointerDown(this, button);
source.pointerDown(this, button, width, height, pressure, tangentialPressure,
tiltX, tiltY, twist, altitudeAngle, azimuthAngle);
return this;
},

Expand Down Expand Up @@ -314,9 +317,13 @@
* @returns {Actions}
*/
pointerMove: function(x, y,
{origin="viewport", duration, sourceName=null}={}) {
{origin="viewport", duration, sourceName=null,
width, height, pressure, tangentialPressure,
tiltX, tiltY, twist, altitudeAngle, azimuthAngle}={}) {
let source = this.getSource("pointer", sourceName);
source.pointerMove(this, x, y, duration, origin);
source.pointerMove(this, x, y, duration, origin, width, height, pressure,
tangentialPressure, tiltX, tiltY, twist, altitudeAngle,
azimuthAngle);
return this;
},

Expand Down Expand Up @@ -424,6 +431,38 @@
this.actions = new Map();
}

function setPointerProperties(action, width, height, pressure, tangentialPressure,
tiltX, tiltY, twist, altitudeAngle, azimuthAngle) {
if (width) {
action.width = width;
}
if (height) {
action.height = height;
}
if (pressure) {
action.pressure = pressure;
}
if (tangentialPressure) {
action.tangentialPressure = tangentialPressure;
}
if (tiltX) {
action.tiltX = tiltX;
}
if (tiltY) {
action.tiltY = tiltY;
}
if (twist) {
action.twist = twist;
}
if (altitudeAngle) {
action.altitudeAngle = altitudeAngle;
}
if (azimuthAngle) {
action.azimuthAngle = azimuthAngle;
}
return action;
}

PointerSource.prototype = {
serialize: function(tickCount) {
if (!this.actions.size) {
Expand All @@ -441,12 +480,16 @@
return data;
},

pointerDown: function(actions, button) {
pointerDown: function(actions, button, width, height, pressure, tangentialPressure,
tiltX, tiltY, twist, altitudeAngle, azimuthAngle) {
let tick = actions.tickIdx;
if (this.actions.has(tick)) {
tick = actions.addTick().tickIdx;
}
this.actions.set(tick, {type: "pointerDown", button});
let actionProperties = setPointerProperties({type: "pointerDown", button}, width, height,
pressure, tangentialPressure, tiltX, tiltY,
twist, altitudeAngle, azimuthAngle);
this.actions.set(tick, actionProperties);
},

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

pointerMove: function(actions, x, y, duration, origin) {
pointerMove: function(actions, x, y, duration, origin, width, height, pressure,
tangentialPressure, tiltX, tiltY, twist, altitudeAngle, azimuthAngle) {
let tick = actions.tickIdx;
if (this.actions.has(tick)) {
tick = actions.addTick().tickIdx;
}
this.actions.set(tick, {type: "pointerMove", x, y, origin});
let moveAction = {type: "pointerMove", x, y, origin};
if (duration) {
this.actions.get(tick).duration = duration;
moveAction.duration = duration;
}
let actionProperties = setPointerProperties(moveAction, width, height, pressure,
tangentialPressure, tiltX, tiltY, twist,
altitudeAngle, azimuthAngle);
this.actions.set(tick, actionProperties);
},

addPause: function(actions, duration) {
Expand Down
Loading