Skip to content

Ensure operations that change lox credentials do not overlap.

Merge Info

Related Issues

Backporting

Timeline

  • Immediate: patchset needed as soon as possible
  • Next Minor Stable Release: patchset that needs to be verified in nightly before backport
  • Eventually: patchset that needs to be verified in alpha before backport
  • No Backport (preferred): patchset for the next major stable

(Optional) Justification

  • Emergency security update: patchset fixes CVEs, 0-days, etc
  • Censorship event: patchset enables censorship circumvention
  • Critical bug-fix: patchset fixes a bug in core-functionality
  • Consistency: patchset which would make development easier if it were in both the alpha and release branches; developer tools, build system changes, etc
  • Sponsor required: patchset required for sponsor
  • Localization: typos and other localization changes that should be also in the release branch
  • Other: please explain

Merging

  • Merge to tor-browser - !fixups to tor-browser-specific commits, new features, security backports
  • Merge to base-browser - !fixups to base-browser-specific commits, new features to be shared with mullvad-browser, and security backports
    • NOTE: if your changeset includes patches to both base-browser and tor-browser please clearly label in the change description which commits should be cherry-picked to base-browser after merging

Issue Tracking

Review

Request Reviewer

  • Request review from an applications developer depending on modified system:
    • NOTE: if the MR modifies multiple areas, please /cc all the relevant reviewers (since gitlab only allows 1 reviewer)
    • accessibility : henry
    • android : clairehurst, dan
    • build system : boklm
    • extensions : ma1
    • firefox internals (XUL/JS/XPCOM) : jwilde, ma1
    • fonts : pierov
    • frontend (implementation) : henry
    • frontend (review) : donuts, richard
    • localization : henry, pierov
    • macOS : clairehurst, dan
    • nightly builds : boklm
    • rebases/release-prep : dan, ma1, pierov, richard
    • security : jwilde, ma1
    • signing : boklm, richard
    • updater : pierov
    • windows : jwilde, richard
    • misc/other : pierov, richard

Change Description

Convert Lox.#credentials to a Map. Ensure that any task that changes the credentials is wrapped in #changeCredentials, which should wait for any previous credentials task to complete.

The changes were linted in a second commit to make the first one's diff easier to read.

How Tested

Could not test the real methods because I don't have a Lox invite. I was able to spoof some task though. I added to Lox:

  async fakeTask(loxId, name, result, win) {
    const res = await this.#changeCredentials(loxId, async cred => {
      console.log("STARTING:", name, cred);
      await new Promise(res => win.setTimeout(res, 5000));
      console.log("COMPLETE:", name);
      if (result?.constructor.name === "Error") {
        throw result;
      }
      return result;
    });
    console.log("EXIT:", name, res);
  }

You can changed lox.settings.credentials to be {"fake1":"initial-1","fake2":"initial-2"}, and then run in the browser terminal

const { Lox } = ChromeUtils.importESModule("resource://gre/modules/Lox.sys.mjs");
doTasks = () => {
  Lox.fakeTask("fake1", "task1", "cred-1-1", window);
  Lox.fakeTask("fake1", "task2", null, window);
  Lox.fakeTask("fake2", "taskX", "cred-2-X", window);
  Lox.fakeTask("fake1", "task3", new Error("MY LOX ERROR"), window);
  Lox.fakeTask("fake1", "task4", "cred-1-4", window);
  setTimeout(() => {
    Lox.fakeTask("fake1", "task5", "cred-1-5", window); 
    Lox.fakeTask("fake2", "taskY", "cred-2-Y", window)
  });
};
doTasks();

Result is

console.log: "STARTING:" "task1" "initial-1"
console.log: "STARTING:" "taskX" "initial-2"
console.log: "COMPLETE:" "task1"
console.log: "STARTING:" "task2" "cred-1-1"
console.log: "EXIT:" "task1" "cred-1-1"
console.log: "COMPLETE:" "taskX"
console.log: "STARTING:" "taskY" "cred-2-X"
console.log: "EXIT:" "taskX" "cred-2-X"
console.log: "COMPLETE:" "task2"
console.log: "STARTING:" "task3" "cred-1-1"
console.log: "EXIT:" "task2" null
console.log: "COMPLETE:" "taskY"
console.log: "EXIT:" "taskY" "cred-2-Y"
console.log: "COMPLETE:" "task3"
console.log: "STARTING:" "task4" "cred-1-1"
JavaScript error: debugger eval code, line 6: Error: MY LOX ERROR
console.log: "COMPLETE:" "task4"
console.log: "STARTING:" "task5" "cred-1-4"
console.log: "EXIT:" "task4" "cred-1-4"
console.log: "COMPLETE:" "task5"
console.log: "EXIT:" "task5" "cred-1-5"
Edited by henry

Merge request reports

Loading