From 3654f9652cc02ab8bdaab7cbb629c66d101c7d2d Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Thu, 19 Feb 2015 15:50:21 +0900 Subject: [PATCH] Bug 1119609 part.16 Fix new orange of browser_tilt_controllers.js since they were passed because keypress events were not dispatched r=smaug+vporof --- .../tilt/test/browser_tilt_controller.js | 80 ++++++++++--------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/browser/devtools/tilt/test/browser_tilt_controller.js b/browser/devtools/tilt/test/browser_tilt_controller.js index d11260f140e..282b4290347 100644 --- a/browser/devtools/tilt/test/browser_tilt_controller.js +++ b/browser/devtools/tilt/test/browser_tilt_controller.js @@ -42,19 +42,22 @@ function test() { ok(isEqualVec(rot(), prev_rot), "At init, the rotation should be zero."); - - function testEventCancel(cancellingEvent) { + function testEventCancel(cancellingEvent, cancellingDescription) { + let description = "testEventCancel, cancellingEvent is " + cancellingDescription + ": "; is(document.activeElement, canvas, - "The visualizer canvas should be focused when performing this test."); + description + "The visualizer canvas should be focused when performing this test."); - EventUtils.synthesizeKey("VK_A", { type: "keydown" }); - EventUtils.synthesizeKey("VK_LEFT", { type: "keydown" }); + EventUtils.synthesizeKey("a", { type: "keydown", code: "KeyA", keyCode: KeyboardEvent.DOM_VK_A }); instance.controller._update(); - - ok(!isEqualVec(tran(), prev_tran), - "After a translation key is pressed, the vector should change."); ok(!isEqualVec(rot(), prev_rot), - "After a rotation key is pressed, the quaternion should change."); + description + "After a rotation key is pressed, the quaternion should change."); + EventUtils.synthesizeKey("a", { type: "keyup", code: "KeyA", keyCode: KeyboardEvent.DOM_VK_A }); + + EventUtils.synthesizeKey("ArrowLeft", { type: "keydown", code: "ArrowLeft", keyCode: KeyboardEvent.DOM_VK_LEFT }); + instance.controller._update(); + ok(!isEqualVec(tran(), prev_tran), + description + "After a translation key is pressed, the vector should change."); + EventUtils.synthesizeKey("ArrowLeft", { type: "keyup", code: "ArrowLeft", keyCode: KeyboardEvent.DOM_VK_LEFT }); save(); @@ -63,9 +66,9 @@ function test() { instance.controller._update(); ok(!isEqualVec(tran(), prev_tran), - "Even if the canvas lost focus, the vector has some inertia."); + description + "Even if the canvas lost focus, the vector has some inertia."); ok(!isEqualVec(rot(), prev_rot), - "Even if the canvas lost focus, the quaternion has some inertia."); + description + "Even if the canvas lost focus, the quaternion has some inertia."); save(); @@ -82,41 +85,40 @@ function test() { info("Setting typeaheadfind to true."); - Services.prefs.setBoolPref("accessibility.typeaheadfind", true); - testEventCancel(function() { - EventUtils.synthesizeKey("T", { type: "keydown", altKey: 1 }); - }); - testEventCancel(function() { - EventUtils.synthesizeKey("I", { type: "keydown", ctrlKey: 1 }); - }); - testEventCancel(function() { - EventUtils.synthesizeKey("L", { type: "keydown", metaKey: 1 }); - }); - testEventCancel(function() { - EventUtils.synthesizeKey("T", { type: "keydown", shiftKey: 1 }); - }); + let typeaheadfindEnabled = true; + Services.prefs.setBoolPref("accessibility.typeaheadfind", typeaheadfindEnabled); + for (var i = 0; i < 2; i++) { + testEventCancel(function() { + // XXX Don't use a character which is registered as a mnemonic in the menubar. + EventUtils.synthesizeKey("A", { altKey: true, code: "KeyA", keyCode: KeyboardEvent.DOM_VK_A }); + }, "Alt + A"); + testEventCancel(function() { + // XXX Don't use a character which is registered as a shortcut key. + EventUtils.synthesizeKey(";", { ctrlKey: true, code: "Semicolon", keyCode: KeyboardEvent.DOM_VK_SEMICONLON }); + }, "Ctrl + ;"); + testEventCancel(function() { + // XXX Don't use a character which is registered as a shortcut key. + EventUtils.synthesizeKey("\\", { metaKey: true, code: "Backslash", keyCode: KeyboardEvent.DOM_VK_BACK_SLASH }); + }, "Meta + \\"); + // If typeahead is enabled, Shift + T causes moving focus to the findbar because it inputs "T". + if (!typeaheadfindEnabled) { + testEventCancel(function() { + EventUtils.synthesizeKey("T", { shiftKey: true, code: "KeyT", keyCode: KeyboardEvent.DOM_VK_T }); + }, "Shift + T"); + } - info("Setting typeaheadfind to false."); + // Retry after disabling typeaheadfind. + info("Setting typeaheadfind to false."); - Services.prefs.setBoolPref("accessibility.typeaheadfind", false); - testEventCancel(function() { - EventUtils.synthesizeKey("T", { type: "keydown", altKey: 1 }); - }); - testEventCancel(function() { - EventUtils.synthesizeKey("I", { type: "keydown", ctrlKey: 1 }); - }); - testEventCancel(function() { - EventUtils.synthesizeKey("L", { type: "keydown", metaKey: 1 }); - }); - testEventCancel(function() { - EventUtils.synthesizeKey("T", { type: "keydown", shiftKey: 1 }); - }); + typeaheadfindEnabled = false; + Services.prefs.setBoolPref("accessibility.typeaheadfind", typeaheadfindEnabled); + } info("Testing if loosing focus halts any stacked arcball animations."); testEventCancel(function() { gBrowser.selectedBrowser.contentWindow.focus(); - }); + }, "setting focus to the content window"); }, onEnd: function() {