Skip to content

Commit c6a55f6

Browse files
committed
Improve sample ruleset test.
Make it wait for a specific tab to be ready, rather than any tab, and close tab when done.
1 parent a316aa2 commit c6a55f6

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

https-everywhere-tests/test/test-httpse-installed.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Test that HTTPS Everywhere component is installed and accessible
22

33
const { Cc, Ci } = require("chrome");
4+
var tabs = require("sdk/tabs");
45

56
let HTTPSEverywhere = Cc["@eff.org/https-everywhere;1"]
67
.getService(Ci.nsISupports)
@@ -21,15 +22,17 @@ exports["test httpse potentiallyApplicableRulesets"] = function(assert) {
2122
}
2223

2324
exports["test sample ruleset"] = function(assert, done) {
24-
var tabs = require("sdk/tabs");
25-
26-
tabs.on('ready', function(tab) {
27-
assert.equal(tab.url, "https://www.reddit.com/robots.txt",
28-
"Test that Reddit URLs are rewritten to HTTPS.");
29-
done();
25+
tabs.open({
26+
url: "http://www.reddit.com/robots.txt",
27+
onOpen: function(tab) {
28+
tab.on('load', function(tab) {
29+
assert.equal(tab.url, "http://www.reddit.com/robots.txt",
30+
"Test that Reddit URLs are rewritten to HTTPS.");
31+
tab.close();
32+
done();
33+
});
34+
}
3035
});
31-
32-
tabs.open("http://www.reddit.com/robots.txt");
3336
}
3437

3538
require("sdk/test").run(exports);

0 commit comments

Comments
 (0)