Bug 232598 - Return null for unset attributes in XUL. r=smaug,devtools-reviewers,omc-reviewers,zombie,nchevobbe,settings-reviewers,application-update-reviewers,credential-management-reviewers,mossop,aminomancer,bytesized,issammani,sessionstore-reviewers,dao

I just got bit by this in bug 1873833, let's just fix it. There isn't
all that much stuff depending on it anymore.

Differential Revision: https://phabricator.services.mozilla.com/D204496
This commit is contained in:
Emilio Cobos Álvarez 2024-03-18 09:15:07 +00:00
parent e7f43ecf6f
commit 0e321f79be
64 changed files with 188 additions and 177 deletions

View file

@ -8658,7 +8658,7 @@ function switchToTabHavingURI(
ignoreQueryString || replaceQueryString, ignoreQueryString || replaceQueryString,
ignoreFragmentWhenComparing ignoreFragmentWhenComparing
); );
let browserUserContextId = browser.getAttribute("usercontextid"); let browserUserContextId = browser.getAttribute("usercontextid") || "";
if (aUserContextId != null && aUserContextId != browserUserContextId) { if (aUserContextId != null && aUserContextId != browserUserContextId) {
continue; continue;
} }

View file

@ -28,7 +28,7 @@ add_task(async () => {
is(browser.mIconURL, null, "Should have blanked the icon."); is(browser.mIconURL, null, "Should have blanked the icon.");
is( is(
gBrowser.getTabForBrowser(browser).getAttribute("image"), gBrowser.getTabForBrowser(browser).getAttribute("image"),
"", null,
"Should have blanked the tab icon." "Should have blanked the tab icon."
); );
} }

View file

@ -244,12 +244,12 @@ async function assertMixedContentBlockingState(tabbrowser, states = {}) {
); );
gIdentityHandler._identityIconBox.click(); gIdentityHandler._identityIconBox.click();
await promisePanelOpen; await promisePanelOpen;
let popupAttr = doc let popupAttr =
.getElementById("identity-popup") doc.getElementById("identity-popup").getAttribute("mixedcontent") || "";
.getAttribute("mixedcontent"); let bodyAttr =
let bodyAttr = doc doc
.getElementById("identity-popup-securityView-extended-info") .getElementById("identity-popup-securityView-extended-info")
.getAttribute("mixedcontent"); .getAttribute("mixedcontent") || "";
is( is(
popupAttr.includes("active-loaded"), popupAttr.includes("active-loaded"),

View file

@ -772,7 +772,7 @@ function checkSyncNowButtons(syncing, tooltip = null) {
for (const syncButton of syncButtons) { for (const syncButton of syncButtons) {
is( is(
syncButton.getAttribute("syncstatus"), syncButton.getAttribute("syncstatus"),
syncing ? "active" : "", syncing ? "active" : null,
"button active has the right value" "button active has the right value"
); );
if (tooltip) { if (tooltip) {

View file

@ -119,7 +119,7 @@ async function waitForDialog(doConfirmPrompt, crossDomain, prefEnabled) {
} else { } else {
Assert.equal( Assert.equal(
dialog._overlay.getAttribute("hideContent"), dialog._overlay.getAttribute("hideContent"),
"", null,
"Dialog overlay does not hide the current sites content" "Dialog overlay does not hide the current sites content"
); );
Assert.equal( Assert.equal(
@ -137,7 +137,7 @@ async function waitForDialog(doConfirmPrompt, crossDomain, prefEnabled) {
} else { } else {
Assert.equal( Assert.equal(
dialog._overlay.getAttribute("hideContent"), dialog._overlay.getAttribute("hideContent"),
"", null,
"Dialog overlay does not hide the current sites content" "Dialog overlay does not hide the current sites content"
); );
Assert.equal( Assert.equal(

View file

@ -93,10 +93,10 @@ add_task(async function test_hidden_muted_lazy_tabs_and_swapping() {
mutedTab.toggleMuteAudio(); mutedTab.toggleMuteAudio();
gBrowser.hideTab(hiddenTab); gBrowser.hideTab(hiddenTab);
is(lazyTab.linkedPanel, "", "lazyTab is lazy"); is(lazyTab.linkedPanel, null, "lazyTab is lazy");
is(hiddenTab.linkedPanel, "", "hiddenTab is lazy"); is(hiddenTab.linkedPanel, null, "hiddenTab is lazy");
is(mutedTab.linkedPanel, "", "mutedTab is lazy"); is(mutedTab.linkedPanel, null, "mutedTab is lazy");
is(normalTab.linkedPanel, "", "normalTab is lazy"); is(normalTab.linkedPanel, null, "normalTab is lazy");
ok(mutedTab.linkedBrowser.audioMuted, "mutedTab is muted"); ok(mutedTab.linkedBrowser.audioMuted, "mutedTab is muted");
ok(hiddenTab.hidden, "hiddenTab is hidden"); ok(hiddenTab.hidden, "hiddenTab is hidden");
@ -117,7 +117,7 @@ add_task(async function test_hidden_muted_lazy_tabs_and_swapping() {
}); });
gBrowser.swapBrowsersAndCloseOther(lazyTab, mutedTab); gBrowser.swapBrowsersAndCloseOther(lazyTab, mutedTab);
tabEventTracker.checkExpectations(); tabEventTracker.checkExpectations();
is(lazyTab.linkedPanel, "", "muted lazyTab is still lazy"); is(lazyTab.linkedPanel, null, "muted lazyTab is still lazy");
ok(lazyTab.linkedBrowser.audioMuted, "muted lazyTab is now muted"); ok(lazyTab.linkedBrowser.audioMuted, "muted lazyTab is now muted");
ok(!lazyTab.hidden, "muted lazyTab is not hidden"); ok(!lazyTab.hidden, "muted lazyTab is not hidden");
@ -133,7 +133,7 @@ add_task(async function test_hidden_muted_lazy_tabs_and_swapping() {
}); });
gBrowser.swapBrowsersAndCloseOther(lazyTab, hiddenTab); gBrowser.swapBrowsersAndCloseOther(lazyTab, hiddenTab);
tabEventTracker.checkExpectations(); tabEventTracker.checkExpectations();
is(lazyTab.linkedPanel, "", "hidden lazyTab is still lazy"); is(lazyTab.linkedPanel, null, "hidden lazyTab is still lazy");
ok(!lazyTab.linkedBrowser.audioMuted, "hidden lazyTab is not muted any more"); ok(!lazyTab.linkedBrowser.audioMuted, "hidden lazyTab is not muted any more");
ok(lazyTab.hidden, "hidden lazyTab has been hidden"); ok(lazyTab.hidden, "hidden lazyTab has been hidden");
@ -149,7 +149,7 @@ add_task(async function test_hidden_muted_lazy_tabs_and_swapping() {
}); });
gBrowser.swapBrowsersAndCloseOther(lazyTab, normalTab); gBrowser.swapBrowsersAndCloseOther(lazyTab, normalTab);
tabEventTracker.checkExpectations(); tabEventTracker.checkExpectations();
is(lazyTab.linkedPanel, "", "normal lazyTab is still lazy"); is(lazyTab.linkedPanel, null, "normal lazyTab is still lazy");
ok(!lazyTab.linkedBrowser.audioMuted, "normal lazyTab is not muted any more"); ok(!lazyTab.linkedBrowser.audioMuted, "normal lazyTab is not muted any more");
ok(!lazyTab.hidden, "normal lazyTab is not hidden any more"); ok(!lazyTab.hidden, "normal lazyTab is not hidden any more");

View file

@ -61,9 +61,9 @@ add_task(async function testLazyTabs() {
await triggerClickOn(oldTabs[i], { ctrlKey: true }); await triggerClickOn(oldTabs[i], { ctrlKey: true });
} }
isnot(oldTabs[0].linkedPanel, "", `Old tab 0 shouldn't be lazy`); isnot(oldTabs[0].linkedPanel, null, `Old tab 0 shouldn't be lazy`);
for (let i = 1; i < numTabs; ++i) { for (let i = 1; i < numTabs; ++i) {
is(oldTabs[i].linkedPanel, "", `Old tab ${i} should be lazy`); is(oldTabs[i].linkedPanel, null, `Old tab ${i} should be lazy`);
} }
is(gBrowser.multiSelectedTabsCount, numTabs, `${numTabs} multiselected tabs`); is(gBrowser.multiSelectedTabsCount, numTabs, `${numTabs} multiselected tabs`);
@ -79,11 +79,11 @@ add_task(async function testLazyTabs() {
if (i == 0) { if (i == 0) {
isnot( isnot(
oldTab.linkedPanel, oldTab.linkedPanel,
"", null,
`Old tab ${i} should continue not being lazy` `Old tab ${i} should continue not being lazy`
); );
} else if (i > 0) { } else if (i > 0) {
is(oldTab.linkedPanel, "", `Old tab ${i} should continue being lazy`); is(oldTab.linkedPanel, null, `Old tab ${i} should continue being lazy`);
} else { } else {
return; return;
} }
@ -101,9 +101,13 @@ add_task(async function testLazyTabs() {
await tabsMoved; await tabsMoved;
let newTabs = newWindow.gBrowser.tabs; let newTabs = newWindow.gBrowser.tabs;
isnot(newTabs[0].linkedPanel, "", `New tab 0 should continue not being lazy`); isnot(
newTabs[0].linkedPanel,
null,
`New tab 0 should continue not being lazy`
);
for (let i = 1; i < numTabs; ++i) { for (let i = 1; i < numTabs; ++i) {
is(newTabs[i].linkedPanel, "", `New tab ${i} should continue being lazy`); is(newTabs[i].linkedPanel, null, `New tab ${i} should continue being lazy`);
} }
is( is(

View file

@ -12,7 +12,7 @@ function test() {
is( is(
elemAttr("key_close", "disabled"), elemAttr("key_close", "disabled"),
"", null,
"key_closed should always be enabled" "key_closed should always be enabled"
); );
is( is(

View file

@ -57,7 +57,7 @@ add_task(async function () {
); );
is( is(
tooltip.getAttribute("position"), tooltip.getAttribute("position"),
"", null,
"tooltip position attribute for tab" "tooltip position attribute for tab"
); );

View file

@ -87,7 +87,7 @@ async function backgroundUpdateTest(url, id, checkIconFn) {
let addonId = addon.id; let addonId = addon.id;
ok(addon, "Addon was installed"); ok(addon, "Addon was installed");
is(getBadgeStatus(), "", "Should not start out with an addon alert badge"); is(getBadgeStatus(), null, "Should not start out with an addon alert badge");
// Trigger an update check and wait for the update for this addon // Trigger an update check and wait for the update for this addon
// to be downloaded. // to be downloaded.
@ -156,7 +156,7 @@ async function backgroundUpdateTest(url, id, checkIconFn) {
BrowserTestUtils.removeTab(tab); BrowserTestUtils.removeTab(tab);
// Alert badge and hamburger menu items should be gone // Alert badge and hamburger menu items should be gone
is(getBadgeStatus(), "", "Addon alert badge should be gone"); is(getBadgeStatus(), null, "Addon alert badge should be gone");
await gCUITestUtils.openMainMenu(); await gCUITestUtils.openMainMenu();
addons = PanelUI.addonNotificationContainer; addons = PanelUI.addonNotificationContainer;
@ -205,7 +205,7 @@ async function backgroundUpdateTest(url, id, checkIconFn) {
BrowserTestUtils.removeTab(tab); BrowserTestUtils.removeTab(tab);
is(getBadgeStatus(), "", "Addon alert badge should be gone"); is(getBadgeStatus(), null, "Addon alert badge should be gone");
await addon.uninstall(); await addon.uninstall();
await SpecialPowers.popPrefEnv(); await SpecialPowers.popPrefEnv();

View file

@ -81,7 +81,7 @@ async function testNoPrompt(origUrl, id) {
await updatePromise; await updatePromise;
// There should be no notifications about the update // There should be no notifications about the update
is(getBadgeStatus(), "", "Should not have addon alert badge"); is(getBadgeStatus(), null, "Should not have addon alert badge");
await gCUITestUtils.openMainMenu(); await gCUITestUtils.openMainMenu();
let addons = PanelUI.addonNotificationContainer; let addons = PanelUI.addonNotificationContainer;

View file

@ -58,7 +58,7 @@ var gTests = [
); );
is( is(
gBrowser.selectedTab.getAttribute("sharing"), gBrowser.selectedTab.getAttribute("sharing"),
"", null,
"the new tab doesn't have the 'sharing' attribute" "the new tab doesn't have the 'sharing' attribute"
); );
is( is(
@ -89,7 +89,7 @@ var gTests = [
await TestUtils.waitForCondition(() => !tab.getAttribute("sharing")); await TestUtils.waitForCondition(() => !tab.getAttribute("sharing"));
is( is(
tab.getAttribute("sharing"), tab.getAttribute("sharing"),
"", null,
"the tab no longer has the 'sharing' attribute after closing the stream" "the tab no longer has the 'sharing' attribute after closing the stream"
); );
} }

View file

@ -294,7 +294,7 @@ function closeMenus(node) {
* to check if the close command key was pressed in aEvent. * to check if the close command key was pressed in aEvent.
*/ */
function eventMatchesKey(aEvent, aKey) { function eventMatchesKey(aEvent, aKey) {
let keyPressed = aKey.getAttribute("key").toLowerCase(); let keyPressed = (aKey.getAttribute("key") || "").toLowerCase();
let keyModifiers = aKey.getAttribute("modifiers"); let keyModifiers = aKey.getAttribute("modifiers");
let modifiers = ["Alt", "Control", "Meta", "Shift"]; let modifiers = ["Alt", "Control", "Meta", "Shift"];
@ -341,7 +341,7 @@ function gatherTextUnder(root) {
} else if (HTMLImageElement.isInstance(node)) { } else if (HTMLImageElement.isInstance(node)) {
// If it has an "alt" attribute, add that. // If it has an "alt" attribute, add that.
var altText = node.getAttribute("alt"); var altText = node.getAttribute("alt");
if (altText && altText != "") { if (altText) {
text += " " + altText; text += " " + altText;
} }
} }

View file

@ -35,7 +35,7 @@ add_task(async function () {
createLazyBrowser: true, createLazyBrowser: true,
}); });
Assert.equal(lazyTab.linkedPanel, "", "Tab is lazy"); Assert.equal(lazyTab.linkedPanel, null, "Tab is lazy");
let tabLoaded = new Promise(resolve => { let tabLoaded = new Promise(resolve => {
gBrowser.addTabsProgressListener({ gBrowser.addTabsProgressListener({
async onLocationChange(aBrowser) { async onLocationChange(aBrowser) {

View file

@ -93,7 +93,7 @@ add_task(async function test() {
openURIFromExternal(HOST_EXAMPLE.spec + "?new"); openURIFromExternal(HOST_EXAMPLE.spec + "?new");
is( is(
gBrowser.selectedTab.getAttribute("usercontextid"), gBrowser.selectedTab.getAttribute("usercontextid"),
"", null,
"opener flow with default user context ID forced by pref" "opener flow with default user context ID forced by pref"
); );
}); });

View file

@ -549,7 +549,7 @@ add_task(async function custom_context_menus() {
await startCustomizing(); await startCustomizing();
is( is(
widget.getAttribute("context"), widget.getAttribute("context"),
"", null,
"Should not have own context menu in the toolbar now that we're customizing." "Should not have own context menu in the toolbar now that we're customizing."
); );
is( is(
@ -562,7 +562,7 @@ add_task(async function custom_context_menus() {
simulateItemDrag(widget, panel); simulateItemDrag(widget, panel);
is( is(
widget.getAttribute("context"), widget.getAttribute("context"),
"", null,
"Should not have own context menu when in the panel." "Should not have own context menu when in the panel."
); );
is( is(
@ -577,7 +577,7 @@ add_task(async function custom_context_menus() {
); );
is( is(
widget.getAttribute("context"), widget.getAttribute("context"),
"", null,
"Should not have own context menu when back in toolbar because we're still customizing." "Should not have own context menu when back in toolbar because we're still customizing."
); );
is( is(

View file

@ -9,7 +9,7 @@ add_task(async function open_customize_mode_in_lazy_tab() {
}); });
gCustomizeMode.setTab(tab); gCustomizeMode.setTab(tab);
is(tab.linkedPanel, "", "Tab should be lazy"); is(tab.linkedPanel, null, "Tab should be lazy");
let title = gNavigatorBundle.getFormattedString("customizeMode.tabTitle", [ let title = gNavigatorBundle.getFormattedString("customizeMode.tabTitle", [
document.getElementById("bundle_brand").getString("brandShortName"), document.getElementById("bundle_brand").getString("brandShortName"),

View file

@ -378,7 +378,7 @@ add_task(async function () {
// There is a single node saying there's no tabs for the client. // There is a single node saying there's no tabs for the client.
node = node.nextElementSibling; node = node.nextElementSibling;
is(node.nodeName, "label", "node is a label"); is(node.nodeName, "label", "node is a label");
is(node.getAttribute("itemtype"), "", "node is neither a tab nor a client"); is(node.getAttribute("itemtype"), null, "node is neither a tab nor a client");
node = node.nextElementSibling; node = node.nextElementSibling;
is(node, null, "no more siblings"); is(node, null, "no more siblings");

View file

@ -184,7 +184,11 @@ async function runTests(options) {
is(getListStyleImage(button), details.icon, "icon URL is correct"); is(getListStyleImage(button), details.icon, "icon URL is correct");
is(button.getAttribute("tooltiptext"), title, "image title is correct"); is(button.getAttribute("tooltiptext"), title, "image title is correct");
is(button.getAttribute("label"), title, "image label is correct"); is(button.getAttribute("label"), title, "image label is correct");
is(button.getAttribute("badge"), details.badge, "badge text is correct"); is(
button.getAttribute("badge") || "",
details.badge,
"badge text is correct"
);
is( is(
button.getAttribute("disabled") == "true", button.getAttribute("disabled") == "true",
!details.enabled, !details.enabled,

View file

@ -269,7 +269,7 @@ add_task(async function test_manifest_without_icons() {
let items = menu.getElementsByAttribute("label", "first item"); let items = menu.getElementsByAttribute("label", "first item");
is(items.length, 1, "Found first item"); is(items.length, 1, "Found first item");
// manifest.json does not declare icons, so the root menu item shouldn't have an icon either. // manifest.json does not declare icons, so the root menu item shouldn't have an icon either.
is(items[0].getAttribute("image"), "", "Root menu must not have an icon"); is(items[0].getAttribute("image"), null, "Root menu must not have an icon");
await closeExtensionContextMenu(items[0]); await closeExtensionContextMenu(items[0]);
await extension.awaitMessage("added-second-item"); await extension.awaitMessage("added-second-item");
@ -281,7 +281,7 @@ add_task(async function test_manifest_without_icons() {
is(items.length, 1, "Auto-generated root item exists"); is(items.length, 1, "Auto-generated root item exists");
is( is(
items[0].getAttribute("image"), items[0].getAttribute("image"),
"", null,
"Auto-generated menu root must not have an icon" "Auto-generated menu root must not have an icon"
); );
@ -464,7 +464,7 @@ add_task(async function test_child_icon_update() {
contextMenuChild2 = contextMenu.getElementsByAttribute("label", "child2")[0]; contextMenuChild2 = contextMenu.getElementsByAttribute("label", "child2")[0];
is( is(
contextMenuChild2.getAttribute("image"), contextMenuChild2.getAttribute("image"),
"", null,
"Second child should not have an icon" "Second child should not have an icon"
); );

View file

@ -1168,7 +1168,7 @@ var ViewMenu = {
menuitem.setAttribute("type", "radio"); menuitem.setAttribute("type", "radio");
menuitem.setAttribute("name", "columns"); menuitem.setAttribute("name", "columns");
// This column is the sort key. Its item is checked. // This column is the sort key. Its item is checked.
if (column.getAttribute("sortDirection") != "") { if (column.hasAttribute("sortDirection")) {
menuitem.setAttribute("checked", "true"); menuitem.setAttribute("checked", "true");
} }
} else if (type == "checkbox") { } else if (type == "checkbox") {

View file

@ -131,14 +131,14 @@ let checkContextMenu = async (cbfunc, optionItems, doc = document) => {
if (expectedOptionItems.includes("placesContext_open")) { if (expectedOptionItems.includes("placesContext_open")) {
Assert.equal( Assert.equal(
doc.getElementById("placesContext_open").getAttribute("default"), doc.getElementById("placesContext_open").getAttribute("default"),
loadBookmarksInNewTab ? "" : "true", loadBookmarksInNewTab ? null : "true",
`placesContext_open has the correct "default" attribute when loadBookmarksInTabs = ${loadBookmarksInNewTab}` `placesContext_open has the correct "default" attribute when loadBookmarksInTabs = ${loadBookmarksInNewTab}`
); );
} }
if (expectedOptionItems.includes("placesContext_open:newtab")) { if (expectedOptionItems.includes("placesContext_open:newtab")) {
Assert.equal( Assert.equal(
doc.getElementById("placesContext_open:newtab").getAttribute("default"), doc.getElementById("placesContext_open:newtab").getAttribute("default"),
loadBookmarksInNewTab ? "true" : "", loadBookmarksInNewTab ? "true" : null,
`placesContext_open:newtab has the correct "default" attribute when loadBookmarksInTabs = ${loadBookmarksInNewTab}` `placesContext_open:newtab has the correct "default" attribute when loadBookmarksInTabs = ${loadBookmarksInNewTab}`
); );
} }

View file

@ -72,7 +72,11 @@ function checkPanelClosed() {
let pocketButton = document.getElementById("save-to-pocket-button"); let pocketButton = document.getElementById("save-to-pocket-button");
// Something should have closed the Pocket panel, icon should no longer be red. // Something should have closed the Pocket panel, icon should no longer be red.
is(pocketButton.open, false, "Pocket button is closed"); is(pocketButton.open, false, "Pocket button is closed");
is(pocketButton.getAttribute("pocketed"), "", "Pocket item is not pocketed"); is(
pocketButton.getAttribute("pocketed"),
null,
"Pocket item is not pocketed"
);
} }
test_runner(async function test_pocketButtonState_changeTabs({ sandbox }) { test_runner(async function test_pocketButtonState_changeTabs({ sandbox }) {

View file

@ -335,10 +335,12 @@ add_task(async function sortingCheck() {
"Number of items should not change." "Number of items should not change."
); );
for (let i = 0; i < siteItems.length - 1; ++i) { for (let i = 0; i < siteItems.length - 1; ++i) {
let aType = siteItems[i].getAttribute("actionDescription").toLowerCase(); let aType = (
let bType = siteItems[i + 1] siteItems[i].getAttribute("actionDescription") || ""
.getAttribute("actionDescription") ).toLowerCase();
.toLowerCase(); let bType = (
siteItems[i + 1].getAttribute("actionDescription") || ""
).toLowerCase();
let result = 0; let result = 0;
if (aType > bType) { if (aType > bType) {
result = 1; result = 1;
@ -375,10 +377,12 @@ add_task(async function sortingCheck() {
"Number of items should not change." "Number of items should not change."
); );
for (let i = 0; i < siteItems.length - 1; ++i) { for (let i = 0; i < siteItems.length - 1; ++i) {
let aType = siteItems[i].getAttribute("typeDescription").toLowerCase(); let aType = (
let bType = siteItems[i + 1] siteItems[i].getAttribute("typeDescription") || ""
.getAttribute("typeDescription") ).toLowerCase();
.toLowerCase(); let bType = (
siteItems[i + 1].getAttribute("typeDescription") || ""
).toLowerCase();
let result = 0; let result = 0;
if (aType > bType) { if (aType > bType) {
result = 1; result = 1;

View file

@ -1021,7 +1021,7 @@ add_task(async function testDisableTPCheckBoxDisablesEmailTP() {
// Verify the checkbox is unchecked after clicking. // Verify the checkbox is unchecked after clicking.
is( is(
tpCheckbox.getAttribute("checked"), tpCheckbox.getAttribute("checked"),
"", null,
"Tracking protection checkbox is unchecked" "Tracking protection checkbox is unchecked"
); );

View file

@ -173,7 +173,7 @@ async function close_subdialog_and_test_generic_end_state(
); );
Assert.equal( Assert.equal(
frame.getAttribute("style"), frame.getAttribute("style"),
"", null,
"inline styles should be cleared" "inline styles should be cleared"
); );
Assert.equal( Assert.equal(

View file

@ -3635,7 +3635,7 @@ var SessionStoreInternal = {
} }
// Create a new tab. // Create a new tab.
let userContextId = aTab.getAttribute("usercontextid"); let userContextId = aTab.getAttribute("usercontextid") || "";
let tabOptions = { let tabOptions = {
userContextId, userContextId,

View file

@ -14,7 +14,7 @@ add_task(async function () {
await promiseBrowserLoaded(browser); await promiseBrowserLoaded(browser);
let tab2 = gBrowser.duplicateTab(tab); let tab2 = gBrowser.duplicateTab(tab);
Assert.equal(tab2.getAttribute("usercontextid"), i); Assert.equal(tab2.getAttribute("usercontextid") || "", i);
let browser2 = tab2.linkedBrowser; let browser2 = tab2.linkedBrowser;
await promiseTabRestored(tab2); await promiseTabRestored(tab2);

View file

@ -81,7 +81,7 @@ add_UITour_task(async function test_info_buttons_1() {
); );
is( is(
buttons.children[0].getAttribute("image"), buttons.children[0].getAttribute("image"),
"", null,
"Text should have no image" "Text should have no image"
); );
is(buttons.children[0].className, "", "Text should have no class"); is(buttons.children[0].className, "", "Text should have no class");
@ -94,7 +94,7 @@ add_UITour_task(async function test_info_buttons_1() {
); );
is( is(
buttons.children[1].getAttribute("image"), buttons.children[1].getAttribute("image"),
"", null,
"Link should have no image" "Link should have no image"
); );
is(buttons.children[1].className, "button-link", "Check link class"); is(buttons.children[1].className, "button-link", "Check link class");
@ -107,7 +107,7 @@ add_UITour_task(async function test_info_buttons_1() {
); );
is( is(
buttons.children[2].getAttribute("image"), buttons.children[2].getAttribute("image"),
"", null,
"First button should have no image" "First button should have no image"
); );
is(buttons.children[2].className, "", "Button 1 should have no class"); is(buttons.children[2].className, "", "Button 1 should have no class");
@ -173,7 +173,7 @@ add_UITour_task(async function test_info_buttons_2() {
); );
is( is(
buttons.children[1].getAttribute("image"), buttons.children[1].getAttribute("image"),
"", null,
"Link should have no image" "Link should have no image"
); );
ok( ok(
@ -188,7 +188,7 @@ add_UITour_task(async function test_info_buttons_2() {
); );
is( is(
buttons.children[2].getAttribute("image"), buttons.children[2].getAttribute("image"),
"", null,
"First button should have no image" "First button should have no image"
); );

View file

@ -2,7 +2,7 @@
* http://creativecommons.org/publicdomain/zero/1.0/ * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
async function testVal(aExpected, overflowSide = "") { async function testVal(aExpected, overflowSide = null) {
info(`Testing ${aExpected}`); info(`Testing ${aExpected}`);
try { try {
gURLBar.setURI(makeURI(aExpected)); gURLBar.setURI(makeURI(aExpected));

View file

@ -276,7 +276,7 @@ async function typeAndCommand(eventType, details = {}) {
async function triggerCommand(eventType, details = {}) { async function triggerCommand(eventType, details = {}) {
Assert.equal( Assert.equal(
await UrlbarTestUtils.promiseUserContextId(window), await UrlbarTestUtils.promiseUserContextId(window),
gBrowser.selectedTab.getAttribute("usercontextid"), gBrowser.selectedTab.getAttribute("usercontextid") || "",
"userContextId must be the same as the originating tab" "userContextId must be the same as the originating tab"
); );

View file

@ -11,7 +11,7 @@ var gItemsToTest = {
}; };
function expectedAttributeValueFromPrefs(prefs) { function expectedAttributeValueFromPrefs(prefs) {
return prefs.every(pref => Services.prefs.getBoolPref(pref)) ? "" : "true"; return prefs.every(pref => Services.prefs.getBoolPref(pref)) ? null : "true";
} }
function checkItem(el, prefs) { function checkItem(el, prefs) {

View file

@ -19,7 +19,7 @@ add_task(async function () {
); );
is( is(
tab.linkedBrowser.getAttribute("remote"), tab.linkedBrowser.getAttribute("remote"),
"", null,
"And running in parent process" "And running in parent process"
); );

View file

@ -88,12 +88,12 @@ add_task(async function () {
cmdCopy = searchContextMenu.querySelector("#editmenu-copy"); cmdCopy = searchContextMenu.querySelector("#editmenu-copy");
cmdPaste = searchContextMenu.querySelector("#editmenu-paste"); cmdPaste = searchContextMenu.querySelector("#editmenu-paste");
is(cmdUndo.getAttribute("disabled"), "", "cmdUndo is enabled"); is(cmdUndo.getAttribute("disabled"), null, "cmdUndo is enabled");
is(cmdDelete.getAttribute("disabled"), "", "cmdDelete is enabled"); is(cmdDelete.getAttribute("disabled"), null, "cmdDelete is enabled");
is(cmdSelectAll.getAttribute("disabled"), "", "cmdSelectAll is enabled"); is(cmdSelectAll.getAttribute("disabled"), null, "cmdSelectAll is enabled");
is(cmdCut.getAttribute("disabled"), "", "cmdCut is enabled"); is(cmdCut.getAttribute("disabled"), null, "cmdCut is enabled");
is(cmdCopy.getAttribute("disabled"), "", "cmdCopy is enabled"); is(cmdCopy.getAttribute("disabled"), null, "cmdCopy is enabled");
is(cmdPaste.getAttribute("disabled"), "", "cmdPaste is enabled"); is(cmdPaste.getAttribute("disabled"), null, "cmdPaste is enabled");
onContextMenuClose = toolbox.once("menu-close"); onContextMenuClose = toolbox.once("menu-close");
searchContextMenu.hidePopup(); searchContextMenu.hidePopup();

View file

@ -86,12 +86,12 @@ add_task(async function () {
cmdCopy = searchContextMenu.querySelector("#editmenu-copy"); cmdCopy = searchContextMenu.querySelector("#editmenu-copy");
cmdPaste = searchContextMenu.querySelector("#editmenu-paste"); cmdPaste = searchContextMenu.querySelector("#editmenu-paste");
is(cmdUndo.getAttribute("disabled"), "", "cmdUndo is enabled"); is(cmdUndo.getAttribute("disabled"), null, "cmdUndo is enabled");
is(cmdDelete.getAttribute("disabled"), "", "cmdDelete is enabled"); is(cmdDelete.getAttribute("disabled"), null, "cmdDelete is enabled");
is(cmdSelectAll.getAttribute("disabled"), "", "cmdSelectAll is enabled"); is(cmdSelectAll.getAttribute("disabled"), null, "cmdSelectAll is enabled");
is(cmdCut.getAttribute("disabled"), "", "cmdCut is enabled"); is(cmdCut.getAttribute("disabled"), null, "cmdCut is enabled");
is(cmdCopy.getAttribute("disabled"), "", "cmdCopy is enabled"); is(cmdCopy.getAttribute("disabled"), null, "cmdCopy is enabled");
is(cmdPaste.getAttribute("disabled"), "", "cmdPaste is enabled"); is(cmdPaste.getAttribute("disabled"), null, "cmdPaste is enabled");
const onContextMenuHidden = toolbox.once("menu-close"); const onContextMenuHidden = toolbox.once("menu-close");
searchContextMenu.hidePopup(); searchContextMenu.hidePopup();

View file

@ -96,12 +96,12 @@ add_task(async function () {
cmdCopy = searchContextMenu.querySelector("#editmenu-copy"); cmdCopy = searchContextMenu.querySelector("#editmenu-copy");
cmdPaste = searchContextMenu.querySelector("#editmenu-paste"); cmdPaste = searchContextMenu.querySelector("#editmenu-paste");
is(cmdUndo.getAttribute("disabled"), "", "cmdUndo is enabled"); is(cmdUndo.getAttribute("disabled"), null, "cmdUndo is enabled");
is(cmdDelete.getAttribute("disabled"), "", "cmdDelete is enabled"); is(cmdDelete.getAttribute("disabled"), null, "cmdDelete is enabled");
is(cmdSelectAll.getAttribute("disabled"), "", "cmdSelectAll is enabled"); is(cmdSelectAll.getAttribute("disabled"), null, "cmdSelectAll is enabled");
is(cmdCut.getAttribute("disabled"), "", "cmdCut is enabled"); is(cmdCut.getAttribute("disabled"), null, "cmdCut is enabled");
is(cmdCopy.getAttribute("disabled"), "", "cmdCopy is enabled"); is(cmdCopy.getAttribute("disabled"), null, "cmdCopy is enabled");
is(cmdPaste.getAttribute("disabled"), "", "cmdPaste is enabled"); is(cmdPaste.getAttribute("disabled"), null, "cmdPaste is enabled");
const onContextMenuHidden = toolbox.once("menu-close"); const onContextMenuHidden = toolbox.once("menu-close");
searchContextMenu.hidePopup(); searchContextMenu.hidePopup();

View file

@ -42,7 +42,7 @@ add_task(async function () {
await wait(1000); await wait(1000);
is( is(
readerModeButtonEl.getAttribute("readeractive"), readerModeButtonEl.getAttribute("readeractive"),
"", null,
"reader mode wasn't activated" "reader mode wasn't activated"
); );
@ -72,7 +72,7 @@ add_task(async function () {
await wait(1000); await wait(1000);
is( is(
readerModeButtonEl.getAttribute("readeractive"), readerModeButtonEl.getAttribute("readeractive"),
"", null,
"reader mode still wasn't activated" "reader mode still wasn't activated"
); );

View file

@ -1460,13 +1460,7 @@ void Element::GetAttribute(const nsAString& aName, DOMString& aReturn) {
if (val) { if (val) {
val->ToString(aReturn); val->ToString(aReturn);
} else { } else {
if (IsXULElement()) { aReturn.SetNull();
// XXX should be SetDOMStringToNull(aReturn);
// See bug 232598
// aReturn is already empty
} else {
aReturn.SetNull();
}
} }
} }

View file

@ -55,11 +55,11 @@ SimpleTest.waitForExplicitFinish();
// not when run as a Mochitest plain. // not when run as a Mochitest plain.
//is(xul_cs.color, "rgb(0, 0, 0)", "xul color " + test); //is(xul_cs.color, "rgb(0, 0, 0)", "xul color " + test);
attrValue = removed ? null : ""; let attrValue = removed ? null : "";
is(xul.id, "", "xul id " + test); is(xul.id, "", "xul id " + test);
is(xul.getAttribute("id"), "", "xul getAttribute " + test); is(xul.getAttribute("id"), attrValue, "xul getAttribute " + test);
is($("xul_id"), null, "xul getElementById " + test); is($("xul_id"), null, "xul getElementById " + test);
} }
@ -149,7 +149,7 @@ SimpleTest.waitForExplicitFinish();
await new Promise(SimpleTest.executeSoon); await new Promise(SimpleTest.executeSoon);
if (mutation) { if (mutation) {
is(mutation.target, xul, "target is xul"); is(mutation.target, xul, "target is xul");
is(xul.getAttribute("id"), "", "xul no longer has id attr"); is(xul.getAttribute("id"), null, "xul no longer has id attr");
is(xul.id, "", "xul no longer has id"); is(xul.id, "", "xul no longer has id");
xul.id = "other_xul_id"; xul.id = "other_xul_id";
} else { } else {

View file

@ -144,7 +144,7 @@ declTest("test in-process content events are not processed twice", {
"content", "content",
"Should be a content <browser>" "Should be a content <browser>"
); );
is(browser.getAttribute("remotetype"), "", "Should not be remote"); is(browser.getAttribute("remotetype"), null, "Should not be remote");
await testEventProcessedOnce(browser); await testEventProcessedOnce(browser);
}, },
}); });
@ -160,8 +160,12 @@ declTest("test in-process chrome events are processed correctly", {
"chrome://mochitests/content/browser/dom/ipc/tests/JSWindowActor/file_dummyChromePage.html" "chrome://mochitests/content/browser/dom/ipc/tests/JSWindowActor/file_dummyChromePage.html"
); );
let chromeBrowser = dialog._frame; let chromeBrowser = dialog._frame;
is(chromeBrowser.getAttribute("type"), "", "Should be a chrome <browser>"); is(
is(chromeBrowser.getAttribute("remotetype"), "", "Should not be remote"); chromeBrowser.getAttribute("type"),
null,
"Should be a chrome <browser>"
);
is(chromeBrowser.getAttribute("remotetype"), null, "Should not be remote");
await testEventProcessedOnce(chromeBrowser, "dummyChromePage.html"); await testEventProcessedOnce(chromeBrowser, "dummyChromePage.html");

View file

@ -150,13 +150,13 @@
function basicElementCreateBuiltIn() { function basicElementCreateBuiltIn() {
let element = document.createElementNS(XUL_NS, "axulelement", { is: "test-built-in-element" }); let element = document.createElementNS(XUL_NS, "axulelement", { is: "test-built-in-element" });
ok(element instanceof TestCustomBuiltInElement, "Should be an instance of TestCustomBuiltInElement"); ok(element instanceof TestCustomBuiltInElement, "Should be an instance of TestCustomBuiltInElement");
is(element.getAttribute("is"), "", "The |is| attribute of the created element should not be the extended type."); is(element.getAttribute("is"), null, "The |is| attribute of the created element should not be the extended type.");
document.querySelector("#content").appendChild(element); document.querySelector("#content").appendChild(element);
is(element.textContent, "baz", "Should have set the textContent"); is(element.textContent, "baz", "Should have set the textContent");
let element2 = element.cloneNode(false); let element2 = element.cloneNode(false);
is(element2.localName, "axulelement", "Should see the right tag"); is(element2.localName, "axulelement", "Should see the right tag");
is(element2.getAttribute("is"), "", "The |is| attribute of the created element should not be the extended type."); is(element2.getAttribute("is"), null, "The |is| attribute of the created element should not be the extended type.");
is(element2.textContent, "", "Shouldn't have cloned the textContent"); is(element2.textContent, "", "Shouldn't have cloned the textContent");
document.querySelector("#content").appendChild(element2); document.querySelector("#content").appendChild(element2);
is(element2.textContent, "baz", "Should have set the textContent"); is(element2.textContent, "baz", "Should have set the textContent");
@ -188,13 +188,13 @@
function subclassElementCreateBuiltIn() { function subclassElementCreateBuiltIn() {
let element = document.createElementNS(XUL_NS, "menupopup", { is: "test-popup-extend" }); let element = document.createElementNS(XUL_NS, "menupopup", { is: "test-popup-extend" });
ok(element instanceof TestPopupExtendElement, "Should be an instance of TestPopupExtendElement"); ok(element instanceof TestPopupExtendElement, "Should be an instance of TestPopupExtendElement");
is(element.getAttribute("is"), "", "The |is| attribute of the created element should not be the extended type."); is(element.getAttribute("is"), null, "The |is| attribute of the created element should not be the extended type.");
document.querySelector("#content").appendChild(element); document.querySelector("#content").appendChild(element);
is(element.textContent, "quuz", "Should have set the textContent"); is(element.textContent, "quuz", "Should have set the textContent");
let element2 = element.cloneNode(false); let element2 = element.cloneNode(false);
is(element2.localName, "menupopup", "Should see the right tag"); is(element2.localName, "menupopup", "Should see the right tag");
is(element2.getAttribute("is"), "", "The |is| attribute of the created element should not be the extended type."); is(element2.getAttribute("is"), null, "The |is| attribute of the created element should not be the extended type.");
is(element2.textContent, "", "Shouldn't have cloned the textContent"); is(element2.textContent, "", "Shouldn't have cloned the textContent");
document.querySelector("#content").appendChild(element2); document.querySelector("#content").appendChild(element2);
is(element2.textContent, "quuz", "Should have set the textContent"); is(element2.textContent, "quuz", "Should have set the textContent");
@ -268,13 +268,13 @@
let element = document.createElementNS(XUL_NS, "testwithoutdash", { is: "testwithoutdash-extended" }); let element = document.createElementNS(XUL_NS, "testwithoutdash", { is: "testwithoutdash-extended" });
ok(element instanceof TestWithoutDashExtended, "Should be an instance of TestWithoutDashExtended"); ok(element instanceof TestWithoutDashExtended, "Should be an instance of TestWithoutDashExtended");
ok(element instanceof TestWithoutDash, "Should be an instance of TestWithoutDash"); ok(element instanceof TestWithoutDash, "Should be an instance of TestWithoutDash");
is(element.getAttribute("is"), "", "The |is| attribute of the created element should not be the extended type."); is(element.getAttribute("is"), null, "The |is| attribute of the created element should not be the extended type.");
document.querySelector("#content").appendChild(element); document.querySelector("#content").appendChild(element);
is(element.textContent, "quux", "Should have set the textContent"); is(element.textContent, "quux", "Should have set the textContent");
let element2 = element.cloneNode(false); let element2 = element.cloneNode(false);
is(element2.localName, "testwithoutdash", "Should see the right tag"); is(element2.localName, "testwithoutdash", "Should see the right tag");
is(element2.getAttribute("is"), "", "The |is| attribute of the created element should not be the extended type."); is(element2.getAttribute("is"), null, "The |is| attribute of the created element should not be the extended type.");
is(element2.textContent, "", "Shouldn't have cloned the textContent"); is(element2.textContent, "", "Shouldn't have cloned the textContent");
document.querySelector("#content").appendChild(element2); document.querySelector("#content").appendChild(element2);
is(element2.textContent, "quux", "Should have set the textContent"); is(element2.textContent, "quux", "Should have set the textContent");

View file

@ -290,7 +290,7 @@ async function testModuleNameHelper(moduleName, acceptButtonShouldBeDisabled) {
let dialogNode = win.document.querySelector("dialog"); let dialogNode = win.document.querySelector("dialog");
Assert.equal( Assert.equal(
dialogNode.getAttribute("buttondisabledaccept"), dialogNode.getAttribute("buttondisabledaccept"),
acceptButtonShouldBeDisabled ? "true" : "", // it's a string acceptButtonShouldBeDisabled ? "true" : null,
`dialog accept button should ${ `dialog accept button should ${
acceptButtonShouldBeDisabled ? "" : "not " acceptButtonShouldBeDisabled ? "" : "not "
}be disabled` }be disabled`

View file

@ -30,7 +30,7 @@ let testCases = [
doorhanger: { doorhanger: {
type: "password-save", type: "password-save",
dismissed: true, dismissed: true,
anchorExtraAttr: "", anchorExtraAttr: null,
username: "", username: "",
password: "abcXYZ", password: "abcXYZ",
toggle: "visible", toggle: "visible",
@ -56,7 +56,7 @@ let testCases = [
doorhanger: { doorhanger: {
type: "password-save", type: "password-save",
dismissed: true, dismissed: true,
anchorExtraAttr: "", anchorExtraAttr: null,
username: "", username: "",
password: "pass-changed", password: "pass-changed",
toggle: "visible", toggle: "visible",
@ -80,7 +80,7 @@ let testCases = [
doorhanger: { doorhanger: {
type: "password-change", type: "password-change",
dismissed: true, dismissed: true,
anchorExtraAttr: "", anchorExtraAttr: null,
username: "user1", username: "user1",
password: "autopass-changed", password: "autopass-changed",
}, },
@ -104,7 +104,7 @@ let testCases = [
doorhanger: { doorhanger: {
type: "password-save", type: "password-save",
dismissed: true, dismissed: true,
anchorExtraAttr: "", anchorExtraAttr: null,
username: "user2", username: "user2",
password: "pass2", password: "pass2",
toggle: "visible", toggle: "visible",
@ -147,7 +147,7 @@ let testCases = [
doorhanger: { doorhanger: {
type: "password-save", type: "password-save",
dismissed: true, dismissed: true,
anchorExtraAttr: "", anchorExtraAttr: null,
username: "user2", username: "user2",
password: "pass1", password: "pass1",
toggle: "visible", toggle: "visible",
@ -174,7 +174,7 @@ let testCases = [
doorhanger: { doorhanger: {
type: "password-change", type: "password-change",
dismissed: true, dismissed: true,
anchorExtraAttr: "", anchorExtraAttr: null,
username: "user-saved", username: "user-saved",
password: "pass2", password: "pass2",
toggle: "visible", toggle: "visible",
@ -198,7 +198,7 @@ let testCases = [
doorhanger: { doorhanger: {
type: "password-change", type: "password-change",
dismissed: true, dismissed: true,
anchorExtraAttr: "", anchorExtraAttr: null,
username: "user1", username: "user1",
password: "pass1", password: "pass1",
toggle: "visible", toggle: "visible",
@ -244,7 +244,7 @@ let testCases = [
doorhanger: { doorhanger: {
type: "password-save", type: "password-save",
dismissed: true, dismissed: true,
anchorExtraAttr: "", anchorExtraAttr: null,
username: "", username: "",
password: "a", password: "a",
toggle: "visible", toggle: "visible",
@ -271,7 +271,7 @@ let testCases = [
doorhanger: { doorhanger: {
type: "password-save", type: "password-save",
dismissed: true, dismissed: true,
anchorExtraAttr: "", anchorExtraAttr: null,
username: "", username: "",
password: "abc", password: "abc",
toggle: "visible", toggle: "visible",
@ -296,7 +296,7 @@ let testCases = [
doorhanger: { doorhanger: {
type: "password-change", type: "password-change",
dismissed: true, dismissed: true,
anchorExtraAttr: "", anchorExtraAttr: null,
username: "", username: "",
password: "pass", password: "pass",
toggle: "visible", toggle: "visible",

View file

@ -130,7 +130,7 @@ function assertMenuitems(menuitems, expected) {
elmt => elmt =>
!elmt.id.includes("-sep-") && !elmt.id.includes("-sep-") &&
!elmt.hidden && !elmt.hidden &&
["", "false"].includes(elmt.getAttribute("disabled")) [null, "false"].includes(elmt.getAttribute("disabled"))
) )
.map(elmt => elmt.id), .map(elmt => elmt.id),
expected expected

View file

@ -69,11 +69,7 @@ TooltipTextProvider.prototype = {
} }
if (tipElement.namespaceURI == XUL_NS) { if (tipElement.namespaceURI == XUL_NS) {
lookingForSVGTitle = false; lookingForSVGTitle = false;
// NOTE: getAttribute behaves differently for XUL so we can't rely on titleText = tipElement.getAttribute("tooltiptext");
// it returning null, see bug 232598.
titleText = tipElement.hasAttribute("tooltiptext")
? tipElement.getAttribute("tooltiptext")
: null;
} else if (!defView.SVGElement.isInstance(tipElement)) { } else if (!defView.SVGElement.isInstance(tipElement)) {
lookingForSVGTitle = false; lookingForSVGTitle = false;
titleText = tipElement.getAttribute("title"); titleText = tipElement.getAttribute("title");

View file

@ -153,7 +153,7 @@ XULStore.prototype = {
} }
const uri = node.ownerDocument.documentURI; const uri = node.ownerDocument.documentURI;
const value = node.getAttribute(attr); const value = node.getAttribute(attr) || "";
if (node.localName == "window") { if (node.localName == "window") {
this.log("Persisting attributes to windows is handled by AppWindow."); this.log("Persisting attributes to windows is handled by AppWindow.");

View file

@ -732,7 +732,7 @@
} }
get label() { get label() {
return this.getAttribute("label"); return this.getAttribute("label") || "";
} }
set image(val) { set image(val) {
@ -762,9 +762,7 @@
} }
get accessKey() { get accessKey() {
return this.labelElement return this.labelElement?.accessKey || this.getAttribute("accesskey");
? this.labelElement.accessKey
: this.getAttribute("accesskey");
} }
}; };
MozElements.BaseTextMixin = BaseTextMixin; MozElements.BaseTextMixin = BaseTextMixin;

View file

@ -40,7 +40,7 @@ function runTests()
let checkboxLabel = $("checkbox-label"); let checkboxLabel = $("checkbox-label");
is(checkboxLabel.control, "checkbox", "checkbox control"); is(checkboxLabel.control, "checkbox", "checkbox control");
is(checkboxLabel.labeledControlElement, checkbox, "checkbox labeledControlElement"); is(checkboxLabel.labeledControlElement, checkbox, "checkbox labeledControlElement");
is(checkbox.accessKey, "", "checkbox accessKey not set"); is(checkbox.accessKey, null, "checkbox accessKey not set");
checkboxLabel.accessKey = "C"; checkboxLabel.accessKey = "C";
is(checkbox.accessKey, "C", "checkbox accessKey set"); is(checkbox.accessKey, "C", "checkbox accessKey set");

View file

@ -49,10 +49,10 @@ function runTestSet(suffix)
var three = $("three" + suffix); var three = $("three" + suffix);
var four = $("four" + suffix); var four = $("four" + suffix);
checkAttributes(one, "One", "", "", true, false); checkAttributes(one, "One", null, null, true, false);
checkAttributes(two, "", "", "false", false, false); checkAttributes(two, null, null, "false", false, false);
checkAttributes(three, "Three", "T", "true", false, false); checkAttributes(three, "Three", "T", "true", false, false);
checkAttributes(four, "Four", "F", "", false, false); checkAttributes(four, "Four", "F", null, false, false);
if (isMac && suffix) { if (isMac && suffix) {
var utils = window.windowUtils; var utils = window.windowUtils;
@ -62,8 +62,8 @@ function runTestSet(suffix)
$("menu" + suffix).open = true; $("menu" + suffix).open = true;
} }
checkAttributes(one, "One", "", "", false, true); checkAttributes(one, "One", null, null, false, true);
checkAttributes(two, "Cat", "C", "", false, true); checkAttributes(two, "Cat", "C", null, false, true);
checkAttributes(three, "Dog", "D", "false", true, true); checkAttributes(three, "Dog", "D", "false", true, true);
checkAttributes(four, "Four", "F", "true", false, true); checkAttributes(four, "Four", "F", "true", false, true);

View file

@ -34,7 +34,7 @@ function runTests()
list.selectedItem = null; list.selectedItem = null;
is(list.value, "", "Check list value after setting selectedItem to null"); is(list.value, "", "Check list value after setting selectedItem to null");
is(list.getAttribute("label"), "", "Check list label after setting selectedItem to null"); is(list.getAttribute("label"), null, "Check list label after setting selectedItem to null");
// select something again to make sure the label is not already empty // select something again to make sure the label is not already empty
list.selectedIndex = 1; list.selectedIndex = 1;
@ -61,14 +61,14 @@ function runTests()
// set the value to null and test it (bug 408940) // set the value to null and test it (bug 408940)
list.value = null; list.value = null;
is(list.value, "", "Check list value after setting value to null"); is(list.value, "", "Check list value after setting value to null");
is(list.getAttribute("label"), "", "Check list label after setting value to null"); is(list.getAttribute("label"), null, "Check list label after setting value to null");
// select something again to make sure the label is not already empty // select something again to make sure the label is not already empty
list.selectedIndex = 1; list.selectedIndex = 1;
// set the value to undefined and test it (bug 408940) // set the value to undefined and test it (bug 408940)
list.value = undefined; list.value = undefined;
is(list.value, "", "Check list value after setting value to undefined"); is(list.value, "", "Check list value after setting value to undefined");
is(list.getAttribute("label"), "", "Check list label after setting value to undefined"); is(list.getAttribute("label"), null, "Check list label after setting value to undefined");
// select something again to make sure the label is not already empty // select something again to make sure the label is not already empty
list.selectedIndex = 1; list.selectedIndex = 1;
@ -76,7 +76,7 @@ function runTests()
// and make sure the previous label is removed // and make sure the previous label is removed
list.value = "this does not exist"; list.value = "this does not exist";
is(list.value, "this does not exist", "Check the list value after setting it to something not associated witn an existing menuitem"); is(list.value, "this does not exist", "Check the list value after setting it to something not associated witn an existing menuitem");
is(list.getAttribute("label"), "", "Check that the list label is empty after selecting a nonexistent item"); is(list.getAttribute("label"), null, "Check that the list label is empty after selecting a nonexistent item");
SimpleTest.finish(); SimpleTest.finish();
} }

View file

@ -16,15 +16,19 @@ function ok(condition, message) {
window.arguments[0].SimpleTest.ok(condition, message); window.arguments[0].SimpleTest.ok(condition, message);
} }
function is(a, b, message) {
window.arguments[0].SimpleTest.is(a, b, message);
}
function doSingleTest(param) function doSingleTest(param)
{ {
var exception = null; var exception = null;
try { try {
document.documentElement.removeAttribute("chromemargin"); document.documentElement.removeAttribute("chromemargin");
document.documentElement.setAttribute("chromemargin", param); document.documentElement.setAttribute("chromemargin", param);
ok(document. is(document.
documentElement. documentElement.
getAttribute("chromemargin") == param, "couldn't set/get chromemargin?"); getAttribute("chromemargin"), param, "couldn't set/get chromemargin?");
} catch (ex) { } catch (ex) {
exception = ex; exception = ex;
} }
@ -44,7 +48,7 @@ function runTests()
// test remove // test remove
doc.removeAttribute("chromemargin"); doc.removeAttribute("chromemargin");
ok(doc.getAttribute("chromemargin") == "", "couldn't remove chromemargin?"); is(doc.getAttribute("chromemargin"), null, "couldn't remove chromemargin?");
// we already test these really well in a c++ test in widget // we already test these really well in a c++ test in widget
doSingleTest("1,2,3,4"); doSingleTest("1,2,3,4");

View file

@ -82,7 +82,7 @@ function runTest()
document.documentElement.appendChild(keyset); document.documentElement.appendChild(keyset);
iterateKeys(true, "appended"); iterateKeys(true, "appended");
var accelText = menuitem => menuitem.getAttribute("acceltext").toLowerCase(); var accelText = menuitem => (menuitem.getAttribute("acceltext") || "").toLowerCase();
$("menubutton").open = true; $("menubutton").open = true;

View file

@ -363,8 +363,8 @@ function testPopupMovement()
is(screenX, expectedx, gTests[gTestIndex] + " (6000, 100) x"); is(screenX, expectedx, gTests[gTestIndex] + " (6000, 100) x");
is(screenY, 100, gTests[gTestIndex] + " (6000, 100) y"); is(screenY, 100, gTests[gTestIndex] + " (6000, 100) y");
is(popup.getAttribute("left"), "", gTests[gTestIndex] + " left is empty after moving"); is(popup.getAttribute("left"), null, gTests[gTestIndex] + " left is empty after moving");
is(popup.getAttribute("top"), "", gTests[gTestIndex] + " top is empty after moving"); is(popup.getAttribute("top"), null, gTests[gTestIndex] + " top is empty after moving");
popup.setAttribute("left", "80"); popup.setAttribute("left", "80");
popup.setAttribute("top", "82"); popup.setAttribute("top", "82");
[screenX, screenY] = getScreenXY(popup); [screenX, screenY] = getScreenXY(popup);
@ -387,8 +387,8 @@ function testPopupMovement()
is(screenX, expectedx, gTests[gTestIndex] + " move after set left and top x to -1"); is(screenX, expectedx, gTests[gTestIndex] + " move after set left and top x to -1");
is(screenY, expectedy, gTests[gTestIndex] + " move after set left and top y to -1"); is(screenY, expectedy, gTests[gTestIndex] + " move after set left and top y to -1");
is(popup.getAttribute("left"), "", gTests[gTestIndex] + " left is not set after moving to -1"); is(popup.getAttribute("left"), null, gTests[gTestIndex] + " left is not set after moving to -1");
is(popup.getAttribute("top"), "", gTests[gTestIndex] + " top is not set after moving to -1"); is(popup.getAttribute("top"), null, gTests[gTestIndex] + " top is not set after moving to -1");
popup.hidePopup(); popup.hidePopup();
} }

View file

@ -321,11 +321,7 @@ function testtag_tree_columns(tree, expectedColumns, testid) {
// check the view's getColumnProperties method // check the view's getColumnProperties method
var properties = tree.view.getColumnProperties(column); var properties = tree.view.getColumnProperties(column);
var expectedProperties = expectedColumn.properties; var expectedProperties = expectedColumn.properties;
is( is(properties, expectedProperties || "", adjtestid + "getColumnProperties");
properties,
expectedProperties ? expectedProperties : "",
adjtestid + "getColumnProperties"
);
} }
is(columns.getFirstColumn(), columns[0], testid + "getFirstColumn"); is(columns.getFirstColumn(), columns[0], testid + "getFirstColumn");
@ -2151,12 +2147,12 @@ function convertDOMtoTreeRowInfo(treechildren, level, rowidx) {
for (var c = 0; c < treerow.childNodes.length; c++) { for (var c = 0; c < treerow.childNodes.length; c++) {
var cell = treerow.childNodes[c]; var cell = treerow.childNodes[c];
cellInfo.push({ cellInfo.push({
label: "" + cell.getAttribute("label"), label: cell.getAttribute("label") || "",
value: cell.getAttribute("value"), value: cell.getAttribute("value") || "",
properties: cell.getAttribute("properties"), properties: cell.getAttribute("properties") || "",
editable: cell.getAttribute("editable") != "false", editable: cell.getAttribute("editable") != "false",
selectable: cell.getAttribute("selectable") != "false", selectable: cell.getAttribute("selectable") != "false",
image: cell.getAttribute("src"), image: cell.getAttribute("src") || "",
mode: cell.hasAttribute("mode") mode: cell.hasAttribute("mode")
? parseInt(cell.getAttribute("mode")) ? parseInt(cell.getAttribute("mode"))
: 3, : 3,
@ -2170,7 +2166,7 @@ function convertDOMtoTreeRowInfo(treechildren, level, rowidx) {
: convertDOMtoTreeRowInfo(descendants, level + 1, rowidx); : convertDOMtoTreeRowInfo(descendants, level + 1, rowidx);
obj.rows.push({ obj.rows.push({
cells: cellInfo, cells: cellInfo,
properties: treerow.getAttribute("properties"), properties: treerow.getAttribute("properties") || "",
container: treeitem.getAttribute("container") == "true", container: treeitem.getAttribute("container") == "true",
separator: treeitem.localName == "treeseparator", separator: treeitem.localName == "treeseparator",
children, children,

View file

@ -84,7 +84,7 @@
).toLowerCase(); ).toLowerCase();
// If the accesskey of the current button is pressed, just activate it // If the accesskey of the current button is pressed, just activate it
if (this.accessKey.toLowerCase() == charPressedLower) { if (this.accessKey?.toLowerCase() == charPressedLower) {
this.click(); this.click();
return; return;
} }
@ -201,7 +201,7 @@
while (iterator.nextNode()) { while (iterator.nextNode()) {
var test = iterator.currentNode; var test = iterator.currentNode;
if ( if (
test.accessKey.toLowerCase() == aAccessKeyLower && test.accessKey?.toLowerCase() == aAccessKeyLower &&
!test.disabled && !test.disabled &&
!test.collapsed && !test.collapsed &&
!test.hidden !test.hidden

View file

@ -19,7 +19,7 @@
this.setAttribute("value", val); this.setAttribute("value", val);
} }
get value() { get value() {
return this.getAttribute("value"); return this.getAttribute("value") || "";
} }
// nsIDOMXULSelectControlItemElement // nsIDOMXULSelectControlItemElement

View file

@ -153,7 +153,7 @@
// nsIDOMXULSelectControlElement // nsIDOMXULSelectControlElement
get value() { get value() {
return this.getAttribute("value"); return this.getAttribute("value") || "";
} }
// nsIDOMXULMenuListElement // nsIDOMXULMenuListElement
@ -163,12 +163,12 @@
// nsIDOMXULMenuListElement // nsIDOMXULMenuListElement
get image() { get image() {
return this.getAttribute("image"); return this.getAttribute("image") || "";
} }
// nsIDOMXULMenuListElement // nsIDOMXULMenuListElement
get label() { get label() {
return this.getAttribute("label"); return this.getAttribute("label") || "";
} }
set description(val) { set description(val) {
@ -176,7 +176,7 @@
} }
get description() { get description() {
return this.getAttribute("description"); return this.getAttribute("description") || "";
} }
// nsIDOMXULMenuListElement // nsIDOMXULMenuListElement

View file

@ -214,7 +214,7 @@
} }
get value() { get value() {
return this.getAttribute("value"); return this.getAttribute("value") || "";
} }
set disabled(val) { set disabled(val) {
@ -526,7 +526,7 @@
} }
get value() { get value() {
return this.getAttribute("value"); return this.getAttribute("value") || "";
} }
get selected() { get selected() {

View file

@ -116,7 +116,7 @@
var searchText = var searchText =
"searchLabel" in listitem "searchLabel" in listitem
? listitem.searchLabel ? listitem.searchLabel
: listitem.getAttribute("label"); // (see also bug 250123) : listitem.getAttribute("label") || ""; // (see also bug 250123)
searchText = searchText.substring(0, length).toLowerCase(); searchText = searchText.substring(0, length).toLowerCase();
if (searchText == incrementalString) { if (searchText == incrementalString) {
this.ensureIndexIsVisible(k); this.ensureIndexIsVisible(k);
@ -227,7 +227,7 @@
this.setAttribute("seltype", val); this.setAttribute("seltype", val);
} }
get selType() { get selType() {
return this.getAttribute("seltype"); return this.getAttribute("seltype") || "";
} }
// nsIDOMXULSelectControlElement // nsIDOMXULSelectControlElement
@ -977,7 +977,7 @@
} }
get value() { get value() {
return this.getAttribute("value"); return this.getAttribute("value") || "";
} }
/** /**

View file

@ -459,7 +459,7 @@
} }
get value() { get value() {
return this.getAttribute("value"); return this.getAttribute("value") || "";
} }
get control() { get control() {
@ -563,7 +563,7 @@
} }
get value() { get value() {
return this.getAttribute("value"); return this.getAttribute("value") || "";
} }
get tabbox() { get tabbox() {

View file

@ -1078,7 +1078,7 @@
} }
get selType() { get selType() {
return this.getAttribute("seltype"); return this.getAttribute("seltype") || "";
} }
set currentIndex(val) { set currentIndex(val) {

View file

@ -56,9 +56,12 @@ export var ShortcutUtils = {
}, },
getModifierString(elemMod) { getModifierString(elemMod) {
if (!elemMod) {
return "";
}
let elemString = ""; let elemString = "";
let haveCloverLeaf = false; let haveCloverLeaf = false;
if (elemMod.match("accel")) { if (elemMod.match("accel")) {
if (Services.appinfo.OS == "Darwin") { if (Services.appinfo.OS == "Darwin") {
haveCloverLeaf = true; haveCloverLeaf = true;

View file

@ -64,7 +64,7 @@ add_task(async function doorhanger_bc_multiUpdate() {
is( is(
PanelUI.menuButton.getAttribute("badge-status"), PanelUI.menuButton.getAttribute("badge-status"),
"", null,
"Should not have restart badge during staging" "Should not have restart badge during staging"
); );

View file

@ -74,7 +74,7 @@ add_task(async function doorhanger_bc_multiUpdate() {
is( is(
PanelUI.menuButton.getAttribute("badge-status"), PanelUI.menuButton.getAttribute("badge-status"),
"", null,
"Should not have restart badge during staging" "Should not have restart badge during staging"
); );