Bug 1269497 - Provide toolbox.win getter to make lines shorter in tests;r=jdescottes

MozReview-Commit-ID: 9KuWzsyHQGF
This commit is contained in:
Brian Grinstead 2016-05-03 07:41:20 -07:00
parent 847bb23a7f
commit c77eeb7c73
13 changed files with 28 additions and 22 deletions

View File

@ -1158,7 +1158,7 @@ function getSplitConsole(toolbox, win) {
});
if (!win) {
win = toolbox.doc.defaultView;
win = toolbox.win;
}
if (!toolbox.splitConsole) {

View File

@ -40,7 +40,7 @@ function zoomWithKey(toolbox, key) {
info("Zooming with key: " + key);
let currentZoom = toolbox.zoomValue;
EventUtils.synthesizeKey(key, {accelKey: true}, toolbox.doc.defaultView);
EventUtils.synthesizeKey(key, {accelKey: true}, toolbox.win);
isnot(toolbox.zoomValue, currentZoom, "The zoom level was changed in the toolbox");
}

View File

@ -38,7 +38,7 @@ function test() {
function testCustomHost(t) {
toolbox = t;
is(toolbox.doc.defaultView.top, window, "Toolbox is included in browser.xul");
is(toolbox.win.top, window, "Toolbox is included in browser.xul");
is(toolbox.doc, iframe.contentDocument, "Toolbox is in the custom iframe");
executeSoon(() => gBrowser.removeCurrentTab());
}

View File

@ -53,14 +53,14 @@ add_task(function*() {
yield minimize(toolbox);
onMaximized = toolbox._host.once("maximized");
let tabButton = toolbox.doc.querySelector("#toolbox-tab-inspector");
EventUtils.synthesizeMouseAtCenter(tabButton, {}, toolbox.doc.defaultView);
EventUtils.synthesizeMouseAtCenter(tabButton, {}, toolbox.win);
yield onMaximized;
info("Minimize again and click on the settings tab");
yield minimize(toolbox);
onMaximized = toolbox._host.once("maximized");
let settingsButton = toolbox.doc.querySelector("#toolbox-tab-options");
EventUtils.synthesizeMouseAtCenter(settingsButton, {}, toolbox.doc.defaultView);
EventUtils.synthesizeMouseAtCenter(settingsButton, {}, toolbox.win);
yield onMaximized;
info("Switch to a different host");
@ -76,7 +76,7 @@ add_task(function*() {
function* minimize(toolbox) {
let button = toolbox.doc.querySelector("#toolbox-dock-bottom-minimize");
let onMinimized = toolbox._host.once("minimized");
EventUtils.synthesizeMouseAtCenter(button, {}, toolbox.doc.defaultView);
EventUtils.synthesizeMouseAtCenter(button, {}, toolbox.win);
yield onMinimized;
}
@ -85,14 +85,14 @@ function* minimizeWithShortcut(toolbox) {
.getAttribute("key");
let onMinimized = toolbox._host.once("minimized");
EventUtils.synthesizeKey(key, {accelKey: true, shiftKey: true},
toolbox.doc.defaultView);
toolbox.win);
yield onMinimized;
}
function* maximize(toolbox) {
let button = toolbox.doc.querySelector("#toolbox-dock-bottom-minimize");
let onMaximized = toolbox._host.once("maximized");
EventUtils.synthesizeMouseAtCenter(button, {}, toolbox.doc.defaultView);
EventUtils.synthesizeMouseAtCenter(button, {}, toolbox.win);
yield onMaximized;
}
@ -101,6 +101,6 @@ function* maximizeWithShortcut(toolbox) {
.getAttribute("key");
let onMaximized = toolbox._host.once("maximized");
EventUtils.synthesizeKey(key, {accelKey: true, shiftKey: true},
toolbox.doc.defaultView);
toolbox.win);
yield onMaximized;
}

View File

@ -56,7 +56,7 @@ function* testShortcuts(toolbox, index, key, toolIDs) {
" using key " + key);
let onToolSelected = toolbox.once("select");
EventUtils.synthesizeKey(key, {accelKey: true}, toolbox.doc.defaultView);
EventUtils.synthesizeKey(key, {accelKey: true}, toolbox.win);
let id = yield onToolSelected;
info("toolbox-select event from " + id);

View File

@ -43,7 +43,7 @@ function startReloadTest(aToolbox) {
testAllTheTools("docked", () => {
let origHostType = toolbox.hostType;
toolbox.switchHost(Toolbox.HostType.WINDOW).then(() => {
toolbox.doc.defaultView.focus();
toolbox.win.focus();
testAllTheTools("undocked", () => {
toolbox.switchHost(origHostType).then(() => {
gBrowser.selectedBrowser.messageManager.removeMessageListener("devtools:test:load", reloadCounter);

View File

@ -59,7 +59,7 @@ function testShortcuts(aToolbox, aIndex) {
idIndex = aIndex;
info("Testing shortcut for tool " + aIndex + ":" + toolIDs[aIndex] +
" using key " + key);
EventUtils.synthesizeKey(key, modifiers, toolbox.doc.defaultView.parent);
EventUtils.synthesizeKey(key, modifiers, toolbox.win.parent);
}
function selectCB(event, id) {

View File

@ -45,7 +45,7 @@ function testZoomLevel(type, times, expected) {
function sendZoomKey(id, times) {
let key = toolbox.doc.getElementById(id).getAttribute("key");
for (let i = 0; i < times; i++) {
EventUtils.synthesizeKey(key, modifiers, toolbox.doc.defaultView);
EventUtils.synthesizeKey(key, modifiers, toolbox.win);
}
}

View File

@ -276,6 +276,13 @@ Toolbox.prototype = {
return this._host.frame;
},
/**
* Shortcut to the window containing the toolbox UI
*/
get win() {
return this.doc.defaultView;
},
/**
* Shortcut to the document containing the toolbox UI
*/
@ -725,7 +732,7 @@ Toolbox.prototype = {
return;
}
let doc = this.doc.defaultView.parent.document;
let doc = this.win.parent.document;
for (let [id, toolDefinition] of gDevTools.getToolDefinitionMap()) {
// Prevent multiple entries for the same tool.
@ -936,7 +943,7 @@ Toolbox.prototype = {
toolbar.addEventListener("keypress", event => {
let { key, target } = event;
let win = this.doc.defaultView;
let win = this.win;
let elm, type;
if (key === "Tab") {
// Tabbing when toolbar or its contents are focused should move focus to
@ -1900,7 +1907,7 @@ Toolbox.prototype = {
}
if (this.hostType == Toolbox.HostType.WINDOW) {
let doc = this.doc.defaultView.parent.document;
let doc = this.win.parent.document;
let key = doc.getElementById("key_" + toolId);
if (key) {
key.parentNode.removeChild(key);
@ -2172,7 +2179,7 @@ Toolbox.prototype = {
* Enable / disable necessary textbox menu items using globalOverlay.js.
*/
_updateTextboxMenuItems: function() {
let window = this.doc.defaultView;
let window = this.win;
["cmd_undo", "cmd_delete", "cmd_cut",
"cmd_copy", "cmd_paste", "cmd_selectAll"].forEach(window.goUpdateCommand);
},

View File

@ -988,8 +988,7 @@ InspectorPanel.prototype = {
this._markupBox.removeAttribute("collapsed");
let controllerWindow = this._toolbox.doc.defaultView;
this.markup = new MarkupView(this, this._markupFrame, controllerWindow);
this.markup = new MarkupView(this, this._markupFrame, this._toolbox.win);
this.emit("markuploaded");
},

View File

@ -436,7 +436,7 @@ function mouseLeaveMarkupView(inspector) {
let btn = inspector.toolbox.doc.querySelector("#toolbox-controls");
EventUtils.synthesizeMouseAtCenter(btn, {type: "mousemove"},
inspector.toolbox.doc.defaultView);
inspector.toolbox.win);
executeSoon(def.resolve);
return def.promise;

View File

@ -107,7 +107,7 @@ function test() {
let onNodeUnhighlight = toolbox.once("node-unhighlight");
let btn = inspector.toolbox.doc.querySelector(".toolbox-dock-button");
EventUtils.synthesizeMouseAtCenter(btn, {type: "mousemove"},
inspector.toolbox.doc.defaultView);
inspector.toolbox.win);
yield onNodeUnhighlight;
info("Switching back to the console");

View File

@ -60,7 +60,7 @@ function test() {
}
function getCurrentUIState() {
let win = toolbox.doc.defaultView;
let win = toolbox.win;
let deck = toolbox.doc.querySelector("#toolbox-deck");
let webconsolePanel = toolbox.webconsolePanel;
let splitter = toolbox.doc.querySelector("#toolbox-console-splitter");