Commit 1805ff69 authored by Michael Goossens's avatar Michael Goossens
Browse files

Bug 1662329 - Drop cookie permission requirement for cookieStoreId r=robwu

parent feb91401
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -244,3 +244,30 @@ add_task(async function userContext_disabled() {
  await extension.unload();
  await SpecialPowers.popPrefEnv();
});

add_task(async function tabs_query_cookiestoreid_nocookiepermission() {
  let extension = ExtensionTestUtils.loadExtension({
    async background() {
      let tab = await browser.tabs.create({});
      browser.test.assertEq(
        "firefox-default",
        tab.cookieStoreId,
        "Expecting cookieStoreId for new tab"
      );
      let query = await browser.tabs.query({
        index: tab.index,
        cookieStoreId: tab.cookieStoreId,
      });
      browser.test.assertEq(
        "firefox-default",
        query[0].cookieStoreId,
        "Expecting cookieStoreId for new tab through browser.tabs.query"
      );
      await browser.tabs.remove(tab.id);
      browser.test.sendMessage("done");
    },
  });
  await extension.startup();
  await extension.awaitMessage("done");
  await extension.unload();
});
+1 −1
Original line number Diff line number Diff line
@@ -309,7 +309,7 @@ class ProxyChannelFilter {

      ...extraData,
    };
    if (originAttributes && this.extension.hasPermission("cookies")) {
    if (originAttributes) {
      data.cookieStoreId = getCookieStoreIdForOriginAttributes(
        originAttributes
      );
+1 −4
Original line number Diff line number Diff line
@@ -654,6 +654,7 @@ class TabBase {
      isInReaderMode: this.isInReaderMode,
      sharingState: this.sharingState,
      successorTabId: this.successorTabId,
      cookieStoreId: this.cookieStoreId,
    };

    // If the tab has not been fully layed-out yet, fallback to the geometry
@@ -668,10 +669,6 @@ class TabBase {
      result.openerTabId = opener;
    }

    if (this.extension.hasPermission("cookies")) {
      result.cookieStoreId = this.cookieStoreId;
    }

    if (this.hasTabPermission) {
      for (let prop of ["url", "title", "favIconUrl"]) {
        // We use the underscored variants here to avoid the redundant
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ function registerEvent(
  remoteTab = null
) {
  let listener = async data => {
    let event = data.serialize(eventName, extension);
    let event = data.serialize(eventName);
    if (data.registerTraceableChannel) {
      // If this is a primed listener, no tabParent was passed in here,
      // but the convert() callback later in this function will be called
+1 −38
Original line number Diff line number Diff line
@@ -11,12 +11,7 @@ server.registerPathHandler("/dummy", (request, response) => {
add_task(async function test_userContextId_webrequest() {
  let extension = ExtensionTestUtils.loadExtension({
    manifest: {
      permissions: [
        "webRequest",
        "webRequestBlocking",
        "<all_urls>",
        "cookies",
      ],
      permissions: ["webRequest", "webRequestBlocking", "<all_urls>"],
    },
    background() {
      browser.webRequest.onBeforeRequest.addListener(
@@ -44,35 +39,3 @@ add_task(async function test_userContextId_webrequest() {
  await extension.unload();
  await contentPage.close();
});

add_task(async function test_userContextId_webrequest_nopermission() {
  let extension = ExtensionTestUtils.loadExtension({
    manifest: {
      permissions: ["webRequest", "webRequestBlocking", "<all_urls>"],
    },
    background() {
      browser.webRequest.onBeforeRequest.addListener(
        async details => {
          browser.test.assertEq(
            details.cookieStoreId,
            undefined,
            "cookieStoreId not set, requires cookies permission"
          );
          browser.test.notifyPass("webRequest");
        },
        { urls: ["<all_urls>"] },
        ["blocking"]
      );
    },
  });
  await extension.startup();

  let contentPage = await ExtensionTestUtils.loadContentPage(
    "http://example.com/dummy",
    { userContextId: 2 }
  );
  await extension.awaitFinish("webRequest");

  await extension.unload();
  await contentPage.close();
});
Loading