tor-browser

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

process_switch.js (1865B)


      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 /* eslint-env node */
      6 
      7 const { logTest, logTask } = require("./utils/profiling");
      8 
      9 module.exports = logTest(
     10  "process switch test",
     11  async function (context, commands) {
     12    context.log.info("Starting a process switch test");
     13    let urlstr = context.options.browsertime.url;
     14    let page_cycles = context.options.browsertime.page_cycles;
     15    let page_cycle_delay = context.options.browsertime.page_cycle_delay;
     16    let post_startup_delay = context.options.browsertime.post_startup_delay;
     17 
     18    // Get the two urls to use in the test (the second one will be measured)
     19    let urls = urlstr.split(",");
     20    if (urls.length != 2) {
     21      context.log.error(
     22        `Wrong number of urls given. Expecting: 2, Given: ${urls.length}`
     23      );
     24      return false;
     25    }
     26 
     27    context.log.info(
     28      "Waiting for %d ms (post_startup_delay)",
     29      post_startup_delay
     30    );
     31    await commands.wait.byTime(post_startup_delay);
     32 
     33    for (let count = 0; count < page_cycles; count++) {
     34      await logTask(context, "cycle " + count, async function () {
     35        context.log.info("Navigating to about:blank");
     36        await commands.navigate("about:blank");
     37 
     38        context.log.info(
     39          "Cycle %d, waiting for %d ms",
     40          count,
     41          page_cycle_delay
     42        );
     43        await commands.wait.byTime(page_cycle_delay);
     44        context.log.info("Cycle %d, starting the measure", count);
     45 
     46        await commands.navigate(urls[0]);
     47        await commands.wait.byTime(3000);
     48        await commands.measure.start(urls[1]);
     49        await commands.wait.byTime(2000);
     50      });
     51    }
     52 
     53    context.log.info("Process switch test ended.");
     54    return true;
     55  }
     56 );