mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
Bug 597103 - HUDService.deactivateHUDForContext(tab) fails when the given tab is not from the focused window r=gavin.sharp a=betaN+
This commit is contained in:
parent
4e6391e6ac
commit
d030798874
@ -1348,9 +1348,9 @@ HUD_SERVICE.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* Activate a HeadsUpDisplay for the current window
|
||||
* Activate a HeadsUpDisplay for the given tab context.
|
||||
*
|
||||
* @param nsIDOMWindow aContext
|
||||
* @param Element aContext the tab element.
|
||||
* @returns void
|
||||
*/
|
||||
activateHUDForContext: function HS_activateHUDForContext(aContext)
|
||||
@ -1362,23 +1362,24 @@ HUD_SERVICE.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* Deactivate a HeadsUpDisplay for the current window
|
||||
* Deactivate a HeadsUpDisplay for the given tab context.
|
||||
*
|
||||
* @param nsIDOMWindow aContext
|
||||
* @returns void
|
||||
*/
|
||||
deactivateHUDForContext: function HS_deactivateHUDForContext(aContext)
|
||||
{
|
||||
var gBrowser = HUDService.currentContext().gBrowser;
|
||||
var window = aContext.linkedBrowser.contentWindow;
|
||||
var browser = gBrowser.getBrowserForDocument(window.top.document);
|
||||
var tabId = gBrowser.getNotificationBox(browser).getAttribute("id");
|
||||
var hudId = "hud_" + tabId;
|
||||
var displayNode = this.getHeadsUpDisplay(hudId);
|
||||
let window = aContext.linkedBrowser.contentWindow;
|
||||
let nBox = aContext.ownerDocument.defaultView.
|
||||
getNotificationBox(window);
|
||||
let hudId = "hud_" + nBox.id;
|
||||
let displayNode = nBox.querySelector("#" + hudId);
|
||||
|
||||
if (hudId in this.displayRegistry && displayNode) {
|
||||
this.unregisterActiveContext(hudId);
|
||||
this.unregisterDisplay(hudId);
|
||||
this.unregisterDisplay(displayNode);
|
||||
window.focus();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -92,6 +92,7 @@ _BROWSER_TEST_FILES = \
|
||||
browser_webconsole_bug_583816_tab_focus.js \
|
||||
browser_webconsole_bug_594477_clickable_output.js \
|
||||
browser_webconsole_bug_589162_css_filter.js \
|
||||
browser_webconsole_bug_597103_deactivateHUDForContext_unfocused_window.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
||||
|
@ -0,0 +1,89 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mihai Șucan <mihai.sucan@gmail.com>
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const TEST_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-console.html";
|
||||
|
||||
let tab1, tab2, win1, win2;
|
||||
let noErrors = true;
|
||||
|
||||
function tab1Loaded(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
|
||||
win2 = OpenBrowserWindow();
|
||||
win2.addEventListener("load", win2Loaded, true);
|
||||
}
|
||||
|
||||
function win2Loaded(aEvent) {
|
||||
win2.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
|
||||
tab2 = win2.gBrowser.addTab();
|
||||
win2.gBrowser.selectedTab = tab2;
|
||||
tab2.linkedBrowser.addEventListener("load", tab2Loaded, true);
|
||||
tab2.linkedBrowser.contentWindow.location = TEST_URI;
|
||||
}
|
||||
|
||||
function tab2Loaded(aEvent) {
|
||||
tab2.linkedBrowser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
|
||||
waitForFocus(function() {
|
||||
try {
|
||||
HUDService.activateHUDForContext(tab1);
|
||||
}
|
||||
catch (ex) {
|
||||
ok(false, "HUDService.activateHUDForContext(tab1) exception: " + ex);
|
||||
noErrors = false;
|
||||
}
|
||||
|
||||
try {
|
||||
HUDService.activateHUDForContext(tab2);
|
||||
}
|
||||
catch (ex) {
|
||||
ok(false, "HUDService.activateHUDForContext(tab2) exception: " + ex);
|
||||
noErrors = false;
|
||||
}
|
||||
|
||||
try {
|
||||
HUDService.deactivateHUDForContext(tab1);
|
||||
}
|
||||
catch (ex) {
|
||||
ok(false, "HUDService.deactivateHUDForContext(tab1) exception: " + ex);
|
||||
noErrors = false;
|
||||
}
|
||||
|
||||
try {
|
||||
HUDService.deactivateHUDForContext(tab2);
|
||||
}
|
||||
catch (ex) {
|
||||
ok(false, "HUDService.deactivateHUDForContext(tab2) exception: " + ex);
|
||||
noErrors = false;
|
||||
}
|
||||
|
||||
if (noErrors) {
|
||||
ok(true, "there were no errors");
|
||||
}
|
||||
|
||||
win2.gBrowser.removeTab(tab2);
|
||||
|
||||
executeSoon(function() {
|
||||
win2.close();
|
||||
tab1 = tab2 = win1 = win2 = null;
|
||||
finishTest();
|
||||
});
|
||||
|
||||
}, tab2.linkedBrowser.contentWindow);
|
||||
}
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", tab1Loaded, true);
|
||||
tab1 = gBrowser.selectedTab;
|
||||
win1 = window;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user