Bug 1329299 - Verify frameId in webrequest tests. r=kmag, a=jcristau
authorShane Caraveo <scaraveo@mozilla.com>
Thu, 12 Jan 2017 12:09:35 -0800
changeset 353635 d49507cffc8ac291ec912ace8240894b9cd53988
parent 353634 fd642e0cca778eb13702e616e36d9940217624f9
child 353636 77badc363a32b04bd72eb7a3d720cc66b540e7ee
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag, jcristau
bugs1329299
milestone52.0a2
Bug 1329299 - Verify frameId in webrequest tests. r=kmag, a=jcristau 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
@@ -30,17 +30,17 @@ function WebRequestEventManager(context,
 
       let data2 = {
         requestId: data.requestId,
         url: data.url,
         originUrl: data.originUrl,
         method: data.method,
         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
@@ -186,16 +186,19 @@ function background(events) {
                                   `last requestId ${expected.test.requestId} different from this one ${details.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);