Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPT: Refactor contacts tests to use test-only-api.js #25421

Merged
merged 1 commit into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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