Bug 1306797: Dispatch key events to the correct windows. r=me
authorKris Maglione <maglione.k@gmail.com>
Sun, 06 Nov 2016 19:18:24 -0800
changeset 351416 90854a5e168707ba2d5958ddcb5f34eb3fb2cedd
parent 351415 4ffa6e380d58d41cf7ea567e9485a09c07d7ba87
child 351417 4b1de4471e4b0f472c0b5c523b3f64cbd15ff30c
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1306797
milestone52.0a1
Bug 1306797: Dispatch key events to the correct windows. r=me MozReview-Commit-ID: 2jxb5dnVREu
browser/components/extensions/test/browser/browser_ext_commands_onCommand.js
--- a/browser/components/extensions/test/browser/browser_ext_commands_onCommand.js
+++ b/browser/components/extensions/test/browser/browser_ext_commands_onCommand.js
@@ -171,30 +171,30 @@ add_task(function* test_user_defined_com
     SimpleTest.monitorConsole(resolve, [{
       message: /Reading manifest: Error processing commands.*.unrecognized_property: An unexpected property was found/,
     }]);
   });
 
   yield extension.startup();
   yield extension.awaitMessage("ready");
 
-  function* runTest() {
+  function* runTest(window) {
     for (let testCommand of testCommands) {
       if (testCommand.shortcutMac && !testCommand.shortcut && !isMac) {
         continue;
       }
-      EventUtils.synthesizeKey(testCommand.key, testCommand.modifiers);
+      EventUtils.synthesizeKey(testCommand.key, testCommand.modifiers, window);
       let message = yield extension.awaitMessage("oncommand");
       is(message, testCommand.name, `Expected onCommand listener to fire with the correct name: ${testCommand.name}`);
     }
   }
 
   // Create another window after the extension is loaded.
   let win2 = yield BrowserTestUtils.openNewBrowserWindow();
-  yield BrowserTestUtils.loadURI(win2.gBrowser.selectedBrowser, "about:config");
+  yield BrowserTestUtils.loadURI(win2.gBrowser.selectedBrowser, "about:robots");
   yield BrowserTestUtils.browserLoaded(win2.gBrowser.selectedBrowser);
 
   let totalTestCommands = Object.keys(testCommands).length;
   let expectedCommandsRegistered = isMac ? totalTestCommands : totalTestCommands - totalMacOnlyCommands;
 
   // Confirm the keysets have been added to both windows.
   let keysetID = `ext-keyset-id-${makeWidgetId(extension.id)}`;
   let keyset = win1.document.getElementById(keysetID);
@@ -202,20 +202,20 @@ add_task(function* test_user_defined_com
   is(keyset.childNodes.length, expectedCommandsRegistered, "Expected keyset to have the correct number of children");
 
   keyset = win2.document.getElementById(keysetID);
   ok(keyset != null, "Expected keyset to exist");
   is(keyset.childNodes.length, expectedCommandsRegistered, "Expected keyset to have the correct number of children");
 
   // Confirm that the commands are registered to both windows.
   yield focusWindow(win1);
-  yield runTest();
+  yield runTest(win1);
 
   yield focusWindow(win2);
-  yield runTest();
+  yield runTest(win2);
 
   yield extension.unload();
 
   // Confirm that the keysets have been removed from both windows after the extension is unloaded.
   keyset = win1.document.getElementById(keysetID);
   is(keyset, null, "Expected keyset to be removed from the window");
 
   keyset = win2.document.getElementById(keysetID);