Bug 1256264 - Make requestId a string. r=kmag
authorAndreas Wagner <mail@andreaswagner.org>
Mon, 14 Mar 2016 14:05:57 +0100
changeset 289166 a3ed682cb1815f4e712aaee9e65080d9f7a40910
parent 289165 d9cc905f0f37faa8d1da6e449709d261eda4933b
child 289167 70960616621c6d2fce52edc827a7600aeb2087a3
push id30098
push usercbook@mozilla.com
push dateFri, 18 Mar 2016 14:32:34 +0000
treeherdermozilla-central@3d37c7e5b8dd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1256264
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1256264 - Make requestId a string. r=kmag MozReview-Commit-ID: G9qh3jurdfZ
toolkit/components/extensions/test/mochitest/test_ext_webrequest.html
toolkit/modules/addons/WebRequest.jsm
--- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest.html
@@ -243,20 +243,35 @@ function backgroundScript() {
     }
     browser.test.assertTrue(modifiedAny, `at least one modified ${phase}Headers element`);
 
     for (let name of deleted) {
       browser.test.assertFalse(headers.some(h => h.name === name), `deleted header ${name} still found in ${phase}Headers`);
     }
   }
 
+  let lastRequestId = -1;
+  let lastRequestUrl = null;
+  function validateRequestIdType(currentId) {
+    browser.test.assertTrue(typeof lastRequestId === "string");
+    browser.test.assertTrue(typeof currentId === "string");
+    browser.test.assertTrue(typeof parseInt(currentId, 10) === "number");
+    browser.test.assertTrue(parseInt(lastRequestId, 10) !== parseInt(currentId, 10));
+  }
+
   function onBeforeRequest(details) {
     browser.test.log(`onBeforeRequest ${details.requestId} ${details.url}`);
 
-    browser.test.assertTrue(details.requestId > 0, `valid requestId ${details.requestId}`);
+    if (!lastRequestUrl) {
+      lastRequestUrl = details.url;
+      lastRequestId = details.requestId;
+    } else if (lastRequestUrl != details.url) {
+      validateRequestIdType(details.requestId);
+    }
+
     let ids = requestIDs.get(details.url);
     if (ids) {
       ids.add(details.requestId);
     } else {
       requestIDs.set(details.url, new Set([details.requestId]));
     }
     checkResourceType(details.type);
     if (shouldRecord(details.url)) {
--- a/toolkit/modules/addons/WebRequest.jsm
+++ b/toolkit/modules/addons/WebRequest.jsm
@@ -39,17 +39,17 @@ function extractFromChannel(channel, key
   }
   return null;
 }
 
 var RequestId = {
   count: 1,
   KEY: "mozilla.webRequest.requestId",
   create(channel = null) {
-    let id = this.count++;
+    let id = (this.count++).toString();
     if (channel) {
       attachToChannel(channel, this.KEY, id);
     }
     return id;
   },
 
   get(channel) {
     return channel && extractFromChannel(channel, this.KEY) || this.create(channel);