tor-browser

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

head.js (3477B)


      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-disable no-unused-vars */
      6 
      7 "use strict";
      8 
      9 Services.scriptloader.loadSubScript(
     10  "chrome://mochitests/content/browser/devtools/client/debugger/test/mochitest/head.js",
     11  this
     12 );
     13 
     14 /**
     15 * Helper function for `_loadAllIntegrationTests`.
     16 *
     17 * Implements this as a global method in order to please eslint.
     18 * This will be used by modules loaded from "integration-tests" folder
     19 * in order to register a new integration task, ran when executing `runAllIntegrationTests`.
     20 */
     21 const integrationTasks = [];
     22 function addIntegrationTask(fun) {
     23  integrationTasks.push(fun);
     24 }
     25 
     26 /**
     27 * Helper function for `runAllIntegrationTests`.
     28 *
     29 * Loads all the modules from "integration-tests" folder and return
     30 * all the task they implemented and registered by calling `addIntegrationTask`.
     31 */
     32 function _loadAllIntegrationTests() {
     33  const testsDir = getChromeDir(getResolvedURI(gTestPath));
     34  testsDir.append("integration-tests");
     35  const entries = testsDir.directoryEntries;
     36  const urls = [];
     37  while (entries.hasMoreElements()) {
     38    const file = entries.nextFile;
     39    const url = Services.io.newFileURI(file).spec;
     40    if (url.endsWith(".js")) {
     41      urls.push(url);
     42    }
     43  }
     44 
     45  // We need to sort in order to run the test in a reliable order
     46  urls.sort();
     47 
     48  for (const url of urls) {
     49    Services.scriptloader.loadSubScript(url, this);
     50  }
     51  return integrationTasks;
     52 }
     53 
     54 /**
     55 * Method to be called by each integration tests which will
     56 * run all the "integration tasks" implemented in files from the "integration-tests" folder.
     57 * These files should call the `addIntegrationTask()` method to register something to run.
     58 *
     59 * @param {string} testFolder
     60 *        Define what folder in "examples" folder to load before opening the debugger.
     61 *        This is meant to be a versionized test folder with v1, v2, v3 folders.
     62 *        (See createVersionizedHttpTestServer())
     63 * @param {object} env
     64 *        Environment object passed down to each task to better know
     65 *        which particular integration test is being run.
     66 */
     67 async function runAllIntegrationTests(testFolder, env) {
     68  const tasks = _loadAllIntegrationTests();
     69 
     70  const testServer = createVersionizedHttpTestServer(
     71    "../examples/" + testFolder
     72  );
     73  const testUrl = testServer.urlFor("index.html");
     74 
     75  for (const task of tasks) {
     76    info(` ==> Running integration task '${task.name}'`);
     77    await task(testServer, testUrl, env);
     78  }
     79 }
     80 
     81 const INTEGRATION_TEST_PAGE_SOURCES = [
     82  "index.html",
     83  "iframe.html",
     84  "script.js",
     85  "onload.js",
     86  "test-functions.js",
     87  "query.js?x=1",
     88  "query.js?x=2",
     89  "query2.js?y=3",
     90  "bundle.js",
     91  "original.js",
     92  "bundle-with-another-original.js",
     93  "original-with-no-update.js",
     94  "replaced-bundle.js",
     95  "removed-original.js",
     96  "named-eval.js",
     97  "react-component-module.js",
     98  // This is the JS file with encoded characters and custom protocol
     99  "文字コード.js",
    100  // Webpack generated some extra sources:
    101  "bootstrap 3b1a221408fdde86aa49",
    102  "bootstrap a1ecee2f86e1d0ea3fb5",
    103  "bootstrap d343aa81956b90d9f67e",
    104  // There is 3 occurences, one per target (main thread, worker and iframe).
    105  // But there is even more source actors (named evals and duplicated script tags).
    106  "same-url.sjs",
    107  "same-url.sjs",
    108  "log-worker.js",
    109  "same-url.sjs",
    110 ];