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.js
// META: script=/resources/testdriver-vendor.js // META: script=/resources/testdriver-vendor.js
// META: script=resources/helpers.js // META: script=resources/helpers.js
......
...@@ -8,31 +8,16 @@ ...@@ -8,31 +8,16 @@
// these tests the browser must be run with these options: // these tests the browser must be run with these options:
// //
// --enable-blink-features=MojoJS,MojoJSTest // --enable-blink-features=MojoJS,MojoJSTest
const loadChromiumResources = async () => { async function loadChromiumResources() {
if (!window.MojoInterfaceInterceptor) {
// Do nothing on non-Chromium-based browsers or when the Mojo bindings are
// not present in the global namespace.
return;
}
const resources = [ const chromiumResources = [
'/gen/layout_test_data/mojo/public/js/mojo_bindings.js',
'/gen/third_party/blink/public/mojom/contacts/contacts_manager.mojom.js', '/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 => { await loadMojoResources(chromiumResources);
const script = document.createElement('script'); await loadScript('/resources/chromium/contacts_manager_mock.js');
script.src = path; }
script.async = false;
const promise = new Promise((resolve, reject) => {
script.onload = resolve;
script.onerror = reject;
});
document.head.appendChild(script);
return promise;
}));
};
// User Agents must provide their own implementation of `WebContacts`, // User Agents must provide their own implementation of `WebContacts`,
// which must contain the following this interface: // which must contain the following this interface:
...@@ -42,12 +27,11 @@ const loadChromiumResources = async () => { ...@@ -42,12 +27,11 @@ const loadChromiumResources = async () => {
// } // }
async function createWebContactsTest() { async function createWebContactsTest() {
if (typeof WebContactsTest === 'undefined') { if (typeof WebContactsTest === 'undefined') {
await loadChromiumResources(); if (isChromiumBased) {
await loadChromiumResources();
}
} }
assert_true( assert_implements(WebContactsTest, 'WebContactsTest is unavailable.');
typeof WebContactsTest !== 'undefined',
'Mojo testing interface is not available.'
);
return new WebContactsTest(); 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