tor-browser

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

test_listsources-03.js (970B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Check getSources functionality when there are lots of sources.
      8 */
      9 
     10 add_task(
     11  threadFrontTest(async ({ threadFront, debuggee }) => {
     12    await executeOnNextTickAndWaitForPause(
     13      () => evalCode(debuggee),
     14      threadFront
     15    );
     16 
     17    const response = await threadFront.getSources();
     18 
     19    Assert.ok(
     20      !response.error,
     21      "There shouldn't be an error fetching large amounts of sources."
     22    );
     23 
     24    Assert.ok(
     25      response.sources.some(function (s) {
     26        return s.url.match(/foo-999.js$/);
     27      })
     28    );
     29 
     30    await threadFront.resume();
     31  })
     32 );
     33 
     34 function evalCode(debuggee) {
     35  for (let i = 0; i < 1000; i++) {
     36    Cu.evalInSandbox(
     37      "function foo###() {return ###;}".replace(/###/g, i),
     38      debuggee,
     39      "1.8",
     40      "http://example.com/foo-" + i + ".js",
     41      1
     42    );
     43  }
     44  debuggee.eval("debugger;");
     45 }