tor-browser

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

browser_465223.js (1632B)


      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 add_task(async function test_clearWindowValues() {
      6  /** Test for Bug 465223 */
      7 
      8  let uniqueKey1 = "bug 465223.1";
      9  let uniqueKey2 = "bug 465223.2";
     10  let uniqueValue1 = "unik" + Date.now();
     11  let uniqueValue2 = "pi != " + Math.random();
     12 
     13  // open a window and set a value on it
     14  let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
     15  await promiseWindowLoaded(newWin);
     16  ss.setCustomWindowValue(newWin, uniqueKey1, uniqueValue1);
     17 
     18  let newState = { windows: [{ tabs: [{ entries: [] }], extData: {} }] };
     19  newState.windows[0].extData[uniqueKey2] = uniqueValue2;
     20  await setWindowState(newWin, newState);
     21 
     22  is(newWin.gBrowser.tabs.length, 2, "original tab wasn't overwritten");
     23  is(
     24    ss.getCustomWindowValue(newWin, uniqueKey1),
     25    uniqueValue1,
     26    "window value wasn't overwritten when the tabs weren't"
     27  );
     28  is(
     29    ss.getCustomWindowValue(newWin, uniqueKey2),
     30    uniqueValue2,
     31    "new window value was correctly added"
     32  );
     33 
     34  newState.windows[0].extData[uniqueKey2] = uniqueValue1;
     35  await setWindowState(newWin, newState, true);
     36 
     37  is(newWin.gBrowser.tabs.length, 1, "original tabs were overwritten");
     38  is(
     39    ss.getCustomWindowValue(newWin, uniqueKey1),
     40    "",
     41    "window value was cleared"
     42  );
     43  is(
     44    ss.getCustomWindowValue(newWin, uniqueKey2),
     45    uniqueValue1,
     46    "window value was correctly overwritten"
     47  );
     48 
     49  // clean up
     50  await BrowserTestUtils.closeWindow(newWin);
     51 });