tor-browser

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

browser_stable_midi_port_ids.js (1433B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 const EXAMPLE_COM_URL = "https://example.com/browser/dom/midi/tests/";
      5 const EXAMPLE_ORG_URL = "https://example.org/browser/dom/midi/tests/";
      6 const PAGE1 = "port_ids_page_1.html";
      7 const PAGE2 = "port_ids_page_2.html";
      8 
      9 // Return the MIDI port id of the first input port for the given URL and page
     10 function id_for_tab(url, page) {
     11  return BrowserTestUtils.withNewTab(
     12    {
     13      gBrowser,
     14      url: url + page,
     15      waitForLoad: true,
     16    },
     17    async function (browser) {
     18      return SpecialPowers.spawn(browser, [""], function () {
     19        return content.wrappedJSObject.get_first_input_id();
     20      });
     21    }
     22  );
     23 }
     24 
     25 add_task(async function () {
     26  let com_page1;
     27  let com_page1_reload;
     28  let org_page1;
     29  let org_page2;
     30 
     31  [com_page1, com_page1_reload, org_page1, org_page2] = await Promise.all([
     32    id_for_tab(EXAMPLE_COM_URL, PAGE1),
     33    id_for_tab(EXAMPLE_COM_URL, PAGE1),
     34    id_for_tab(EXAMPLE_ORG_URL, PAGE1),
     35    id_for_tab(EXAMPLE_ORG_URL, PAGE2),
     36  ]);
     37  Assert.equal(
     38    com_page1,
     39    com_page1_reload,
     40    "MIDI port ids should be the same when reloading the same page"
     41  );
     42  Assert.notEqual(
     43    com_page1,
     44    org_page1,
     45    "MIDI port ids should be different in different origins"
     46  );
     47  Assert.equal(
     48    org_page1,
     49    org_page2,
     50    "MIDI port ids should be the same in the same origin"
     51  );
     52 });