Update web-platform-tests to revision dc5ac330e65f29e767d7ce86004be251aad321f6

This commit is contained in:
WPT Sync Bot 2019-03-09 20:40:39 -05:00
parent 169b8cf144
commit ef0343b420
15 changed files with 280 additions and 35 deletions

View file

@ -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>

View file

@ -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>

View file

@ -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();

View file

@ -22,6 +22,7 @@ enum MediaSessionAction {
"previoustrack",
"nexttrack",
"skipad",
"stop",
};
callback MediaSessionActionHandler = void();