Skip to content

Commit

Permalink
Update web-platform-tests to revision dc5ac330e65f29e767d7ce86004be25…
Browse files Browse the repository at this point in the history
…1aad321f6
  • Loading branch information
servo-wpt-sync committed Mar 10, 2019
1 parent 169b8cf commit ef0343b
Show file tree
Hide file tree
Showing 15 changed files with 280 additions and 35 deletions.
3 changes: 0 additions & 3 deletions tests/wpt/metadata/FileAPI/url/url-with-fetch.any.js.ini
Expand Up @@ -37,6 +37,3 @@
[Revoke blob URL after creating Request, will fetch]
expected: FAIL

[Revoke blob URL after calling fetch, fetch should succeed]
expected: FAIL

31 changes: 30 additions & 1 deletion tests/wpt/metadata/MANIFEST.json
Expand Up @@ -302677,6 +302677,11 @@
{}
]
],
"idle-detection/mock.js": [
[
{}
]
],
"imagebitmap-renderingcontext/META.yml": [
[
{}
Expand Down Expand Up @@ -352163,6 +352168,12 @@
{}
]
],
"css/css-flexbox/intrinsic-width-overflow-auto.tentative.html": [
[
"css/css-flexbox/intrinsic-width-overflow-auto.tentative.html",
{}
]
],
"css/css-flexbox/order_value.html": [
[
"css/css-flexbox/order_value.html",
Expand Down Expand Up @@ -396238,6 +396249,12 @@
}
]
],
"idle-detection/interceptor.https.html": [
[
"idle-detection/interceptor.https.html",
{}
]
],
"imagebitmap-renderingcontext/bitmaprenderer-as-imagesource.html": [
[
"imagebitmap-renderingcontext/bitmaprenderer-as-imagesource.html",
Expand Down Expand Up @@ -578260,6 +578277,10 @@
"0220d79d901cca14324ea331d0ddfd9c086a08ee",
"manual"
],
"css/css-flexbox/intrinsic-width-overflow-auto.tentative.html": [
"8310e66cc4a2ef680d15f5c3ea56feb6edf4252e",
"testharness"
],
"css/css-flexbox/item-with-table-with-infinite-max-intrinsic-width.html": [
"f475db5bcffd1449be231da943cd1511b15e20b1",
"reftest"
Expand Down Expand Up @@ -665480,6 +665501,14 @@
"4bda5c1a85b71e8fcb1c050710279bfec2919b68",
"testharness"
],
"idle-detection/interceptor.https.html": [
"03595afccdcd224f918f6e8baaf21c2419c24062",
"testharness"
],
"idle-detection/mock.js": [
"d88d1ad1c55afaee243e1e9146827b073c380613",
"support"
],
"imagebitmap-renderingcontext/META.yml": [
"f6a06f4e7d7625855e271ec5422629ca5e734560",
"support"
Expand Down Expand Up @@ -666633,7 +666662,7 @@
"support"
],
"interfaces/mediasession.idl": [
"0fc9ff05f9475cd7f48fde6c22765d431b51310c",
"6fd5725dbb2975e724594629f0c2882477455caa",
"support"
],
"interfaces/mediastream-recording.idl": [
Expand Down
@@ -0,0 +1,7 @@
[intrinsic-width-overflow-auto.tentative.html]
[.flexbox 1]
expected: FAIL

[.flexbox 2]
expected: FAIL

Expand Up @@ -149,9 +149,6 @@
[Matching font-style: 'oblique -21deg' should prefer 'oblique -21deg' over 'oblique -60deg -40deg']
expected: FAIL

[Matching font-style: 'oblique -21deg' should prefer 'oblique -10deg' over 'italic']
expected: FAIL

[Matching font-style: 'oblique -21deg' should prefer 'italic' over 'oblique 0deg']
expected: FAIL

Expand Down

This file was deleted.

@@ -1,4 +1,4 @@
[traverse_the_history_3.html]
[traverse_the_history_5.html]
[Multiple history traversals, last would be aborted]
expected: FAIL

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -0,0 +1,4 @@
[iframe_005.html]
[document.write external script into iframe write back into parent]
expected: FAIL

@@ -0,0 +1,21 @@
<!DOCTYPE html>
<link rel="author" title="Google" href="https://www.google.com/" />
<link rel="help" href="https://drafts.csswg.org/css-flexbox-1/#intrinsic-sizes" />
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/1865" />

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>

<body onload="checkLayout('.flexbox')">
<div class="flexbox" style="display: flex; width: min-content;" data-expected-width="0">
<div style="overflow: auto;">
<div style="width: 100px; height: 100px;"></div>
</div>
</div>

<div class="flexbox" style="display: flex; width: min-content;" data-expected-width="10">
<div style="overflow: auto; border: 5px solid;">
<div style="width: 100px; height: 100px;"></div>
</div>
</div>
133 changes: 133 additions & 0 deletions tests/wpt/web-platform-tests/idle-detection/interceptor.https.html
@@ -0,0 +1,133 @@
<!DOCTYPE html>
<link rel="help" href="https://github.com/inexorabletash/idle-detection">
<title>Tests the Idle Detection API</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="/gen/mojo/public/mojom/base/string16.mojom.js"></script>
<script src="/gen/mojo/public/mojom/base/time.mojom.js"></script>
<script src="/gen/third_party/blink/public/platform/modules/idle/idle_manager.mojom.js"></script>
<script src="mock.js"></script>
<script>
'use strict';

promise_test(async t => {
// Basic test that expects navigator.idle.query() to call internally
// addMonitor, which in turn will return an ACTIVE state.
expect(addMonitor).andReturn((threshold, monitorPtr) => {
return Promise.resolve({
state: {
user: UserIdleState.ACTIVE,
screen: ScreenIdleState.LOCKED
}
});
});

let status = await navigator.idle.query({threshold: 10});

assert_equals(status.state.user, "active");
assert_equals(status.state.screen, "locked");
}, 'query()');

promise_test(async t => {
// Verifies that an event is thrown when a change of state from IDLE to ACTIVE
// is detected.
expect(addMonitor).andReturn((threshold, monitorPtr) => {
t.step_timeout(() => {
monitorPtr.update({
user: UserIdleState.IDLE,
screen: ScreenIdleState.UNLOCKED
});
}, 0);
return Promise.resolve({
state: {
user: UserIdleState.ACTIVE,
screen: ScreenIdleState.UNLOCKED
}
});
});

let monitor = await navigator.idle.query({threshold: 10});

await new EventWatcher(t, monitor, ["change"]).wait_for("change");

assert_equals(monitor.state.user, "idle");
assert_equals(monitor.state.screen, "unlocked");
}, 'updates once');


promise_test(async t => {
// Simulates the user being active, going idle and then going back active
// again.
expect(addMonitor).andReturn((threshold, monitorPtr) => {
// Updates the client once with the user idle.
t.step_timeout(() => {
monitorPtr.update({
user: UserIdleState.IDLE,
screen: ScreenIdleState.UNLOCKED
});
}, 0);
// Updates the client a second time with the user active.
t.step_timeout(() => {
monitorPtr.update({
user: UserIdleState.ACTIVE,
screen: ScreenIdleState.UNLOCKED
});
}, 1);
return Promise.resolve({
state: {
user: UserIdleState.ACTIVE,
screen: ScreenIdleState.UNLOCKED
}
});
});

let monitor = await navigator.idle.query({threshold: 10});

let watcher = new EventWatcher(t, monitor, ["change"]);

// waits for the first event.
await watcher.wait_for("change");
assert_equals(monitor.state.user, "idle");

// waits for the second event.
await watcher.wait_for("change");
assert_equals(monitor.state.user, "active");
}, 'updates twice');

promise_test(async t => {
// Simulates a locked screen.
expect(addMonitor).andReturn((threshold, monitorPtr) => {
return Promise.resolve({
state: {
user: UserIdleState.ACTIVE,
screen: ScreenIdleState.LOCKED
}
});
});

let monitor = await navigator.idle.query({threshold: 10});

assert_equals(monitor.state.screen, "locked");
}, 'locked screen');

promise_test(async t => {
// Simulates the service becoming unavailable.
expect(addMonitor).andReturn((threshold, monitorPtr) => {
return new Promise((resolve, reject) => {
// leave the renderer deliberately hanging by not resolve()-ing.
});
});

let error = new Promise((resolve, reject) => {
navigator.idle.query({threshold: 10})
.then((e) => {reject("unexpected response :(")})
.catch((e) => {resolve(e.message)});
});

// simulates what happens when the service is unavailable.
close();

assert_equals(await error, "Idle detection not available");
}, "service unavailable");
</script>
83 changes: 83 additions & 0 deletions tests/wpt/web-platform-tests/idle-detection/mock.js
@@ -0,0 +1,83 @@
/**
* This is a testing framework that enables us to test the user idle detection
* by intercepting the connection between the renderer and the browser and
* exposing a mocking API for tests.
*
* Usage:
*
* 1) Include <script src="mock.js"></script> in your file.
* 2) Set expectations
* expect(addMonitor).andReturn((threshold, monitorPtr, callback) => {
* // mock behavior
* })
* 3) Call navigator.idle.query()
*
* The mocking API is blink agnostic and is designed such that other engines
* could implement it too. Here are the symbols that are exposed to tests:
*
* - function addMonitor(): the main/only function that can be mocked.
* - function expect(): the main/only function that enables us to mock it.
* - function close(): disconnects the interceptor.
* - enum UserIdleState {IDLE, ACTIVE}: blink agnostic constants.
* - enum ScreenIdleState {LOCKED, UNLOCKED}: blink agnostic constants.
*/

class FakeIdleMonitor {
addMonitor(threshold, monitorPtr, callback) {
return this.handler.addMonitor(threshold, monitorPtr);
}
setHandler(handler) {
this.handler = handler;
return this;
}
setBinding(binding) {
this.binding = binding;
return this;
}
close() {
this.binding.close();
}
}

const UserIdleState = {};
const ScreenIdleState = {};

function addMonitor(threshold, monitorPtr, callback) {
throw new Error("expected to be overriden by tests");
}

async function close() {
interceptor.close();
}

function expect(call) {
return {
andReturn(callback) {
let handler = {};
handler[call.name] = callback;
interceptor.setHandler(handler);
}
}
}

function intercept() {
let result = new FakeIdleMonitor();

let binding = new mojo.Binding(blink.mojom.IdleManager, result);
let interceptor = new MojoInterfaceInterceptor(blink.mojom.IdleManager.name);
interceptor.oninterfacerequest = (e) => {
binding.bind(e.handle);
}

interceptor.start();

UserIdleState.ACTIVE = blink.mojom.UserIdleState.kActive;
UserIdleState.IDLE = blink.mojom.UserIdleState.kIdle;
ScreenIdleState.LOCKED = blink.mojom.ScreenIdleState.kLocked;
ScreenIdleState.UNLOCKED = blink.mojom.ScreenIdleState.kUnlocked;

result.setBinding(binding);
return result;
}

const interceptor = intercept();
1 change: 1 addition & 0 deletions tests/wpt/web-platform-tests/interfaces/mediasession.idl
Expand Up @@ -22,6 +22,7 @@ enum MediaSessionAction {
"previoustrack",
"nexttrack",
"skipad",
"stop",
};

callback MediaSessionActionHandler = void();
Expand Down

0 comments on commit ef0343b

Please sign in to comment.