Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/webusb/usbDevice-iframe.https.html

Issue 2789723003: Migrate WebUSB LayoutTests into external/wpt (Closed)
Patch Set: Upstream tests that will work in stable Chrome Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="/resources/testharness.js"></script>
3 <script src="/resources/testharnessreport.js"></script>
4 <script src="resources/fake-devices.js"></script>
5 <script src="resources/usb-helpers.js"></script>
6 <script>
7 'use strict';
8
9 function runIframeDisconnectTest(onDeviceConnected) {
10 return new Promise((resolve, reject) => {
11 let opened = false;
12
13 let iframe = document.createElement('iframe');
14 iframe.src = 'resources/open-in-iframe.html';
15 iframe.onload = () => {
16 navigator.usb.test.attachToWindow(iframe.contentWindow).then(() => {
17 iframe.contentWindow.postMessage('Ready', '*');
18 });
19 };
20
21 window.onmessage = messageEvent => {
22 if (messageEvent.data == 'Ready') {
23 let fakeDevice = navigator.usb.test.addFakeDevice(fakeDeviceInit);
24 fakeDevice.onclose = () => {
25 assert_true(opened);
26 resolve();
27 };
28 } else if (messageEvent.data == 'Success') {
29 opened = true;
30 onDeviceConnected(iframe);
31 } else {
32 reject(messageEvent.data);
33 }
34 };
35
36 document.body.appendChild(iframe);
37 });
38 }
39
40 usb_test(() => {
41 return runIframeDisconnectTest(iframe => {
42 document.body.removeChild(iframe);
43 });
44 }, 'detaching iframe disconnects device.');
45
46 usb_test(() => {
47 return runIframeDisconnectTest(iframe => {
48 iframe.src = 'about:blank';
49 });
50 }, 'navigating iframe disconnects device.');
51 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698