Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
bug 1053997 - reduce e10s crash potential
Browse files Browse the repository at this point in the history
  • Loading branch information
zombie committed Aug 14, 2014
1 parent ded315e commit 3360de7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 deletions.
44 changes: 15 additions & 29 deletions test/addons/e10s-tabs/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,25 @@ const { merge } = require('sdk/util/object');
const { version } = require('sdk/system');
const { getMostRecentBrowserWindow } = require('sdk/window/utils');
const { promise: windowPromise, close, focus } = require('sdk/window/helpers');
const { when } = require('sdk/system/unload');

// run e10s tests only on builds from trunk, fx-team, Nightly..
if (!version.endsWith('a1')) {
module.exports = {};
}

function openE10sWindow() {
let window = getMostRecentBrowserWindow().OpenBrowserWindow({ remote: true });
return windowPromise(window, 'load').then(focus);
function replaceWindow(remote) {
let old = getMostRecentBrowserWindow();
let window = old.OpenBrowserWindow({ remote });
return windowPromise(window, 'load').then(focus).then(_ => close(old));
}

function makeE10sTests(exports) {
let newExports = {};
// merge(module.exports, require('./test-tab'));
merge(module.exports, require('./test-tab-events'));
merge(module.exports, require('./test-tab-observer'));
merge(module.exports, require('./test-tab-utils'));

for (let key of Object.keys(exports)) {
if (typeof(exports[key]) == "function" && key.substring(0, 4) == "test") {
let testFunction = exports[key];
newExports[key] = function(assert, done) {
openE10sWindow().then(window => {
testFunction(assert, () => {
close(window).then(done);
});
});
}
}
}

return newExports;
// run e10s tests only on builds from trunk, fx-team, Nightly..
if (!version.endsWith('a1')) {
module.exports = {};
}

merge(module.exports, makeE10sTests(require('./test-tab')));
merge(module.exports, makeE10sTests(require('./test-tab-events')));
merge(module.exports, makeE10sTests(require('./test-tab-observer')));
merge(module.exports, makeE10sTests(require('./test-tab-utils')));
replaceWindow(true).then(_ =>
require('sdk/test/runner').runTestsFromModule(module));

require('sdk/test/runner').runTestsFromModule(module);
when(_ => replaceWindow(false));
4 changes: 2 additions & 2 deletions test/addons/e10s-tabs/lib/test-tab-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (isWindowPBSupported) {
assert.equal(isPrivate(window), false, 'all found windows are not private');
});

assert.equal(windows(null, {includePrivate: true}).length, 3, 'there are really three windows');
assert.equal(windows(null, {includePrivate: true}).length, 2, 'there are really two windows');

close(window).then(done);
});
Expand All @@ -57,7 +57,7 @@ else if (isTabPBSupported) {
'there are two tabs found');
assert.equal(utils_tabs[utils_tabs.length-1], tab,
'the last tab is the opened tab');
assert.equal(browserWindows.length, 2, 'there is only two windows');
assert.equal(browserWindows.length, 1, 'there is only one window');
closeTab(tab);

done();
Expand Down

0 comments on commit 3360de7

Please sign in to comment.