Bug 1319496 - 4. Fix context menu item IDs; r=sebastian
authorJim Chen <nchen@mozilla.com>
Tue, 29 Nov 2016 12:25:53 -0500
changeset 324720 16dbb57af3e2888827ef2db6d6e17d28cdab1379
parent 324719 10a6565daede03fcb1b5d4c7bfbfa499dfec404c
child 324721 5e8406f38c0936d8626a9dc0debc23b5ea7138bd
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerssebastian
bugs1319496
milestone53.0a1
Bug 1319496 - 4. Fix context menu item IDs; r=sebastian Context menu items used UUIDs as their prompt list item IDs. However, prompt list items only support integers as IDs. This error didn't show up before because JSONObject was silently ignoring the error. This patch changes to using an incremental integer as the ID and fixes the error.
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -6882,20 +6882,25 @@ var Tabs = {
     let tabs = BrowserApp.tabs;
     for (let i = 0; i < tabs.length; i++) {
       dump(aPrefix + " | " + "Tab [" + tabs[i].browser.contentWindow.location.href + "]: lastTouchedAt:" + tabs[i].lastTouchedAt + ", zombie:" + tabs[i].browser.__SS_restore);
     }
   },
 };
 
 function ContextMenuItem(args) {
-  this.id = uuidgen.generateUUID().toString();
+  this.id = ContextMenuItem._nextId;
   this.args = args;
+
+  // Limit to Java int range.
+  ContextMenuItem._nextId = (ContextMenuItem._nextId + 1) & 0x7fffffff;
 }
 
+ContextMenuItem._nextId = 1;
+
 ContextMenuItem.prototype = {
   get order() {
     return this.args.order || 0;
   },
 
   matches: function(elt, x, y) {
     return this.args.selector.matches(elt, x, y);
   },