Skip to content

Commit

Permalink
test: update wpt url and resource
Browse files Browse the repository at this point in the history
Refs: web-platform-tests/wpt#26317

PR-URL: #36032
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
watilde committed Nov 19, 2020
1 parent 73ea670 commit d6d4721
Show file tree
Hide file tree
Showing 12 changed files with 437 additions and 222 deletions.
6 changes: 3 additions & 3 deletions test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ 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/54c6d64be0/url
- resources: https://github.com/web-platform-tests/wpt/tree/1d14e821b9/resources
- interfaces: https://github.com/web-platform-tests/wpt/tree/15e47f779c/interfaces
- 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
- 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
Expand Down
26 changes: 21 additions & 5 deletions test/fixtures/wpt/interfaces/html.idl
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ interface HTMLIFrameElement : HTMLElement {
[SameObject, PutForwards=value] readonly attribute DOMTokenList sandbox;
[CEReactions] attribute DOMString allow;
[CEReactions] attribute boolean allowFullscreen;
[CEReactions] attribute boolean allowPaymentRequest;
[CEReactions] attribute DOMString width;
[CEReactions] attribute DOMString height;
[CEReactions] attribute DOMString referrerPolicy;
Expand Down Expand Up @@ -1564,16 +1563,18 @@ dictionary ElementDefinitionOptions {

[Exposed=Window]
interface ElementInternals {
// Form-associated custom elements
// Shadow root access
readonly attribute ShadowRoot? shadowRoot;

// Form-associated custom elements
undefined setFormValue((File or USVString or FormData)? value,
optional (File or USVString or FormData)? state);
optional (File or USVString or FormData)? state);

readonly attribute HTMLFormElement? form;

undefined setValidity(optional ValidityStateFlags flags = {},
optional DOMString message,
optional HTMLElement anchor);
optional DOMString message,
optional HTMLElement anchor);
readonly attribute boolean willValidate;
readonly attribute ValidityState validity;
readonly attribute DOMString validationMessage;
Expand All @@ -1583,6 +1584,9 @@ interface ElementInternals {
readonly attribute NodeList labels;
};

// Accessibility semantics
ElementInternals includes ARIAMixin;

dictionary ValidityStateFlags {
boolean valueMissing = false;
boolean typeMismatch = false;
Expand Down Expand Up @@ -2353,6 +2357,18 @@ interface WorkerLocation {
readonly attribute USVString hash;
};

[Exposed=Worklet, SecureContext]
interface WorkletGlobalScope {};

[Exposed=Window, SecureContext]
interface Worklet {
[NewObject] Promise<undefined> addModule(USVString moduleURL, optional WorkletOptions options = {});
};

dictionary WorkletOptions {
RequestCredentials credentials = "same-origin";
};

[Exposed=Window]
interface Storage {
readonly attribute unsigned long length;
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/wpt/resources/test-only-api.m.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* Whether the browser is Chromium-based with MojoJS enabled */
export const isChromiumBased = 'MojoInterfaceInterceptor' in self;

/* Whether the browser is WebKit-based with internal test-only API enabled */
export const isWebKitBased = !isChromiumBased && 'internals' in self;
2 changes: 2 additions & 0 deletions test/fixtures/wpt/resources/test-only-api.m.js.headers
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Content-Type: text/javascript; charset=utf-8
Cache-Control: max-age=3600
109 changes: 105 additions & 4 deletions test/fixtures/wpt/resources/testdriver-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
function Actions(defaultTickDuration=16) {
this.sourceTypes = new Map([["key", KeySource],
["pointer", PointerSource],
["wheel", WheelSource],
["none", GeneralSource]]);
this.sources = new Map();
this.sourceOrder = [];
Expand All @@ -22,6 +23,7 @@
this.createSource("none");
this.tickIdx = 0;
this.defaultTickDuration = defaultTickDuration;
this.context = null;
}

Actions.prototype = {
Expand Down Expand Up @@ -65,15 +67,25 @@
} catch(e) {
return Promise.reject(e);
}
return test_driver.action_sequence(actions);
return test_driver.action_sequence(actions, this.context);
},

/**
* Set the context for the actions
*
* @param {WindowProxy} context - Context in which to run the action sequence
*/
setContext: function(context) {
this.context = context;
return this;
},

/**
* Get the action source with a particular source type and name.
* If no name is passed, a new source with the given type is
* created.
*
* @param {String} type - Source type ('none', 'key', or 'pointer')
* @param {String} type - Source type ('none', 'key', 'pointer', or 'wheel')
* @param {String?} name - Name of the source
* @returns {Source} Source object for that source.
*/
Expand Down Expand Up @@ -154,6 +166,32 @@
return this;
},

/**
* Add a new wheel input source with the given name
*
* @param {String} type - Name of the wheel source
* @param {Bool} set - Set source as the default wheel source
* @returns {Actions}
*/
addWheel: function(name, set=true) {
this.createSource("wheel", name);
if (set) {
this.setWheel(name);
}
return this;
},

/**
* Set the current default wheel source
*
* @param {String} name - Name of the wheel source
* @returns {Actions}
*/
setWheel: function(name) {
this.setSource("wheel", name);
return this;
},

createSource: function(type, name, parameters={}) {
if (!this.sources.has(type)) {
throw new Error(`${type} is not a valid action type`);
Expand Down Expand Up @@ -196,8 +234,9 @@
*
* @param {Number?} duration - Minimum length of the tick in ms.
* @param {String} sourceType - source type
* @param {String?} sourceName - Named key or pointer source to use or null for the default
* key or pointer source
* @param {String?} sourceName - Named key, pointer or wheel source to use
* or null for the default key, pointer or
* wheel source
* @returns {Actions}
*/
pause: function(duration=0, sourceType="none", {sourceName=null}={}) {
Expand Down Expand Up @@ -280,6 +319,27 @@
source.pointerMove(this, x, y, duration, origin);
return this;
},

/**
* Create a scroll event for the current default wheel source
*
* @param {Number} x - mouse cursor x coordinate
* @param {Number} y - mouse cursor y coordinate
* @param {Number} deltaX - scroll delta value along the x-axis in pixels
* @param {Number} deltaY - scroll delta value along the y-axis in pixels
* @param {String|Element} origin - Origin of the coordinate system.
* Either "viewport" or an Element
* @param {Number?} duration - Time in ms for the scroll
* @param {String?} sourceName - Named wheel source to use or null for the
* default wheel source
* @returns {Actions}
*/
scroll: function(x, y, deltaX, deltaY,
{origin="viewport", duration, sourceName=null}={}) {
let source = this.getSource("wheel", sourceName);
source.scroll(this, x, y, deltaX, deltaY, duration, origin);
return this;
},
};

function GeneralSource() {
Expand Down Expand Up @@ -417,5 +477,46 @@
},
};

function WheelSource() {
this.actions = new Map();
}

WheelSource.prototype = {
serialize: function(tickCount) {
if (!this.actions.size) {
return undefined;
}
let actions = [];
let data = {"type": "wheel", "actions": actions};
for (let i=0; i<tickCount; i++) {
if (this.actions.has(i)) {
actions.push(this.actions.get(i));
} else {
actions.push({"type": "pause"});
}
}
return data;
},

scroll: function(actions, x, y, deltaX, deltaY, duration, origin) {
let tick = actions.tickIdx;
if (this.actions.has(tick)) {
tick = actions.addTick().tickIdx;
}
this.actions.set(tick, {type: "scroll", x, y, deltaX, deltaY, origin});
if (duration) {
this.actions.get(tick).duration = duration;
}
},

addPause: function(actions, duration) {
let tick = actions.tickIdx;
if (this.actions.has(tick)) {
tick = actions.addTick().tickIdx;
}
this.actions.set(tick, {type: "pause", duration: duration});
},
};

test_driver.Actions = Actions;
})();
Loading

0 comments on commit d6d4721

Please sign in to comment.