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

WPT: Refactor contacts 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: 1123989
Change-Id: Ib7fed092b37243b82fbbf38d871bb75728cb7744
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2395395
Commit-Queue: Arnaud Mandy <arnaud.mandy@intel.com>
Reviewed-by: default avatarFinnur Thorarinsson <finnur@chromium.org>
Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805272}
parent 357ac019
// META: script=/resources/test-only-api.js
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=resources/helpers.js
......
......@@ -8,31 +8,16 @@
// these tests the browser must be run with these options:
//
// --enable-blink-features=MojoJS,MojoJSTest
const loadChromiumResources = async () => {
if (!window.MojoInterfaceInterceptor) {
// Do nothing on non-Chromium-based browsers or when the Mojo bindings are
// not present in the global namespace.
return;
}
async function loadChromiumResources() {
const resources = [
'/gen/layout_test_data/mojo/public/js/mojo_bindings.js',
const chromiumResources = [
'/gen/third_party/blink/public/mojom/contacts/contacts_manager.mojom.js',
'/resources/chromium/contacts_manager_mock.js',
'/gen/components/payments/mojom/payment_request_data.mojom.js',
];
await Promise.all(resources.map(path => {
const script = document.createElement('script');
script.src = path;
script.async = false;
const promise = new Promise((resolve, reject) => {
script.onload = resolve;
script.onerror = reject;
});
document.head.appendChild(script);
return promise;
}));
};
await loadMojoResources(chromiumResources);
await loadScript('/resources/chromium/contacts_manager_mock.js');
}
// User Agents must provide their own implementation of `WebContacts`,
// which must contain the following this interface:
......@@ -42,12 +27,11 @@ const loadChromiumResources = async () => {
// }
async function createWebContactsTest() {
if (typeof WebContactsTest === 'undefined') {
if (isChromiumBased) {
await loadChromiumResources();
}
assert_true(
typeof WebContactsTest !== 'undefined',
'Mojo testing interface is not available.'
);
}
assert_implements(WebContactsTest, 'WebContactsTest is unavailable.');
return new WebContactsTest();
}
......
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