aboutsummaryrefslogtreecommitdiff
path: root/tools/addon-sdk-1.3/packages/api-utils/tests/test-e10s-porting.js
blob: 3dc4d32d2a342710f6d31cbf6919a1bbba49573a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// This file just runs all test suites we've white-listed as being 
// compatible with E10s. Once we're done with the porting effort,
// we'll just enable cfx's '--e10s' option by default and remove
// this file.

// This is just to serve as an indicator not to run these tests in
// the addon process.
require("chrome");

const E10S_COMPATIBLE_TEST_SUITES = [
  'test-api-utils.js',
  'test-traits-core.js',
  'test-traits.js',
  'test-list.js',
  'test-self.js'
];

exports.runE10SCompatibleTestSuites = function(test) {
  var xulApp = require("xul-app");
  if (xulApp.is("Firefox") &&
      xulApp.versionInRange(xulApp.version, "4.0b7", "4.0b8pre")) {
    test.pass("Due to bug 609066, Firefox 4.0b7 will never pass this test, " +
              "so we'll skip it.");
    return;
  }

  // If the "jetpack/service" XPCOM component is not present, then the host
  // application does not support e10s, so we can't run any e10s-compatible
  // test suites under e10s mode.
  if (!require("chrome").Cc["@mozilla.org/jetpack/service;1"]) {
    test.pass("This application does not support e10s.");
    return;
  }

  if (packaging.enableE10s) {
    // Don't worry about running these E10S-compatible test
    // suites, cfx will find them by default because its
    // '--e10s' option is enabled.
    test.pass("'cfx --e10s' detected, skipping this test.");
    return;
  }

  var {TestFinder} = require("unit-test-finder");
  var {TestRunner} = require("unit-test");
  var url = require("url");

  var thisDir = url.toFilename(url.URL('./', __url__));
  var finder = new TestFinder({
    dirs: [thisDir],
    filter: function(name) {
      return E10S_COMPATIBLE_TEST_SUITES.indexOf(name) != -1;
    },
    testInProcess: false,
    testOutOfProcess: true
  });
  var runner = new TestRunner();
  finder.findTests(function(tests) {
    test.assert(tests.length >= 1, "must find at least one test");
    runner.startMany({
      tests: tests,
      onDone: function(runner) {
        test.assertEqual(runner.failed, 0,
                         "No tests in addon process should have failed");
        test.assert(runner.passed > 0,
                    "Some tests in addon process must have been run");
        test.failed += runner.failed;
        test.passed += runner.passed;
        test.done();
      }
    });
  });
  test.waitUntilDone();
};