tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

requestStorageAccess_helper.js (1089B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 /* globals browser */
      6 
      7 // Helper for calling the internal requestStorageAccessForOrigin method. The
      8 // method is called on the first-party document for the third-party which needs
      9 // first-party storage access.
     10 browser.runtime.onMessage.addListener(request => {
     11  let { requestStorageAccessOrigin, warning } = request;
     12  if (!requestStorageAccessOrigin) {
     13    return false;
     14  }
     15 
     16  // Log a warning to the web console, informing about the shim.
     17  console.warn(warning);
     18 
     19  // Call the internal storage access API. Passing false means we don't require
     20  // user activation, but will always show the storage access prompt. The user
     21  // has to explicitly allow storage access.
     22  return document
     23    .requestStorageAccessForOrigin(requestStorageAccessOrigin, false)
     24    .then(() => {
     25      return { success: true };
     26    })
     27    .catch(() => {
     28      return { success: false };
     29    });
     30 });