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

Side by Side Diff: third_party/WebKit/LayoutTests/usb/usbDevice-iframe.html

Issue 1946063002: Replace DeviceManager::GetDeviceChanges with a client interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@proper_stubs
Patch Set: Rebase.d Created 4 years, 7 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/mojo-helpers.js"></script> 4 <script src="../resources/mojo-helpers.js"></script>
5 <script src="resources/fake-devices.js"></script> 5 <script src="resources/fake-devices.js"></script>
6 <script src="resources/usb-helpers.js"></script> 6 <script src="resources/usb-helpers.js"></script>
7 <script> 7 <script>
8 'use strict'; 8 'use strict';
9 9
10 function runIframeDisconnectTest(usb, onDeviceConnected) { 10 function runIframeDisconnectTest(usb, onDeviceConnected) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 return runIframeDisconnectTest(usb, iframe => { 50 return runIframeDisconnectTest(usb, iframe => {
51 document.body.removeChild(iframe); 51 document.body.removeChild(iframe);
52 }); 52 });
53 }, 'detaching iframe disconnects device.'); 53 }, 'detaching iframe disconnects device.');
54 54
55 usb_test(usb => { 55 usb_test(usb => {
56 return runIframeDisconnectTest(usb, iframe => { 56 return runIframeDisconnectTest(usb, iframe => {
57 iframe.src = 'about:blank'; 57 iframe.src = 'about:blank';
58 }); 58 });
59 }, 'navigating iframe disconnects device.'); 59 }, 'navigating iframe disconnects device.');
60
61 usb_test(usb => {
62 return new Promise((resolve, reject) => {
63 let mockDeviceManager = new usb.MockDeviceManager;
64 let iframe = document.createElement('iframe');
65
66 window.onmessage = messageEvent => {
67 if (messageEvent.data === 'Ready') {
68 document.body.removeChild(iframe);
69 runGarbageCollection().then(() => {
70 mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
71 resolve();
72 });
73 } else {
74 reject(messageEvent.data);
75 }
76 };
77
78 iframe.src = 'resources/open-in-iframe.html';
79 iframe.onload = () => {
80 iframe.contentWindow.mojo.define(
81 "Mojo Service Registry",
82 [ 'content/public/renderer/frame_service_registry' ],
83 (frameServiceRegistry) => {
84 frameServiceRegistry.addServiceOverrideForTesting(
85 usb.DeviceManager.name,
86 pipe => { mockDeviceManager.bindToPipe(pipe); });
87 iframe.contentWindow.postMessage('Ready', '*');
88 });
89 }
90 document.body.appendChild(iframe);
91 });
92 }, 'events are not delivered to detached frames');
60 </script> 93 </script>
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/usb/resources/usb-helpers.js ('k') | third_party/WebKit/Source/modules/webusb/USB.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698