Revision c07267bcbf0fbd8dff22d8729e6c8b823bd2435f authored by Luke Bjerring on 17 May 2018, 20:53:16 UTC, committed by Luke Bjerring on 17 May 2018, 20:53:16 UTC
1 parent 7a3894d
usbDevice-iframe.https.html
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/fake-devices.js"></script>
<script src="resources/usb-helpers.js"></script>
<script>
'use strict';
function runIframeDisconnectTest(onDeviceConnected) {
return new Promise((resolve, reject) => {
let opened = false;
let iframe = document.createElement('iframe');
iframe.src = 'resources/open-in-iframe.html';
iframe.onload = () => {
navigator.usb.test.attachToWindow(iframe.contentWindow).then(() => {
iframe.contentWindow.postMessage('Ready', '*');
});
};
window.onmessage = messageEvent => {
if (messageEvent.data == 'Ready') {
let fakeDevice = navigator.usb.test.addFakeDevice(fakeDeviceInit);
fakeDevice.onclose = () => {
assert_true(opened);
resolve();
};
} else if (messageEvent.data == 'Success') {
opened = true;
onDeviceConnected(iframe);
} else {
reject(messageEvent.data);
}
};
document.body.appendChild(iframe);
});
}
usb_test(() => {
return runIframeDisconnectTest(iframe => {
document.body.removeChild(iframe);
});
}, 'detaching iframe disconnects device.');
usb_test(() => {
return runIframeDisconnectTest(iframe => {
iframe.src = 'about:blank';
});
}, 'navigating iframe disconnects device.');
</script>
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...