Skip to content

Commit

Permalink
WPT: Refactor contacts tests to use test-only-api.js
Browse files Browse the repository at this point in the history
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
  • Loading branch information
arskama authored and chromium-wpt-export-bot committed Sep 7, 2020
1 parent 932a431 commit 2eaba85
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
1 change: 1 addition & 0 deletions contacts/contacts-select.https.window.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// META: script=/resources/test-only-api.js
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=resources/helpers.js
Expand Down
36 changes: 10 additions & 26 deletions contacts/resources/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -42,12 +27,11 @@ const loadChromiumResources = async () => {
// }
async function createWebContactsTest() {
if (typeof WebContactsTest === 'undefined') {
await loadChromiumResources();
if (isChromiumBased) {
await loadChromiumResources();
}
}
assert_true(
typeof WebContactsTest !== 'undefined',
'Mojo testing interface is not available.'
);
assert_implements(WebContactsTest, 'WebContactsTest is unavailable.');
return new WebContactsTest();
}

Expand Down

0 comments on commit 2eaba85

Please sign in to comment.