WebKit Bugzilla
Attachment 362391 Details for
Bug 187039
: Add support for testdriver WPT tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-187039-20190219191311.patch (text/plain), 15.60 KB, created by
darshan
on 2019-02-19 10:13:13 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
darshan
Created:
2019-02-19 10:13:13 PST
Size:
15.60 KB
patch
obsolete
>Subversion Revision: 241648 >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index f6b3b6ac2c7bfe838ec4882eb9da1c556da4288a..87eafb2960e43421c138a2fe8a43c6355d147a5f 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,15 @@ >+2019-02-19 Darshan Kadu <dkadu@igalia.com> >+ >+ Add support for testdriver WPT tests >+ https://bugs.webkit.org/show_bug.cgi?id=187039 >+ >+ Changed the expected behaviour of imported/w3c/web-platform-tests/infrastructure/testdriver >+ tests to failure. >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestExpectations: >+ > 2019-02-16 Zalan Bujtas <zalan@apple.com> > > [LFC][BFC] Add support for block replaced intrinsic width. >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index ce0540cfd917401df3c0d21ea179995c63b0ba92..eae13ee2efbb0e24f31219f4303f2b579cbb0044 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,34 @@ >+2019-02-19 Darshan Kadu <dkadu@igalia.com> >+ >+ Add support for testdriver WPT tests >+ https://bugs.webkit.org/show_bug.cgi?id=187039 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ imported web-platform-tests/resources/testdriver.js from wpt. >+ Overridden the window.test_driver_internal object's (from web-platform-tests/resources/testdriver.js) >+ two functions window.test_driver_internal.click and window.test_driver_internal.send_keys. >+ >+ * web-platform-tests/infrastructure/testdriver/bless-expected.txt: Added. >+ * web-platform-tests/infrastructure/testdriver/click-expected.txt: Added. >+ * web-platform-tests/infrastructure/testdriver/send_keys-expected.txt: Added. >+ * web-platform-tests/resources/testdriver-vendor.js: Added. >+ (window.test_driver_internal.click): >+ (window.test_driver_internal.send_keys): >+ * web-platform-tests/resources/testdriver.js: Added. >+ (getInViewCenterPoint): >+ (getPointerInteractablePaintTree): >+ (inView): >+ (window.test_driver.bless): >+ (window.test_driver.click): >+ (window.test_driver.send_keys): >+ (window.test_driver.freeze): >+ (window.test_driver.action_sequence): >+ (window.test_driver_internal.click): >+ (window.test_driver_internal.send_keys): >+ (window.test_driver_internal.freeze): >+ (window.test_driver_internal.action_sequence): >+ > 2019-02-12 Rob Buis <rbuis@igalia.com> > > Align with Fetch on data: URLs >diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations >index 90e51188c606647f6c958ad537a1a532e1bf004d..02eaa1fe117a21bf134f2d75ae47752615a8ee21 100644 >--- a/LayoutTests/TestExpectations >+++ b/LayoutTests/TestExpectations >@@ -904,7 +904,7 @@ webkit.org/b/187003 imported/w3c/web-platform-tests/infrastructure/reftest/refte > imported/w3c/web-platform-tests/infrastructure/assumptions/ahem.html [ ImageOnlyFailure ] > imported/w3c/web-platform-tests/infrastructure/assumptions/min-font-size.html [ ImageOnlyFailure ] > webkit.org/b/186045 imported/w3c/web-platform-tests/infrastructure/reftest-wait.html [ ImageOnlyFailure ] # reftest-wait not supported yet. >-webkit.org/b/187039 imported/w3c/web-platform-tests/infrastructure/testdriver [ Skip ] # testdriver not supported yet. >+webkit.org/b/187039 imported/w3c/web-platform-tests/infrastructure/testdriver [ Failure ] # testdriver not supported yet. > webkit.org/b/187093 [ Debug ] imported/w3c/web-platform-tests/infrastructure/assumptions/html-elements.html [ Skip ] > imported/w3c/web-platform-tests/infrastructure/server/wpt-server-websocket.sub.html [ Skip ] # non deterministic URL in text dump > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/infrastructure/testdriver/bless-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/infrastructure/testdriver/bless-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..656dfc57d555cc684ed88cb3a5f9dde7193cfc80 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/infrastructure/testdriver/bless-expected.txt >@@ -0,0 +1 @@ >+Pass >diff --git a/LayoutTests/imported/w3c/web-platform-tests/infrastructure/testdriver/click-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/infrastructure/testdriver/click-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..656dfc57d555cc684ed88cb3a5f9dde7193cfc80 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/infrastructure/testdriver/click-expected.txt >@@ -0,0 +1 @@ >+Pass >diff --git a/LayoutTests/imported/w3c/web-platform-tests/infrastructure/testdriver/send_keys-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/infrastructure/testdriver/send_keys-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..656dfc57d555cc684ed88cb3a5f9dde7193cfc80 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/infrastructure/testdriver/send_keys-expected.txt >@@ -0,0 +1 @@ >+Pass >diff --git a/LayoutTests/imported/w3c/web-platform-tests/resources/testdriver-vendor.js b/LayoutTests/imported/w3c/web-platform-tests/resources/testdriver-vendor.js >new file mode 100644 >index 0000000000000000000000000000000000000000..a73f6eebc83d030f0e8ce3cd1312eaece0bc6470 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/resources/testdriver-vendor.js >@@ -0,0 +1,9 @@ >+(function() { >+ window.test_driver_internal.click = function(element, coords) { >+ throw "click event is not implemented"; >+ }; >+ >+ window.test_driver_internal.send_keys = function(element, keys) { >+ throw "send key is not implemented"; >+ }; >+})(); >diff --git a/LayoutTests/imported/w3c/web-platform-tests/resources/testdriver.js b/LayoutTests/imported/w3c/web-platform-tests/resources/testdriver.js >new file mode 100644 >index 0000000000000000000000000000000000000000..7b2ed2fa4ad574c1926b5454394e40c7372ef466 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/resources/testdriver.js >@@ -0,0 +1,243 @@ >+(function() { >+ "use strict"; >+ var idCounter = 0; >+ >+ function getInViewCenterPoint(rect) { >+ var left = Math.max(0, rect.left); >+ var right = Math.min(window.innerWidth, rect.right); >+ var top = Math.max(0, rect.top); >+ var bottom = Math.min(window.innerHeight, rect.bottom); >+ >+ var x = 0.5 * (left + right); >+ var y = 0.5 * (top + bottom); >+ >+ return [x, y]; >+ } >+ >+ function getPointerInteractablePaintTree(element) { >+ if (!window.document.contains(element)) { >+ return []; >+ } >+ >+ var rectangles = element.getClientRects(); >+ >+ if (rectangles.length === 0) { >+ return []; >+ } >+ >+ var centerPoint = getInViewCenterPoint(rectangles[0]); >+ >+ if ("elementsFromPoint" in document) { >+ return document.elementsFromPoint(centerPoint[0], centerPoint[1]); >+ } else if ("msElementsFromPoint" in document) { >+ var rv = document.msElementsFromPoint(centerPoint[0], centerPoint[1]); >+ return Array.prototype.slice.call(rv ? rv : []); >+ } else { >+ throw new Error("document.elementsFromPoint unsupported"); >+ } >+ } >+ >+ function inView(element) { >+ var pointerInteractablePaintTree = getPointerInteractablePaintTree(element); >+ return pointerInteractablePaintTree.indexOf(element) !== -1; >+ } >+ >+ >+ /** >+ * @namespace >+ */ >+ window.test_driver = { >+ /** >+ * Trigger user interaction in order to grant additional privileges to >+ * a provided function. >+ * >+ * https://html.spec.whatwg.org/#triggered-by-user-activation >+ * >+ * @param {String} intent - a description of the action which much be >+ * triggered by user interaction >+ * @param {Function} action - code requiring escalated privileges >+ * >+ * @returns {Promise} fulfilled following user interaction and >+ * execution of the provided `action` function; >+ * rejected if interaction fails or the provided >+ * function throws an error >+ */ >+ bless: function(intent, action) { >+ var button = document.createElement("button"); >+ button.innerHTML = "This test requires user interaction.<br />" + >+ "Please click here to allow " + intent + "."; >+ button.id = "wpt-test-driver-bless-" + (idCounter += 1); >+ const elem = document.body || document.documentElement; >+ elem.appendChild(button); >+ >+ return new Promise(function(resolve, reject) { >+ button.addEventListener("click", resolve); >+ >+ test_driver.click(button).catch(reject); >+ }).then(function() { >+ button.remove(); >+ >+ if (typeof action === "function") { >+ return action(); >+ } >+ }); >+ }, >+ >+ /** >+ * Triggers a user-initiated click >+ * >+ * This matches the behaviour of the {@link >+ * https://w3c.github.io/webdriver/webdriver-spec.html#element-click|WebDriver >+ * Element Click command}. >+ * >+ * @param {Element} element - element to be clicked >+ * @returns {Promise} fulfilled after click occurs, or rejected in >+ * the cases the WebDriver command errors >+ */ >+ click: function(element) { >+ if (window.top !== window) { >+ return Promise.reject(new Error("can only click in top-level window")); >+ } >+ >+ if (!window.document.contains(element)) { >+ return Promise.reject(new Error("element in different document or shadow tree")); >+ } >+ >+ if (!inView(element)) { >+ element.scrollIntoView({behavior: "instant", >+ block: "end", >+ inline: "nearest"}); >+ } >+ >+ var pointerInteractablePaintTree = getPointerInteractablePaintTree(element); >+ if (pointerInteractablePaintTree.length === 0 || >+ !element.contains(pointerInteractablePaintTree[0])) { >+ return Promise.reject(new Error("element click intercepted error")); >+ } >+ >+ var rect = element.getClientRects()[0]; >+ var centerPoint = getInViewCenterPoint(rect); >+ return window.test_driver_internal.click(element, >+ {x: centerPoint[0], >+ y: centerPoint[1]}); >+ }, >+ >+ /** >+ * Send keys to an element >+ * >+ * This matches the behaviour of the {@link >+ * https://w3c.github.io/webdriver/webdriver-spec.html#element-send-keys|WebDriver >+ * Send Keys command}. >+ * >+ * @param {Element} element - element to send keys to >+ * @param {String} keys - keys to send to the element >+ * @returns {Promise} fulfilled after keys are sent, or rejected in >+ * the cases the WebDriver command errors >+ */ >+ send_keys: function(element, keys) { >+ if (window.top !== window) { >+ return Promise.reject(new Error("can only send keys in top-level window")); >+ } >+ >+ if (!window.document.contains(element)) { >+ return Promise.reject(new Error("element in different document or shadow tree")); >+ } >+ >+ if (!inView(element)) { >+ element.scrollIntoView({behavior: "instant", >+ block: "end", >+ inline: "nearest"}); >+ } >+ >+ var pointerInteractablePaintTree = getPointerInteractablePaintTree(element); >+ if (pointerInteractablePaintTree.length === 0 || >+ !element.contains(pointerInteractablePaintTree[0])) { >+ return Promise.reject(new Error("element send_keys intercepted error")); >+ } >+ >+ return window.test_driver_internal.send_keys(element, keys); >+ }, >+ >+ /** >+ * Freeze the current page >+ * >+ * The freeze function transitions the page from the HIDDEN state to >+ * the FROZEN state as described in {@link >+ * https://github.com/WICG/page-lifecycle/blob/master/README.md|Lifecycle API >+ * for Web Pages} >+ * >+ * @returns {Promise} fulfilled after the freeze request is sent, or rejected >+ * in case the WebDriver command errors >+ */ >+ freeze: function() { >+ return window.test_driver_internal.freeze(); >+ }, >+ >+ /** >+ * Send a sequence of actions >+ * >+ * This function sends a sequence of actions to the top level window >+ * to perform. It is modeled after the behaviour of {@link >+ * https://w3c.github.io/webdriver/#actions|WebDriver Actions Command} >+ * >+ * @param {Array} actions - an array of actions. The format is the same as the actions >+ property of the WebDriver command {@link >+ https://w3c.github.io/webdriver/#perform-actions|Perform >+ Actions} command. Each element is an object representing an >+ input source and each input source itself has an actions >+ property detailing the behaviour of that source at each timestep >+ (or tick). Authors are not expected to construct the actions >+ sequence by hand, but to use the builder api provided in >+ testdriver-actions.js >+ * @returns {Promise} fufiled after the actions are performed, or rejected in >+ * the cases the WebDriver command errors >+ */ >+ action_sequence: function(actions) { >+ return window.test_driver_internal.action_sequence(actions); >+ } >+ }; >+ >+ window.test_driver_internal = { >+ /** >+ * Triggers a user-initiated click >+ * >+ * @param {Element} element - element to be clicked >+ * @param {{x: number, y: number} coords - viewport coordinates to click at >+ * @returns {Promise} fulfilled after click occurs or rejected if click fails >+ */ >+ click: function(element, coords) { >+ return Promise.reject(new Error("unimplemented")); >+ }, >+ >+ /** >+ * Triggers a user-initiated click >+ * >+ * @param {Element} element - element to be clicked >+ * @param {String} keys - keys to send to the element >+ * @returns {Promise} fulfilled after keys are sent or rejected if click fails >+ */ >+ send_keys: function(element, keys) { >+ return Promise.reject(new Error("unimplemented")); >+ }, >+ >+ /** >+ * Freeze the current page >+ * >+ * @returns {Promise} fulfilled after freeze request is sent, otherwise >+ * it gets rejected >+ */ >+ freeze: function() { >+ return Promise.reject(new Error("unimplemented")); >+ }, >+ >+ /** >+ * Send a sequence of pointer actions >+ * >+ * @returns {Promise} fufilled after actions are sent, rejected if any actions >+ * fail >+ */ >+ action_sequence: function(actions) { >+ return Promise.reject(new Error("unimplemented")); >+ } >+ }; >+})(); >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
dkadu
:
review?
ews-watchlist
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 187039
:
351375
|
351410
| 362391 |
362401
|
362412