Skip to content

Commit

Permalink
Bug 1632092 - Rename all XUL namespace variables to XUL_NS. r=Gijs,ma…
Browse files Browse the repository at this point in the history
…rionette-reviewers,whimboo

Differential Revision: https://phabricator.services.mozilla.com/D71913
  • Loading branch information
nt1m committed Apr 24, 2020
1 parent 3e14ed2 commit 5a254f3
Show file tree
Hide file tree
Showing 18 changed files with 49 additions and 76 deletions.
2 changes: 0 additions & 2 deletions browser/base/content/webext-panels.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const { ExtensionUtils } = ChromeUtils.import(

var { promiseEvent } = ExtensionUtils;

const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";

function getBrowser(panel) {
let browser = document.getElementById("webext-panels-browser");
if (browser) {
Expand Down
4 changes: 1 addition & 3 deletions browser/components/BrowserGlue.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ var EXPORTED_SYMBOLS = [
"DefaultBrowserCheck",
];

const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";

const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
Expand Down Expand Up @@ -2005,7 +2003,7 @@ BrowserGlue.prototype = {
let win = BrowserWindowTracker.getTopWindow();

let stack = win.gBrowser.getPanel().querySelector(".browserStack");
let mask = win.document.createElementNS(XULNS, "box");
let mask = win.document.createXULElement("box");
mask.setAttribute("id", "content-mask");
stack.appendChild(mask);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ add_task(async function() {
dummyBtn.setAttribute("removable", "true");
CustomizableUI.getCustomizationTarget(gNavBar).appendChild(dummyBtn);
let popupSet = document.getElementById("mainPopupSet");
gLazyArea = document.createElementNS(kNSXUL, "panel");
gLazyArea = document.createXULElement("panel");
gLazyArea.id = kLazyAreaId;
gLazyArea.setAttribute("hidden", "true");
popupSet.appendChild(gLazyArea);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ add_task(async function asyncCleanup() {
});

function setupArea() {
let lazyArea = document.createElementNS(kNSXUL, "hbox");
let lazyArea = document.createXULElement("hbox");
lazyArea.id = kLazyAreaId;
document.getElementById("nav-bar").appendChild(lazyArea);
CustomizableUI.registerArea(kLazyAreaId, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

const TOOLBARID = "test-noncustomizable-toolbar-for-toggling";
function test() {
let tb = document.createElementNS(kNSXUL, "toolbar");
let tb = document.createXULElement("toolbar");
tb.id = TOOLBARID;
gNavToolbox.appendChild(tb);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ add_task(async function() {
);

let otherWin = await openAndLoadWindow({}, true);
let otherTB = otherWin.document.createElementNS(kNSXUL, "toolbar");
let otherTB = otherWin.document.createXULElement("toolbar");
otherTB.id = TOOLBARID;
otherTB.setAttribute("customizable", "true");
let wasInformedCorrectlyOfAreaAppearing = false;
Expand Down
16 changes: 7 additions & 9 deletions browser/components/customizableui/test/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ registerCleanupFunction(() =>

var { synthesizeDrop, synthesizeMouseAtCenter } = EventUtils;

const kNSXUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";

const kForceOverflowWidthPx = 450;

function createDummyXULButton(id, label, win = window) {
let btn = win.document.createElementNS(kNSXUL, "toolbarbutton");
let btn = win.document.createXULElement("toolbarbutton");
btn.id = id;
btn.setAttribute("label", label || id);
btn.className = "toolbarbutton-1 chromeclass-toolbar-additional";
Expand All @@ -50,7 +48,7 @@ var gAddedToolbars = new Set();

function createToolbarWithPlacements(id, placements = []) {
gAddedToolbars.add(id);
let tb = document.createElementNS(kNSXUL, "toolbar");
let tb = document.createXULElement("toolbar");
tb.id = id;
tb.setAttribute("customizable", "true");
CustomizableUI.registerArea(id, {
Expand All @@ -65,24 +63,24 @@ function createToolbarWithPlacements(id, placements = []) {
function createOverflowableToolbarWithPlacements(id, placements) {
gAddedToolbars.add(id);

let tb = document.createElementNS(kNSXUL, "toolbar");
let tb = document.createXULElement("toolbar");
tb.id = id;
tb.setAttribute("customizationtarget", id + "-target");

let customizationtarget = document.createElementNS(kNSXUL, "hbox");
let customizationtarget = document.createXULElement("hbox");
customizationtarget.id = id + "-target";
customizationtarget.setAttribute("flex", "1");
tb.appendChild(customizationtarget);

let overflowPanel = document.createElementNS(kNSXUL, "panel");
let overflowPanel = document.createXULElement("panel");
overflowPanel.id = id + "-overflow";
document.getElementById("mainPopupSet").appendChild(overflowPanel);

let overflowList = document.createElementNS(kNSXUL, "vbox");
let overflowList = document.createXULElement("vbox");
overflowList.id = id + "-overflow-list";
overflowPanel.appendChild(overflowList);

let chevron = document.createElementNS(kNSXUL, "toolbarbutton");
let chevron = document.createXULElement("toolbarbutton");
chevron.id = id + "-chevron";
tb.appendChild(chevron);

Expand Down
4 changes: 2 additions & 2 deletions browser/components/sessionstore/SessionStore.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const TAB_EVENTS = [
"TabUnpinned",
];

const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";

/**
* When calling restoreTabContent, we can supply a reason why
Expand Down Expand Up @@ -1560,7 +1560,7 @@ var SessionStoreInternal = {
break;
case "XULFrameLoaderCreated":
if (
target.namespaceURI == NS_XUL &&
target.namespaceURI == XUL_NS &&
target.localName == "browser" &&
target.frameLoader &&
target.permanentKey
Expand Down
5 changes: 3 additions & 2 deletions dom/manifest/ManifestFinder.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ function isXULBrowser(aBrowser) {
if (!aBrowser || !aBrowser.namespaceURI || !aBrowser.localName) {
return false;
}
const XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
return aBrowser.namespaceURI === XUL && aBrowser.localName === "browser";
const XUL_NS =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
return aBrowser.namespaceURI === XUL_NS && aBrowser.localName === "browser";
}

function checkForManifest(aWindow) {
Expand Down
5 changes: 3 additions & 2 deletions dom/manifest/ManifestObtainer.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ function isXULBrowser(aBrowser) {
if (!aBrowser || !aBrowser.namespaceURI || !aBrowser.localName) {
return false;
}
const XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
return aBrowser.namespaceURI === XUL && aBrowser.localName === "browser";
const XUL_NS =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
return aBrowser.namespaceURI === XUL_NS && aBrowser.localName === "browser";
}

/**
Expand Down
1 change: 0 additions & 1 deletion dom/tests/browser/browser_test_new_window_from_content.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
each preference.
*/

const kXULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
const kContentDoc =
"http://www.example.com/browser/dom/tests/browser/test_new_window_from_content_child.html";
const kNewWindowPrefKey = "browser.link.open_newwindow";
Expand Down
13 changes: 6 additions & 7 deletions testing/marionette/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ const FIRST_ORDERED_NODE_TYPE = 9;
const ELEMENT_NODE = 1;
const DOCUMENT_NODE = 9;

const XBLNS = "http://www.mozilla.org/xbl";
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";

/** XUL elements that support checked property. */
const XUL_CHECKED_ELS = new Set(["button", "checkbox", "toolbarbutton"]);
Expand Down Expand Up @@ -1238,13 +1237,13 @@ element.isDOMElement = function(node) {
};

/**
* Ascertains whether <var>el</var> is a XUL- or XBL element.
* Ascertains whether <var>el</var> is a XUL element.
*
* @param {*} node
* Element thought to be a XUL- or XBL element.
* Element to check
*
* @return {boolean}
* True if <var>node</var> is a XULElement or XBLElement,
* True if <var>node</var> is a XULElement,
* false otherwise.
*/
element.isXULElement = function(node) {
Expand All @@ -1253,7 +1252,7 @@ element.isXULElement = function(node) {
node !== null &&
"nodeType" in node &&
node.nodeType === node.ELEMENT_NODE &&
[XBLNS, XULNS].includes(node.namespaceURI)
node.namespaceURI === XUL_NS
);
};

Expand Down Expand Up @@ -1610,7 +1609,7 @@ class ChromeWebElement extends WebElement {
if (!(ChromeWebElement.Identifier in json)) {
throw new InvalidArgumentError(
"Expected chrome element reference " +
pprint`for XUL/XBL element, got: ${json}`
pprint`for XUL element, got: ${json}`
);
}
let uuid = json[ChromeWebElement.Identifier];
Expand Down
22 changes: 6 additions & 16 deletions testing/marionette/test/unit/test_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ const { InvalidArgumentError } = ChromeUtils.import(
"chrome://marionette/content/error.js"
);

const SVGNS = "http://www.w3.org/2000/svg";
const XBLNS = "http://www.mozilla.org/xbl";
const XHTMLNS = "http://www.w3.org/1999/xhtml";
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
const SVG_NS = "http://www.w3.org/2000/svg";
const XHTML_NS = "http://www.w3.org/1999/xhtml";
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";

class Element {
constructor(tagName, attrs = {}) {
Expand Down Expand Up @@ -49,7 +48,7 @@ class DOMElement extends Element {
super(tagName, attrs);

if (typeof this.namespaceURI == "undefined") {
this.namespaceURI = XHTMLNS;
this.namespaceURI = XHTML_NS;
}
if (typeof this.ownerDocument == "undefined") {
this.ownerDocument = { designMode: "off" };
Expand Down Expand Up @@ -83,28 +82,20 @@ class DOMElement extends Element {
class SVGElement extends Element {
constructor(tagName, attrs = {}) {
super(tagName, attrs);
this.namespaceURI = SVGNS;
this.namespaceURI = SVG_NS;
}
}

class XULElement extends Element {
constructor(tagName, attrs = {}) {
super(tagName, attrs);
this.namespaceURI = XULNS;
}
}

class XBLElement extends XULElement {
constructor(tagName, attrs = {}) {
super(tagName, attrs);
this.namespaceURI = XBLNS;
this.namespaceURI = XUL_NS;
}
}

const domEl = new DOMElement("p");
const svgEl = new SVGElement("rect");
const xulEl = new XULElement("browser");
const xblEl = new XBLElement("framebox");

class WindowProxy {
get parent() {
Expand Down Expand Up @@ -192,7 +183,6 @@ add_test(function test_isDOMElement() {

add_test(function test_isXULElement() {
ok(element.isXULElement(xulEl));
ok(element.isXULElement(xblEl));
ok(!element.isXULElement(domEl));
ok(!element.isXULElement(svgEl));
ok(!element.isDOMElement(domWin));
Expand Down
22 changes: 6 additions & 16 deletions testing/marionette/test/unit/test_evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ const { evaluate } = ChromeUtils.import(
"chrome://marionette/content/evaluate.js"
);

const SVGNS = "http://www.w3.org/2000/svg";
const XBLNS = "http://www.mozilla.org/xbl";
const XHTMLNS = "http://www.w3.org/1999/xhtml";
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
const SVG_NS = "http://www.w3.org/2000/svg";
const XHTML_NS = "http://www.w3.org/1999/xhtml";
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";

class Element {
constructor(tagName, attrs = {}) {
Expand All @@ -31,35 +30,27 @@ class Element {
class DOMElement extends Element {
constructor(tagName, attrs = {}) {
super(tagName, attrs);
this.namespaceURI = XHTMLNS;
this.namespaceURI = XHTML_NS;
}
}

class SVGElement extends Element {
constructor(tagName, attrs = {}) {
super(tagName, attrs);
this.namespaceURI = SVGNS;
this.namespaceURI = SVG_NS;
}
}

class XULElement extends Element {
constructor(tagName, attrs = {}) {
super(tagName, attrs);
this.namespaceURI = XULNS;
}
}

class XBLElement extends XULElement {
constructor(tagName, attrs = {}) {
super(tagName, attrs);
this.namespaceURI = XBLNS;
this.namespaceURI = XUL_NS;
}
}

const domEl = new DOMElement("p");
const svgEl = new SVGElement("rect");
const xulEl = new XULElement("browser");
const xblEl = new XBLElement("framebox");

const seenEls = new element.Store();

Expand All @@ -80,7 +71,6 @@ add_test(function test_toJSON_types() {
ok(evaluate.toJSON(domEl, seenEls) instanceof WebElement);
ok(evaluate.toJSON(svgEl, seenEls) instanceof WebElement);
ok(evaluate.toJSON(xulEl, seenEls) instanceof WebElement);
ok(evaluate.toJSON(xblEl, seenEls) instanceof WebElement);

// toJSON
equal(
Expand Down
4 changes: 2 additions & 2 deletions toolkit/components/tooltiptext/TooltipTextProvider.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TooltipTextProvider.prototype = {
}

const XLinkNS = "http://www.w3.org/1999/xlink";
const XULNS =
const XUL_NS =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";

var titleText = null;
Expand Down Expand Up @@ -109,7 +109,7 @@ TooltipTextProvider.prototype = {
XULtooltiptextText == null
) {
if (tipElement.nodeType == defView.Node.ELEMENT_NODE) {
if (tipElement.namespaceURI == XULNS) {
if (tipElement.namespaceURI == XUL_NS) {
XULtooltiptextText = tipElement.hasAttribute("tooltiptext")
? tipElement.getAttribute("tooltiptext")
: null;
Expand Down
4 changes: 2 additions & 2 deletions toolkit/content/widgets/richlistbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,10 +935,10 @@
* nsIDOMXULSelectControlItemElement
*/
get label() {
const XULNS =
const XUL_NS =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
return Array.from(
this.getElementsByTagNameNS(XULNS, "label"),
this.getElementsByTagNameNS(XUL_NS, "label"),
label => label.value
).join(" ");
}
Expand Down
4 changes: 2 additions & 2 deletions toolkit/content/widgets/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@
return;
}
if (this.parentNode.parentNode.enableColumnDrag) {
var xulns =
var XUL_NS =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var cols = this.parentNode.getElementsByTagNameNS(xulns, "treecol");
var cols = this.parentNode.getElementsByTagNameNS(XUL_NS, "treecol");

// only start column drag operation if there are at least 2 visible columns
var visible = 0;
Expand Down
Loading

0 comments on commit 5a254f3

Please sign in to comment.