Commit 20ded1b9 authored by Ovidio Henriquez's avatar Ovidio Henriquez Committed by Commit Bot

bluetooth: web: test: Load resources on http test

This change updates the prefixes used for loading Chromium specific
resources to use the aliases used by the Apache HTTP server for the http
bluetooth test. As a result, the cross origin iframe test now uses the
new test API so that it can be migrated to the wpt/ directory.

BUG=509038

Change-Id: Ib946c912913d7a67b887fff4d74e432ea915ddb9
Reviewed-on: https://chromium-review.googlesource.com/827531Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Reviewed-by: default avatarConley Owens <cco3@chromium.org>
Commit-Queue: Ovidio Henriquez <odejesush@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524521}
parent a2476cb9
...@@ -4,34 +4,32 @@ ...@@ -4,34 +4,32 @@
<script src="/js-test-resources/testdriver.js"></script> <script src="/js-test-resources/testdriver.js"></script>
<script src="/js-test-resources/testdriver-vendor.js"></script> <script src="/js-test-resources/testdriver-vendor.js"></script>
<script src="/js-test-resources/bluetooth/bluetooth-helpers.js"></script> <script src="/js-test-resources/bluetooth/bluetooth-helpers.js"></script>
<script src="/js-test-resources/bluetooth/bluetooth-fake-adapter.js"></script>
<body> <body>
<script> <script>
'use strict'; 'use strict';
const test_desc = 'Request device from a unique origin. ' + const test_desc = 'Request device from a unique origin. ' +
'Should reject with SecurityError.'; 'Should reject with SecurityError.';
let iframe = document.createElement('iframe'); let iframe = document.createElement('iframe');
async_test(test => bluetooth_test(() => setUpConnectableHealthThermometerDevice()
setBluetoothFakeAdapter('HeartRateAdapter') // 1. Load the iframe.
// 1. Load the iframe. .then(() => new Promise(resolve => {
.then(() => new Promise(resolve => { iframe.src = 'https://localhost:8443/js-test-resources/bluetooth/' +
iframe.src = 'https://localhost:8443/js-test-resources/bluetooth/requestDevice-in-iframe.html'; 'requestDevice-in-iframe.html';
document.body.appendChild(iframe); document.body.appendChild(iframe);
iframe.addEventListener('load', resolve); iframe.addEventListener('load', resolve);
})) }))
// 2. Request the device from the iframe. // 2. Request the device from the iframe.
.then(() => { .then(() => new Promise(resolve => {
callWithTrustedClick(() => { callWithTrustedClick(() => {
iframe.contentWindow.postMessage('Go', '*'); iframe.contentWindow.postMessage('Go', '*');
}); });
window.onmessage = messageEvent => test.step(() => { window.onmessage = messageEvent => {
assert_equals(messageEvent.data, 'SecurityError: requestDevice() ' + assert_equals(messageEvent.data, 'SecurityError: requestDevice() ' +
'called from cross-origin iframe.'); 'called from cross-origin iframe.');
test.done(); resolve();
}); }
}), test_desc); })), test_desc);
</script> </script>
</body> </body>
...@@ -25,8 +25,15 @@ function performChromiumSetup() { ...@@ -25,8 +25,15 @@ function performChromiumSetup() {
// Load the Chromium-specific resources. // Load the Chromium-specific resources.
let root = window.location.pathname.match(/.*LayoutTests/); let root = window.location.pathname.match(/.*LayoutTests/);
let resource_prefix = `${root}/resources`; let resource_prefix, gen_prefix;
let gen_prefix = 'file:///gen/'; if (root === null) {
// Use the correct aliases for tests using an HTTP server.
resource_prefix = `/js-test-resources`;
gen_prefix = `/gen`;
} else {
resource_prefix = `${root}/resources`;
gen_prefix = 'file:///gen/';
}
return loadScripts([ return loadScripts([
`${gen_prefix}/layout_test_data/mojo/public/js/mojo_bindings.js`, `${gen_prefix}/layout_test_data/mojo/public/js/mojo_bindings.js`,
`${gen_prefix}/content/test/data/mojo_layouttest_test.mojom.js`, `${gen_prefix}/content/test/data/mojo_layouttest_test.mojom.js`,
......
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