tor-browser

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

browser_dead_object.js (1265B)


      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 
      6 // For bug 773980, test that Components.utils.isDeadWrapper works as expected.
      7 
      8 add_task(async function test() {
      9  const url =
     10    "http://mochi.test:8888/browser/js/xpconnect/tests/browser/browser_deadObjectOnUnload.html";
     11  let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url);
     12  let browser = gBrowser.selectedBrowser;
     13  let innerWindowId = browser.innerWindowID;
     14  let contentDocDead = await ContentTask.spawn(
     15    browser,
     16    { innerWindowId },
     17    async function (args) {
     18      let doc = content.document;
     19      let { TestUtils } = ChromeUtils.importESModule(
     20        "resource://testing-common/TestUtils.sys.mjs"
     21      );
     22      let promise = TestUtils.topicObserved("inner-window-nuked", subject => {
     23        let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
     24        return id == args.innerWindowId;
     25      });
     26      content.location = "http://mochi.test:8888/";
     27      await promise;
     28      return Cu.isDeadWrapper(doc);
     29    }
     30  );
     31  is(contentDocDead, true, "wrapper is dead");
     32  BrowserTestUtils.removeTab(newTab);
     33 });