Commit 599544ee authored by Chromium WPT Sync's avatar Chromium WPT Sync Committed by Commit Bot

Import wpt@0f57631975fa3c48a1149c21bd0485e0aa9e6e0d

Using wpt-import in Chromium e3a54217.

Note to sheriffs: This CL imports external tests and adds
expectations for those tests; if this CL is large and causes
a few new failures, please fix the failures by adding new
lines to TestExpectations rather than reverting. See:
https://chromium.googlesource.com/chromium/src/+/master/docs/testing/web_platform_tests.md

Directory owners for changes in this CL:
mkwst@chromium.org:
  external/wpt/cookies

NOAUTOREVERT=true
TBR=robertma@google.com

No-Export: true
Cq-Include-Trybots: luci.chromium.try:linux-wpt-identity-fyi-rel,linux-wpt-payments-fyi-rel
Change-Id: Ib10d71ee9c09633879a75d3328b509d679800a7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485761Reviewed-by: default avatarWPT Autoroller <wpt-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Commit-Queue: WPT Autoroller <wpt-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Cr-Commit-Position: refs/heads/master@{#818780}
parent 68c71019
......@@ -10,14 +10,9 @@
<script src="/resources/testharnessreport.js"></script>
<script src="resources/cookie-http-state-template.js"></script>
</head>
<body style="background:#EEE">
<h3>Log</h3>
<div id="log" style="height:50px; overflow-y:scroll; background: #FFF">
</div>
<h3>IFrames</h3>
<div id="iframes" style="height:170px; overflow-y:scroll; background: #FFF">
</div>
<h3>Test Results</h3>
<body>
<div id="log"></div>
<div id="iframes"></div>
<script>
setup({ explicit_timeout: true });
......
......@@ -9,14 +9,9 @@
<script src="/resources/testharnessreport.js"></script>
<script src="resources/cookie-http-state-template.js"></script>
</head>
<body style="background:#EEE">
<h3>Log</h3>
<div id="log" style="height:50px; overflow-y:scroll; background: #FFF">
</div>
<h3>IFrames</h3>
<div id="iframes" style="height:170px; overflow-y:scroll; background: #FFF">
</div>
<h3>Test Results</h3>
<body>
<div id="log"></div>
<div id="iframes"></div>
<script>
setup({ explicit_timeout: true });
......
......@@ -9,14 +9,9 @@
<script src="/resources/testharnessreport.js"></script>
<script src="resources/cookie-http-state-template.js"></script>
</head>
<body style="background:#EEE">
<h3>Log</h3>
<div id="log" style="height:50px; overflow-y:scroll; background: #FFF">
</div>
<h3>IFrames</h3>
<div id="iframes" style="height:170px; overflow-y:scroll; background: #FFF">
</div>
<h3>Test Results</h3>
<body>
<div id="log"></div>
<div id="iframes"></div>
<script>
setup({ explicit_timeout: true });
......
......@@ -9,14 +9,9 @@
<script src="/resources/testharnessreport.js"></script>
<script src="resources/cookie-http-state-template.js"></script>
</head>
<body style="background:#EEE">
<h3>Log</h3>
<div id="log" style="height:50px; overflow-y:scroll; background: #FFF">
</div>
<h3>IFrames</h3>
<div id="iframes" style="height:170px; overflow-y:scroll; background: #FFF">
</div>
<h3>Test Results</h3>
<body>
<div id="log"></div>
<div id="iframes"></div>
<script>
setup({ explicit_timeout: true });
......
......@@ -10,14 +10,9 @@
<script src="/resources/testharnessreport.js"></script>
<script src="resources/cookie-http-state-template.js"></script>
</head>
<body style="background:#EEE">
<h3>Log</h3>
<div id="log" style="height:50px; overflow-y:scroll; background: #FFF">
</div>
<h3>IFrames</h3>
<div id="iframes" style="height:170px; overflow-y:scroll; background: #FFF">
</div>
<h3>Test Results</h3>
<body>
<div id="log"></div>
<div id="iframes"></div>
<script>
setup({ explicit_timeout: true });
......
......@@ -10,14 +10,9 @@
<script src="/resources/testharnessreport.js"></script>
<script src="resources/cookie-http-state-template.js"></script>
</head>
<body style="background:#EEE">
<h3>Log</h3>
<div id="log" style="height:50px; overflow-y:scroll; background: #FFF">
</div>
<h3>IFrames</h3>
<div id="iframes" style="height:170px; overflow-y:scroll; background: #FFF">
</div>
<h3>Test Results</h3>
<body>
<div id="log"></div>
<div id="iframes"></div>
<script>
setup({ explicit_timeout: true });
......
......@@ -9,14 +9,9 @@
<script src="/resources/testharnessreport.js"></script>
<script src="resources/cookie-http-state-template.js"></script>
</head>
<body style="background:#EEE">
<h3>Log</h3>
<div id="log" style="height:50px; overflow-y:scroll; background: #FFF">
</div>
<h3>IFrames</h3>
<div id="iframes" style="height:170px; overflow-y:scroll; background: #FFF">
</div>
<h3>Test Results</h3>
<body>
<div id="log"></div>
<div id="iframes"></div>
<script>
setup({ explicit_timeout: true });
......
......@@ -10,14 +10,9 @@
<script src="/resources/testharnessreport.js"></script>
<script src="resources/cookie-http-state-template.js"></script>
</head>
<body style="background:#EEE">
<h3>Log</h3>
<div id="log" style="height:50px; overflow-y:scroll; background: #FFF">
</div>
<h3>IFrames</h3>
<div id="iframes" style="height:170px; overflow-y:scroll; background: #FFF">
</div>
<h3>Test Results</h3>
<body>
<div id="log"></div>
<div id="iframes"></div>
<script>
setup({ explicit_timeout: true });
......
......@@ -9,14 +9,9 @@
<script src="/resources/testharnessreport.js"></script>
<script src="resources/cookie-http-state-template.js"></script>
</head>
<body style="background:#EEE">
<h3>Log</h3>
<div id="log" style="height:50px; overflow-y:scroll; background: #FFF">
</div>
<h3>IFrames</h3>
<div id="iframes" style="height:170px; overflow-y:scroll; background: #FFF">
</div>
<h3>Test Results</h3>
<body>
<div id="log"></div>
<div id="iframes"></div>
<script>
setup({ explicit_timeout: true });
......
......@@ -10,14 +10,9 @@
<script src="/resources/testharnessreport.js"></script>
<script src="resources/cookie-http-state-template.js"></script>
</head>
<body style="background:#EEE">
<h3>Log</h3>
<div id="log" style="height:50px; overflow-y:scroll; background: #FFF">
</div>
<h3>IFrames</h3>
<div id="iframes" style="height:170px; overflow-y:scroll; background: #FFF">
</div>
<h3>Test Results</h3>
<body>
<div id="log"></div>
<div id="iframes"></div>
<script>
setup({ explicit_timeout: true });
......
......@@ -9,7 +9,7 @@
<script src="/resources/testharnessreport.js"></script>
<script src="cookie-http-state-template.js"></script>
</head>
<body style="background:#EEE">
<body>
<h1>Cookie Tests</h1>
This page is a debug page for cookie tests. To run a test in isolation,
append "?debug=" and the test id to this URL. E.g. to debug "value0001", use
......@@ -51,17 +51,10 @@
Below, all tests are running. The Log contains messages (e.g. when cookies
are left over) and the IFrames list preserves all requested files and shows
which cookies were expected to show. <br>
<h3>Log</h3>
<div id="log" style="height:50px; overflow-y:scroll; background: #FFF">
</div>
<h3>IFrames</h3>
<div id="iframes" style="height:170px; overflow-y:scroll; background: #FFF">
</div>
<h3>Test Results</h3>
<!-- No element should come after this - the test harness appends the result
here when it finished running all of them. -->
<div id="log"></div>
<div id="iframes"></div>
<script type="text/javascript">
<script>
setup({ explicit_timeout: true });
const TEST_CASES = [%s];
......
......@@ -8,24 +8,14 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="cookie-http-state-template.js"></script>
<style type="text/css">
.scrollable {
height:150px;
overflow-y:scroll;
}
</style>
</head>
<body>
<h3>Log</h3>
<div id="log" class="scrollable"></div>
<h3>IFrame</h3>
<div id="iframes" class="toggleable scrollable"></div>
<h3>Test Results</h3>
<div id="log"></div>
<div id="iframes"></div>
<script>
setup({ explicit_timeout: true });
promise_test(createCookieTest("%s"), "DEBUG");
</script>
</body>
</html>
......@@ -9,14 +9,9 @@
<script src="/resources/testharnessreport.js"></script>
<script src="resources/cookie-http-state-template.js"></script>
</head>
<body style="background:#EEE">
<h3>Log</h3>
<div id="log" style="height:50px; overflow-y:scroll; background: #FFF">
</div>
<h3>IFrames</h3>
<div id="iframes" style="height:170px; overflow-y:scroll; background: #FFF">
</div>
<h3>Test Results</h3>
<body>
<div id="log"></div>
<div id="iframes"></div>
<script>
setup({ explicit_timeout: true });
......
......@@ -52,79 +52,27 @@ window.test_driver_internal = {
// other commands...
/**
* Triggers browser window to be resized and relocated
*
* This matches the behaviour of the {@link
* https://w3c.github.io/webdriver/#set-window-rect|WebDriver
* Set Window Rect command}.
*
* @param {Integer} x - The x coordinate of the top left of the window
* @param {Integer} y - The x coordinate of the top left of the window
* @param {Integer} width - The width of the window
* @param {Integer} height - The height of the window
* @returns {Promise} fulfilled after window rect is set occurs, or rejected in
* the cases the WebDriver command errors
*/
set_window_rect: function(x, y, width, height) {
return Promise.reject(new Error("unimplemented"))
}
```
We will leave this unimplemented and override it in another file. Lets do that now!
### [wptrunner/wptrunner/testdriver-extra.js](https://github.com/web-platform-tests/wpt/blob/master/tools/wptrunner/wptrunner/testdriver-extra.js)
### [tools/wptrunner/wptrunner/testdriver-extra.js](https://github.com/web-platform-tests/wpt/blob/master/tools/wptrunner/wptrunner/testdriver-extra.js)
This will be the default function called when invoking the test driver commands (sometimes it is overridden by testdriver-vendor.js, but this is outside the scope of this writeup).
This will be the default function called when invoking the test driver commands (sometimes it is overridden by testdriver-vendor.js, but that is outside the scope of this tutorial). In most cases this is just boilerplate:
```javascript
window.test_driver_internal.set_element_rect = function(x, y, width, height) {
const pending_promise = new Promise(function(resolve, reject) {
pending_resolve = resolve;
pending_reject = reject;
});
window.opener.postMessage(
{"type": "action", "action": "set_window_rect", "x": x, "y": y, "width": width, "height": height}, "*");
return pending_promise;
return create_action("set_element_rect", {x, y, width, height});
};
```
The main thing here is the `postMessage` argument. The first argument is an object with properties
- `type`: this always has to be the string `"action"`
- `action`: the name of the testdriver command this defines (in this case, `set_window_rect`)
- any other things you want to pass to the next point of execution (in this case, the x, y coordinates and the width and height)
<!-- The pending promise needs to be there as it is resolved when the window receives a completion message from the executor. -->
The pending promise is out of scope of this function and is resolved when the window receives a completion message from the executor.
This happens here in the same file:
```javascript
let pending_resolve = null;
let pending_reject = null;
let result = null;
window.addEventListener("message", function(event) {
const data = event.data;
if (typeof data !== "object" && data !== null) {
return;
}
if (data.type !== "testdriver-complete") {
return;
}
if (data.status === "success") {
result = JSON.parse(data.message).result
pending_resolve(result);
} else {
pending_reject();
}
});
```
One limitation this introduces is that only one testdriver call can be made at one time since the `pending_resolve` and `pending_reject` variables are in an outer scope.
The `create_action` helper function does the heavy lifting of setting up a postMessage to the wptrunner internals as well as returning a promise that will resolve once the call is complete.
Next, this is passed to the executor and protocol in wptrunner. Time to switch to Python!
[tools/wptrunner/wptrunner/executors/protocol.py](https://github.com/web-platform-tests/wpt/blob/master/tools/wptrunner/wptrunner/executors/protocol.py)
### [tools/wptrunner/wptrunner/executors/protocol.py](https://github.com/web-platform-tests/wpt/blob/master/tools/wptrunner/wptrunner/executors/protocol.py)
```python
class SetWindowRectProtocolPart(ProtocolPart):
......@@ -144,34 +92,9 @@ class SetWindowRectProtocolPart(ProtocolPart):
pass
```
Next we change the base executor.
[tools/wptrunner/wptrunner/executors/base.py](https://github.com/web-platform-tests/wpt/blob/master/tools/wptrunner/wptrunner/executors/base.py)
```python
class CallbackHandler(object):
"""Handle callbacks from testdriver-using tests.
The default implementation here makes sense for things that are roughly like
WebDriver. Things that are more different to WebDriver may need to create a
fully custom implementation."""
Next we create a representation of our new action.
def __init__(self, logger, protocol, test_window):
self.protocol = protocol
self.test_window = test_window
self.logger = logger
self.callbacks = {
"action": self.process_action,
"complete": self.process_complete
}
self.actions = {
"click": ClickAction(self.logger, self.protocol),
"send_keys": SendKeysAction(self.logger, self.protocol),
{other actions},
"set_window_rect": SetWindowRectAction(self.logger, self.protocol) # add this!
}
```
### [tools/wptrunner/wptrunner/executors/actions.py](https://github.com/web-platform-tests/wpt/blob/master/tools/wptrunner/wptrunner/executors/actions.py)
```python
class SetWindowRectAction(object):
......@@ -186,12 +109,14 @@ class SetWindowRectAction(object):
self.protocol.set_window_rect.set_window_rect(x, y, width, height)
```
Then add your new class to the `actions = [...]` list at the end of the file.
Don't forget to write docs in ```testdriver.md```.
Now we write the browser specific implementations.
### Chrome
We will use [executorwebdriver](https://github.com/web-platform-tests/wpt/blob/master/tools/wptrunner/wptrunner/executors/executorwebdriver.py) and use the WebDriver API.
We will modify [executorwebdriver.py](https://github.com/web-platform-tests/wpt/blob/master/tools/wptrunner/wptrunner/executors/executorwebdriver.py) and use the WebDriver API.
There isn't too much work to do here, we just need to define a subclass of the protocol part we defined earlier.
......@@ -238,7 +163,7 @@ class WebDriverProtocol(Protocol):
### Firefox
We use the [set window rect](https://firefox-source-docs.mozilla.org/python/marionette_driver.html#marionette_driver.marionette.Marionette.set_window_rect) Marionette command.
We will use [executormarionette](https://github.com/web-platform-tests/wpt/blob/master/tools/wptrunner/wptrunner/executors/executormarionette.py) and use the Marionette Python API.
We will modify [executormarionette.py](https://github.com/web-platform-tests/wpt/blob/master/tools/wptrunner/wptrunner/executors/executormarionette.py) and use the Marionette Python API.
We have little actual work to do here! We just need to define a subclass of the protocol part we defined earlier.
......@@ -309,6 +234,7 @@ promise_test(async t => {
}
</script>
```
### What about testdriver-vendor.js?
The file [testdriver-vendor.js](https://github.com/web-platform-tests/wpt/blob/master/resources/testdriver-vendor.js) is the equivalent to testdriver-extra.js above, except it is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment