Bug 1329299 verify frameId in webrequest tests, r?kmag draft
authorShane Caraveo <scaraveo@mozilla.com>
Thu, 12 Jan 2017 12:09:35 -0800
changeset 459769 65da1985084a437437e0b4e17f67aa8030cb9d94
parent 459680 048240a074e841c425a4da4707cf8e353074ec1d
child 542008 a75ae6034a98245e89b16021fdeeae20a0103015
push id41342
push usermixedpuppy@gmail.com
push dateThu, 12 Jan 2017 20:10:29 +0000
reviewerskmag
bugs1329299
milestone53.0a1
Bug 1329299 verify frameId in webrequest tests, r?kmag MozReview-Commit-ID: LuQcGsogs7J
toolkit/components/extensions/ext-webRequest.js
toolkit/components/extensions/test/mochitest/head_webrequest.js
--- a/toolkit/components/extensions/ext-webRequest.js
+++ b/toolkit/components/extensions/ext-webRequest.js
@@ -39,17 +39,17 @@ function WebRequestEventManager(context,
       let data2 = {
         requestId: data.requestId,
         url: data.url,
         originUrl: data.originUrl,
         method: data.method,
         tabId: browserData.tabId,
         type: data.type,
         timeStamp: Date.now(),
-        frameId: ExtensionManagement.getFrameId(data.windowId),
+        frameId: data.type == "main_frame" ? 0 : ExtensionManagement.getFrameId(data.windowId),
         parentFrameId: ExtensionManagement.getParentFrameId(data.parentWindowId, data.windowId),
       };
 
       const maybeCached = ["onResponseStarted", "onBeforeRedirect", "onCompleted", "onErrorOccurred"];
       if (maybeCached.includes(eventName)) {
         data2.fromCache = !!data.fromCache;
       }
 
--- a/toolkit/components/extensions/test/mochitest/head_webrequest.js
+++ b/toolkit/components/extensions/test/mochitest/head_webrequest.js
@@ -183,16 +183,19 @@ function background(events) {
           browser.test.assertEq(expected.test.requestId, details.requestId, "redirects will keep the same requestId");
         } else {
           // Save any values we want to validate in later events.
           expected.test.requestId = details.requestId;
           expected.test.tabId = details.tabId;
         }
         // Tests we don't need to do every event.
         browser.test.assertTrue(details.type.toUpperCase() in browser.webRequest.ResourceType, `valid resource type ${details.type}`);
+        if (details.type == "main_frame") {
+          browser.test.assertEq(0, details.frameId, "frameId is zero when type is main_frame bug 1329299");
+        }
       } else {
         // On events after onBeforeRequest, check the previous values.
         browser.test.assertEq(expected.test.requestId, details.requestId, "correct requestId");
         browser.test.assertEq(expected.test.tabId, details.tabId, "correct tabId");
       }
       if (name == "onBeforeSendHeaders") {
         if (expected.headers && expected.headers.request) {
           result.requestHeaders = processHeaders("request", expected, details);