Commit d5e233ea authored by Arnaud Mandy's avatar Arnaud Mandy Committed by Commit Bot

WPT: Refactor idle-detection tests to use test-only-api.js

use of test-only-api.js in preparation for launching official MojoJS support
in WPT. This would not change the test results on Chromium waterfall
(everything should continue to pass) or upstream WPT (tests currently
fail because MojoJS isn't enabled).

Bug: 1123990
Change-Id: Ib1c94aa4980503ab90857f716f334d42a3cb4b0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2396220Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Reviewed-by: default avatarRaphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Arnaud Mandy <arnaud.mandy@intel.com>
Cr-Commit-Position: refs/heads/master@{#805838}
parent 667a0759
...@@ -3,18 +3,18 @@ ...@@ -3,18 +3,18 @@
<title>Tests the Idle Detection API</title> <title>Tests the Idle Detection API</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/resources/test-only-api.js"></script>
<script src="/resources/testdriver.js"></script> <script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script> <script src="/resources/testdriver-vendor.js"></script>
<script src="/gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script> <script src="resources/idle-detection-helper.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/mojom/idle/idle_manager.mojom.js"></script>
<script src="mock.js"></script>
<script> <script>
'use strict'; 'use strict';
promise_setup(async t => { promise_setup(async t => {
await test_driver.set_permission({ name: 'notifications' }, 'granted', false); await test_driver.set_permission({ name: 'notifications' }, 'granted', false);
if (isChromiumBased) {
await loadChromiumResources();
}
}) })
promise_test(async t => { promise_test(async t => {
......
'use strict';
// These tests rely on the User Agent providing an implementation of
// platform nfc backends.
//
// In Chromium-based browsers this implementation is provided by a polyfill
// in order to reduce the amount of test-only code shipped to users. To enable
// these tests the browser must be run with these options:
//
// --enable-blink-features=MojoJS,MojoJSTest
async function loadChromiumResources() {
const chromiumResources = [
'/gen/mojo/public/mojom/base/string16.mojom.js',
'/gen/mojo/public/mojom/base/time.mojom.js',
'/gen/third_party/blink/public/mojom/idle/idle_manager.mojom.js'
];
await loadMojoResources(chromiumResources);
await loadScript('/resources/chromium/mock-idle-detection.js');
}
...@@ -718,7 +718,7 @@ MISSING DEPENDENCY: bluetooth/resources/bluetooth-test.js ...@@ -718,7 +718,7 @@ MISSING DEPENDENCY: bluetooth/resources/bluetooth-test.js
MISSING DEPENDENCY: contacts/resources/helpers.js MISSING DEPENDENCY: contacts/resources/helpers.js
MISSING DEPENDENCY: credential-management/support/otpcredential-helper.js MISSING DEPENDENCY: credential-management/support/otpcredential-helper.js
MISSING DEPENDENCY: generic-sensor/resources/generic-sensor-helpers.js MISSING DEPENDENCY: generic-sensor/resources/generic-sensor-helpers.js
MISSING DEPENDENCY: idle-detection/interceptor.https.html MISSING DEPENDENCY: idle-detection/resources/idle-detection-helper.js
MISSING DEPENDENCY: mediacapture-image/resources/imagecapture-helpers.js MISSING DEPENDENCY: mediacapture-image/resources/imagecapture-helpers.js
MISSING DEPENDENCY: orientation-event/resources/orientation-event-helpers.js MISSING DEPENDENCY: orientation-event/resources/orientation-event-helpers.js
MISSING DEPENDENCY: resources/test-only-api.js MISSING DEPENDENCY: resources/test-only-api.js
......
<!DOCTYPE html> <!DOCTYPE html>
<link rel="help" href="https://github.com/samuelgoto/idle-detection"> <link rel="help" href="https://github.com/samuelgoto/idle-detection">
<title>Tests the Idle Detection API</title> <title>Tests the Idle Detection API</title>
<script src="../resources/testharness.js"></script> <script src="/resources/test-only-api.js"></script>
<script src="../resources/testharnessreport.js"></script> <script src="/resources/testharness.js"></script>
<script src="../resources/visibility.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script> <script src="/idle-detection/resources/idle-detection-helper.js"></script>
<script src="file:///gen/mojo/public/mojom/base/string16.mojom.js"></script>
<script src="file:///gen/mojo/public/mojom/base/time.mojom.js"></script>
<script src="file:///gen/third_party/blink/public/mojom/idle/idle_manager.mojom.js"></script>
<script src="../external/wpt/idle-detection/mock.js"></script>
<script> <script>
'use strict'; 'use strict';
promise_test(async t => { // setMainWindowHidden is duplicated from resources/visibility.js.
// This is necessary to have the test in wpt_internal.
function setMainWindowHidden(hidden) {
return new Promise((resolve, reject) => {
if (!window.testRunner) {
reject("no window.testRunner present");
return;
}
if (document.visibilityState == (hidden ? "hidden" : "visible")) {
reject("setMainWindowHidden(" + hidden + ") called but already " + hidden);
return;
}
document.addEventListener("visibilitychange", resolve, {once:true});
testRunner.setMainWindowHidden(hidden);
});
}
promise_setup(async t => {
await internals.setPermission({name: 'notifications'}, 'granted', await internals.setPermission({name: 'notifications'}, 'granted',
location.origin, location.origin); location.origin, location.origin);
if (isChromiumBased) {
await loadChromiumResources();
}
})
promise_test(async t => {
let monitor; let monitor;
expect(addMonitor).andReturn((threshold, monitorPtr) => { expect(addMonitor).andReturn((threshold, monitorPtr) => {
......
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