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

Commit

Permalink
cleaning up the test/private-browsng/windows.js tests by using promises
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvold committed Feb 28, 2013
1 parent 51c55f3 commit f392e71
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions test/private-browsing/windows.js
Expand Up @@ -5,6 +5,7 @@

const { pb, pbUtils } = require('./helper');
const { openDialog, open } = require('window/utils');
const { once, close } = require('sdk/window/helpers');
const { isPrivate } = require('sdk/private-browsing');
const { browserWindows: windows } = require('sdk/windows');

Expand All @@ -16,22 +17,17 @@ exports.testPerWindowPrivateBrowsingGetter = function(assert, done) {
private: true
});

win.addEventListener('DOMContentLoaded', function onload() {
win.removeEventListener('DOMContentLoaded', onload, false);

once(win, 'DOMContentLoaded').then(function onload() {
assert.equal(pbUtils.getMode(win),
true, 'Newly opened window is in PB mode');
assert.ok(isPrivate(win), 'isPrivate(window) is true');
assert.equal(pb.isActive, false, 'PB mode is not active');

win.addEventListener("unload", function onunload() {
win.removeEventListener('unload', onload, false);
close(win).then(function() {
assert.equal(pb.isActive, false, 'PB mode is not active');
done();
}, false);

win.close();
}, false);
});
});
}

// test open() from window/utils with private feature
Expand All @@ -44,22 +40,17 @@ exports.testPerWindowPrivateBrowsingGetter = function(assert, done) {
}
});

win.addEventListener('DOMContentLoaded', function onload() {
win.removeEventListener('DOMContentLoaded', onload, false);

once(win, 'DOMContentLoaded').then(function onload() {
assert.equal(pbUtils.getMode(win),
true, 'Newly opened window is in PB mode');
assert.ok(isPrivate(win), 'isPrivate(window) is true');
assert.equal(pb.isActive, false, 'PB mode is not active');

win.addEventListener("unload", function onunload() {
win.removeEventListener('unload', onload, false);
close(win).then(function() {
assert.equal(pb.isActive, false, 'PB mode is not active');
done();
}, false);

win.close();
}, false);
});
});
}

exports.testIsPrivateOnWindowOn = function(assert, done) {
Expand Down

0 comments on commit f392e71

Please sign in to comment.