Bug 1392352 - Part 2 - Refer to the tabbrowser element as gBrowser instead of #content;
Since gBrowser is going to become a plain JS object instead of a DOM node,
we don't want any callers directly referring to the DOM node to get ahold of it.
MozReview-Commit-ID: KbE5dlTWmS
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -635,17 +635,16 @@
collapsed="true">
#ifdef CAN_DRAW_IN_TITLEBAR
<hbox class="titlebar-placeholder" type="pre-tabs"
skipintoolbarset="true"/>
#endif
<tabs id="tabbrowser-tabs"
- tabbrowser="content"
flex="1"
setfocus="false"
tooltip="tabbrowser-tab-tooltip"
stopwatchid="FX_TAB_CLICK_MS">
<tab class="tabbrowser-tab" selected="true" visuallyselected="true" fadein="true"/>
</tabs>
<toolbarbutton id="new-tab-button"
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -6449,17 +6449,17 @@
<destructor>
<![CDATA[
Services.prefs.removeObserver("privacy.userContext", this);
]]>
</destructor>
<field name="tabbrowser" readonly="true">
- document.getElementById(this.getAttribute("tabbrowser"));
+ gBrowser;
</field>
<field name="tabbox" readonly="true">
this.tabbrowser.tabbox;
</field>
<field name="contextMenu" readonly="true">
document.getElementById("tabContextMenu");
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1332,17 +1332,17 @@ BrowserGlue.prototype = {
let allWindowsPrivate = true;
while (browserEnum.hasMoreElements()) {
// XXXbz should we skip closed windows here?
windowcount++;
var browser = browserEnum.getNext();
if (!PrivateBrowsingUtils.isWindowPrivate(browser))
allWindowsPrivate = false;
- var tabbrowser = browser.document.getElementById("content");
+ var tabbrowser = browser.ownerGlobal.gBrowser;
if (tabbrowser)
pagecount += tabbrowser.browsers.length - tabbrowser._numPinnedTabs;
}
this._saveSession = false;
if (pagecount < 2)
return;
--- a/browser/modules/FormValidationHandler.jsm
+++ b/browser/modules/FormValidationHandler.jsm
@@ -73,17 +73,17 @@ var FormValidationHandler =
},
/*
* Internal
*/
_onPopupHiding(aEvent) {
aEvent.originalTarget.removeEventListener("popuphiding", this, true);
- let tabBrowser = aEvent.originalTarget.ownerDocument.getElementById("content");
+ let tabBrowser = aEvent.originalTarget.ownerGlobal.gBrowser;
tabBrowser.selectedBrowser.removeEventListener("scroll", this, true);
tabBrowser.selectedBrowser.removeEventListener("FullZoomChange", this);
tabBrowser.selectedBrowser.removeEventListener("TextZoomChange", this);
tabBrowser.selectedBrowser.removeEventListener("ZoomChangeUsingMouseWheel", this);
this._panel.hidden = true;
this._panel = null;
this._anchor.hidden = true;
--- a/devtools/client/framework/devtools-browser.js
+++ b/devtools/client/framework/devtools-browser.js
@@ -149,17 +149,17 @@ var gDevToolsBrowser = exports.gDevTools
devtoolsTheme = "light";
}
// Style gcli and the splitter between the toolbox and page content. This used to
// set the attribute on the browser's root node but that regressed tpaint:
// bug 1331449.
win.document.getElementById("browser-bottombox")
.setAttribute("devtoolstheme", devtoolsTheme);
- win.document.getElementById("content")
+ win.document.getElementById("appcontent")
.setAttribute("devtoolstheme", devtoolsTheme);
},
observe(subject, topic, prefName) {
switch (topic) {
case "browser-delayed-startup-finished":
this._registerBrowserWindow(subject);
break;
--- a/devtools/client/framework/test/browser_toolbox_theme.js
+++ b/devtools/client/framework/test/browser_toolbox_theme.js
@@ -10,23 +10,23 @@ registerCleanupFunction(() => {
Services.prefs.clearUserPref(PREF_DEVTOOLS_THEME);
});
add_task(function* testDevtoolsTheme() {
info("Checking stylesheet and :root attributes based on devtools theme.");
Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "light");
is(document.getElementById("browser-bottombox").getAttribute("devtoolstheme"), "light",
"The element has an attribute based on devtools theme.");
- is(document.getElementById("content").getAttribute("devtoolstheme"), "light",
+ is(document.getElementById("appcontent").getAttribute("devtoolstheme"), "light",
"The element has an attribute based on devtools theme.");
Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "dark");
is(document.getElementById("browser-bottombox").getAttribute("devtoolstheme"), "dark",
"The element has an attribute based on devtools theme.");
- is(document.getElementById("content").getAttribute("devtoolstheme"), "dark",
+ is(document.getElementById("appcontent").getAttribute("devtoolstheme"), "dark",
"The element has an attribute based on devtools theme.");
Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "firebug");
is(document.getElementById("browser-bottombox").getAttribute("devtoolstheme"), "light",
"The element has 'light' as a default for the devtoolstheme attribute.");
- is(document.getElementById("content").getAttribute("devtoolstheme"), "light",
+ is(document.getElementById("appcontent").getAttribute("devtoolstheme"), "light",
"The element has 'light' as a default for the devtoolstheme attribute.");
});
--- a/devtools/client/themes/splitters.css
+++ b/devtools/client/themes/splitters.css
@@ -15,22 +15,22 @@
--devtools-splitter-top-width: 2px;
--devtools-splitter-bottom-width: 2px;
/* Small draggable area on inline-start to avoid overlaps on scrollbars.*/
--devtools-splitter-inline-start-width: 1px;
--devtools-splitter-inline-end-width: 4px;
}
-#content[devtoolstheme="light"] {
+#appcontent[devtoolstheme="light"] {
/* These variables are used in browser.xul but inside the toolbox they are overridden by --theme-splitter-color */
--devtools-splitter-color: #dde1e4;
}
-#content[devtoolstheme="dark"] {
+#appcontent[devtoolstheme="dark"] {
--devtools-splitter-color: #42484f;
}
.devtools-horizontal-splitter,
.devtools-side-splitter {
-moz-appearance: none;
background-image: none;
border: 0;
--- a/testing/firefox-ui/tests/functional/safebrowsing/test_notification.py
+++ b/testing/firefox-ui/tests/functional/safebrowsing/test_notification.py
@@ -110,46 +110,46 @@ class TestSafeBrowsingNotificationBar(Pu
# Clean up here since the permission gets set in this function
self.puppeteer.utils.permissions.remove('https://www.itisatrap.org', 'safe-browsing')
# Check the not a forgery or attack button in the notification bar
def check_not_badware_button(self, button_property, report_page):
with self.marionette.using_context('chrome'):
# TODO: update to use safe browsing notification bar class when bug 1139544 lands
label = self.browser.localize_property(button_property)
- button = (self.marionette.find_element(By.ID, 'content')
+ button = (self.marionette.find_element(By.TAG_NAME, 'tabbrowser')
.find_element('anon attribute', {'label': label}))
self.browser.tabbar.open_tab(lambda _: button.click())
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
lambda mn: report_page in mn.get_url(),
message='The expected safe-browsing report page has not been opened',
)
with self.marionette.using_context('chrome'):
self.browser.tabbar.close_tab()
def check_get_me_out_of_here_button(self):
with self.marionette.using_context('chrome'):
# TODO: update to use safe browsing notification bar class when bug 1139544 lands
label = self.browser.localize_property('safebrowsing.getMeOutOfHereButton.label')
- button = (self.marionette.find_element(By.ID, 'content')
+ button = (self.marionette.find_element(By.TAG_NAME, 'tabbrowser')
.find_element('anon attribute', {'label': label}))
button.click()
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
lambda mn: self.browser.default_homepage in mn.get_url(),
message='The default home page has not been loaded',
)
def check_x_button(self):
with self.marionette.using_context('chrome'):
# TODO: update to use safe browsing notification bar class when bug 1139544 lands
- button = (self.marionette.find_element(By.ID, 'content')
+ button = (self.marionette.find_element(By.TAG_NAME, 'tabbrowser')
.find_element('anon attribute', {'value': 'blocked-badware-page'})
.find_element('anon attribute',
{'class': 'messageCloseButton close-icon tabbable'}))
button.click()
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
expected.element_stale(button),
message='The notification bar has not been closed',
--- a/testing/mochitest/tests/SimpleTest/SimpleTest.js
+++ b/testing/mochitest/tests/SimpleTest/SimpleTest.js
@@ -878,17 +878,17 @@ SimpleTest.waitForFocus = function (call
}
var isWrapper = Cu.isCrossProcessWrapper(targetWindow);
if (isWrapper || (browser && browser.isRemoteBrowser)) {
var mustFocusSubframe = false;
if (isWrapper) {
// Look for a tabbrowser and see if targetWindow corresponds to one
// within that tabbrowser. If not, just return.
- var tabBrowser = document.getElementsByTagName("tabbrowser")[0] || null;
+ var tabBrowser = window.gBrowser || null;
browser = tabBrowser ? tabBrowser.getBrowserForContentWindow(targetWindow.top) : null;
if (!browser) {
SimpleTest.info("child process window cannot be focused");
return;
}
mustFocusSubframe = (targetWindow != targetWindow.top);
}
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -405,19 +405,20 @@
return this._webBrowserFind;
]]>
</getter>
</property>
<method name="getTabBrowser">
<body>
<![CDATA[
- for (let node = this.parentNode; node instanceof Element; node = node.parentNode) {
- if (node.localName == "tabbrowser")
- return node;
+ if (this.ownerGlobal.gBrowser &&
+ this.ownerGlobal.gBrowser.getTabForBrowser &&
+ this.ownerGlobal.gBrowser.getTabForBrowser(this)) {
+ return this.ownerGlobal.gBrowser;
}
return null;
]]>
</body>
</method>
<field name="_finder">null</field>