tor-browser

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

head.js (1016B)


      1 const { UIState } = ChromeUtils.importESModule(
      2  "resource://services-sync/UIState.sys.mjs"
      3 );
      4 const { sinon } = ChromeUtils.importESModule(
      5  "resource://testing-common/Sinon.sys.mjs"
      6 );
      7 
      8 function promiseSyncReady() {
      9  let service = Cc["@mozilla.org/weave/service;1"].getService(
     10    Ci.nsISupports
     11  ).wrappedJSObject;
     12  return service.whenLoaded();
     13 }
     14 
     15 function setupSendTabMocks({
     16  fxaDevices = null,
     17  state = UIState.STATUS_SIGNED_IN,
     18  isSendableURI = true,
     19 }) {
     20  const sandbox = sinon.createSandbox();
     21  sandbox.stub(fxAccounts.device, "recentDeviceList").get(() => fxaDevices);
     22  sandbox.stub(UIState, "get").returns({
     23    status: state,
     24    syncEnabled: true,
     25  });
     26  if (isSendableURI) {
     27    sandbox.stub(BrowserUtils, "getShareableURL").returnsArg(0);
     28  } else {
     29    sandbox.stub(BrowserUtils, "getShareableURL").returns(null);
     30  }
     31  sandbox.stub(fxAccounts.device, "refreshDeviceList").resolves(true);
     32  sandbox.stub(fxAccounts.commands.sendTab, "send").resolves({ failed: [] });
     33  return sandbox;
     34 }