[Pkg-mozext-commits] [tabmixplus] 21/30: Pass AMO validation test for on* attribute being set using setAttribute

David Prévot taffit at moszumanska.debian.org
Sun Jun 14 22:15:39 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository tabmixplus.

commit 49381da234820da2372aa8b8444a2ae67abd0edb
Author: onemen <tabmix.onemen at gmail.com>
Date:   Wed Jun 10 15:02:58 2015 +0300

    Pass AMO validation test for on* attribute being set using setAttribute
---
 chrome/content/click/click.js                           |  5 +++--
 chrome/content/minit/minit.js                           |  2 +-
 chrome/content/minit/tablib.js                          |  4 +++-
 chrome/content/preferences/links.js                     |  4 +---
 chrome/content/preferences/overlay/overlaySanitizeUI.js |  4 ++--
 chrome/content/preferences/preferences.xul              |  3 ++-
 chrome/content/session/session.js                       | 10 ++++++----
 chrome/content/session/sessionStore.js                  |  8 ++++++--
 chrome/content/tabmix.js                                |  6 +++---
 modules/AutoReload.jsm                                  |  4 ++--
 modules/Shortcuts.jsm                                   |  2 +-
 11 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/chrome/content/click/click.js b/chrome/content/click/click.js
index 49575a9..0ae1fc1 100644
--- a/chrome/content/click/click.js
+++ b/chrome/content/click/click.js
@@ -345,8 +345,9 @@ var TabmixContext = {
 
     // Bug 866880 - Implement "Close Tabs to the Right" as a built-in feature
     if (Tabmix.isVersion(240)) {
-      tabContextMenu.insertBefore($id("context_closeTabsToTheEnd"), $id("tm-closeRightTabs"));
-      $id("context_closeTabsToTheEnd").setAttribute("oncommand","gBrowser._closeRightTabs(TabContextMenu.contextTab);");
+      let closeTabsToTheEnd = $id("context_closeTabsToTheEnd");
+      tabContextMenu.insertBefore(closeTabsToTheEnd, $id("tm-closeRightTabs"));
+      Tabmix.setItem(closeTabsToTheEnd, "oncommand", "gBrowser._closeRightTabs(TabContextMenu.contextTab);");
       tabContextMenu.removeChild($id("tm-closeRightTabs"));
       this._closeRightTabs = "context_closeTabsToTheEnd";
     }
diff --git a/chrome/content/minit/minit.js b/chrome/content/minit/minit.js
index 426dfbb..09d3a73 100644
--- a/chrome/content/minit/minit.js
+++ b/chrome/content/minit/minit.js
@@ -1082,7 +1082,7 @@ Tabmix.navToolbox = {
     // onblur attribut reset each time we exit ToolboxCustomize
     var blur = gURLBar.getAttribute("onblur") || "";
     if (blur.indexOf("Tabmix.urlBarOnBlur") == -1)
-      gURLBar.setAttribute("onblur", blur + "Tabmix.urlBarOnBlur();");
+      Tabmix.setItem(gURLBar, "onblur", blur + "Tabmix.urlBarOnBlur();");
 
     let obj = gURLBar, fn;
     // Fix incompatibility with Omnibar (O is not defined)
diff --git a/chrome/content/minit/tablib.js b/chrome/content/minit/tablib.js
index 7659996..1ccd2a6 100644
--- a/chrome/content/minit/tablib.js
+++ b/chrome/content/minit/tablib.js
@@ -856,7 +856,9 @@ var tablib = {
     clearList.id = "menu_clearClosedWindowsList";
     clearList.setAttribute("label", TabmixSvc.getString("undoClosedWindows.clear.label"));
     clearList.setAttribute("value", -1);
-    clearList.setAttribute("oncommand", "TabmixSessionManager.forgetClosedWindow(-1);");
+    clearList.addEventListener("command", function() {
+      TabmixSessionManager.forgetClosedWindow(-1);
+    });
     undoPopup.insertBefore(clearList, restoreAllWindows);
   },
 
diff --git a/chrome/content/preferences/links.js b/chrome/content/preferences/links.js
index 589204f..c3c4a96 100644
--- a/chrome/content/preferences/links.js
+++ b/chrome/content/preferences/links.js
@@ -2,9 +2,7 @@
 
 var gLinksPane = {
   init: function () {
-    let singleWindow = $("singleWindow");
-    $("pref_singleWindow").setAttribute("onchange", "gLinksPane.singleWindow(this.value);");
-    this.singleWindow(singleWindow.checked);
+    this.singleWindow($("singleWindow").checked);
     gLinksPane.externalLinkValue($("externalLink").checked);
 
     gPrefWindow.initPane("paneLinks");
diff --git a/chrome/content/preferences/overlay/overlaySanitizeUI.js b/chrome/content/preferences/overlay/overlaySanitizeUI.js
index 1b31e16..d1bed05 100644
--- a/chrome/content/preferences/overlay/overlaySanitizeUI.js
+++ b/chrome/content/preferences/overlay/overlaySanitizeUI.js
@@ -63,7 +63,7 @@ Tabmix.setSanitizer = {
       check.setAttribute("label", this._label);
       check.setAttribute("accesskey", this._accesskey);
       check.setAttribute("preference", prefName);
-      check.setAttribute("oncommand", "Tabmix.setSanitizer.confirm(this);");
+      Tabmix.setItem(check, "oncommand", "Tabmix.setSanitizer.confirm(this);");
       if (Services.prefs.prefHasUserValue(prefName)) {
         this.checked = Services.prefs.getBoolPref(prefName);
         check.setAttribute("checked", this.checked);
@@ -84,7 +84,7 @@ Tabmix.setSanitizer = {
       if (this.isPromptDialog) {
         Tabmix.setSanitizer.disableMenuItem();
         pref.setAttribute("readonly", "true");
-        check.setAttribute("onsyncfrompreference",
+        Tabmix.setItem(check, "onsyncfrompreference",
                            "Tabmix.setSanitizer.checked = this.checked; " +
                            "return gSanitizePromptDialog.onReadGeneric();");
       }
diff --git a/chrome/content/preferences/preferences.xul b/chrome/content/preferences/preferences.xul
index 9414c9e..1a3b4bd 100644
--- a/chrome/content/preferences/preferences.xul
+++ b/chrome/content/preferences/preferences.xul
@@ -51,7 +51,8 @@
             src="chrome://tabmixplus/content/preferences/incompatible.xul"/>
   <prefpane id="broadcasters" hidden="true">
     <preferences>
-      <preference id="pref_singleWindow" name="extensions.tabmix.singleWindow" type="bool"/>
+      <preference id="pref_singleWindow" name="extensions.tabmix.singleWindow" type="bool"
+                  onchange="if (typeof gLinksPane == 'object') gLinksPane.singleWindow(this.value);"/>
       <preference id="pref_undoClose"    name="extensions.tabmix.undoClose"    type="bool"/>
     </preferences>
     <broadcasterset id="main:Broadcaster">
diff --git a/chrome/content/session/session.js b/chrome/content/session/session.js
index 21db479..ff34773 100644
--- a/chrome/content/session/session.js
+++ b/chrome/content/session/session.js
@@ -1928,6 +1928,10 @@ if (container == "error") { Tabmix.log("wrapContainer error path " + path + "\n"
          nodes.push(node);
       }
       var count = nodes.length;
+      let restoreSession = function(event) {
+        this.restoreSession(event.originalTarget);
+        event.stopPropagation();
+      }.bind(this);
       for (var i = 0; i < count; i++) {
          node = nodes[i];
          name = this.getDecodedLiteralValue(node, "name");
@@ -1942,8 +1946,7 @@ if (container == "error") { Tabmix.log("wrapContainer error path " + path + "\n"
          // Ubuntu global menu prevents Session manager menu from working from Tools menu
          // this hack is only for left click, middle click and right click still not working
          if (TabmixSvc.isLinux && parentId == "tm-sessionmanager")
-            mi.setAttribute("oncommand", "TabmixSessionManager.restoreSession(event.originalTarget);" +
-                                         " event.stopPropagation();");
+            mi.addEventListener("command", restoreSession);
          mi.value = i;
          if (parentID != "onStart.loadsession") {
             index = closedWinList ? count - 1 - i : i;
@@ -1990,8 +1993,7 @@ if (container == "error") { Tabmix.log("wrapContainer error path " + path + "\n"
                if (showTooltip) menu.setAttribute("tooltiptext", sLabel + nameExt);
                menu.setAttribute("value", (-1 - i));
                if (TabmixSvc.isLinux && parentId == "tm-sessionmanager")
-                  menu.setAttribute("oncommand", "TabmixSessionManager.restoreSession(event.originalTarget);" +
-                                                 " event.stopPropagation();");
+                  menu.addEventListener("command", restoreSession);
                popup.appendChild (menu);
             }
             if (afterCrash && contents != 1) { // add separator before Crashed menu item
diff --git a/chrome/content/session/sessionStore.js b/chrome/content/session/sessionStore.js
index 385a562..3694025 100644
--- a/chrome/content/session/sessionStore.js
+++ b/chrome/content/session/sessionStore.js
@@ -418,14 +418,18 @@ var TMP_ClosedTabs = { // jshint ignore:line
       m.setAttribute("id", "clearClosedTabsList");
       m.setAttribute("label", TabmixSvc.getString("undoclosetab.clear.label"));
       m.setAttribute("value", -1);
-      m.setAttribute("oncommand", "TMP_ClosedTabs.restoreTab('original', -1);");
+      m.addEventListener("command", function() {
+         TMP_ClosedTabs.restoreTab('original', -1);
+      });
 
       // "Restore All Tabs"
       m = aPopup.appendChild(document.createElement("menuitem"));
       m.setAttribute("id", "restoreAllClosedTabs");
       m.setAttribute("label", gNavigatorBundle.getString("menuRestoreAllTabs.label"));
       m.setAttribute("value", -2);
-      m.setAttribute("oncommand", "TMP_ClosedTabs.restoreTab('original', -2);");
+      m.addEventListener("command", function() {
+         TMP_ClosedTabs.restoreTab('original', -2);
+      });
       return true;
    },
 
diff --git a/chrome/content/tabmix.js b/chrome/content/tabmix.js
index 9a19e7a..0cc4c26 100644
--- a/chrome/content/tabmix.js
+++ b/chrome/content/tabmix.js
@@ -26,11 +26,11 @@ Tabmix.startup = function TMP_startup() {
     };
     let command = document.getElementById("Tools:PrivateBrowsing");
     let originalCode = command.getAttribute("oncommand");
-    command.setAttribute("oncommand","if (Tabmix._openNewTab(true)) {" + originalCode + "}");
-    cmdNewWindow.setAttribute("oncommand","if (Tabmix._openNewTab(false)) {" + originalNewNavigator + "}");
+    Tabmix.setItem(command, "oncommand","if (Tabmix._openNewTab(true)) {" + originalCode + "}");
+    Tabmix.setItem(cmdNewWindow, "oncommand","if (Tabmix._openNewTab(false)) {" + originalNewNavigator + "}");
   }
   else
-    cmdNewWindow.setAttribute("oncommand","if (Tabmix.singleWindowMode) BrowserOpenTab(); " +
+    Tabmix.setItem(cmdNewWindow, "oncommand","if (Tabmix.singleWindowMode) BrowserOpenTab(); " +
                                           "else {" + originalNewNavigator + "}");
 
   TabmixContext.toggleEventListener(true);
diff --git a/modules/AutoReload.jsm b/modules/AutoReload.jsm
index 5d7c5eb..605b096 100644
--- a/modules/AutoReload.jsm
+++ b/modules/AutoReload.jsm
@@ -27,8 +27,8 @@ this.AutoReload = {
     var win = aTab.ownerDocument.defaultView;
     let popup = win.document.getElementById("autoreload_popup");
     let parent = aPopup.parentNode;
-    aPopup.setAttribute("onpopuphidden", "this._tab = null;");
-    aPopup.setAttribute("oncommand",
+    win.Tabmix.setItem(aPopup, "onpopuphidden", "this._tab = null;");
+    win.Tabmix.setItem(aPopup, "oncommand",
                         "Tabmix.autoReload.setTime(this._tab, event.originalTarget.value);event.stopPropagation();");
     for (let i=0; i<popup.childNodes.length; i++)
       aPopup.appendChild(popup.childNodes[i].cloneNode(true));
diff --git a/modules/Shortcuts.jsm b/modules/Shortcuts.jsm
index 39fd9a5..b5e21cd 100644
--- a/modules/Shortcuts.jsm
+++ b/modules/Shortcuts.jsm
@@ -241,7 +241,7 @@ this.Shortcuts = {
       keyItem._id = aKey;
       keyset.appendChild(keyItem);
       keyItem.setAttribute("label", aKeyData.label);
-      keyItem.setAttribute("oncommand", "void(0);");
+      aWindow.Tabmix.setItem(keyItem, "oncommand", "void(0);");
       keyItem.addEventListener("command", this, true);
     }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git



More information about the Pkg-mozext-commits mailing list