2014-12-05 04:50:45 +03:00
|
|
|
"use strict";
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var gTestTab;
|
|
|
|
var gContentAPI;
|
|
|
|
var gContentWindow;
|
2014-12-05 04:50:45 +03:00
|
|
|
|
|
|
|
function test() {
|
|
|
|
requestLongerTimeout(2);
|
|
|
|
UITourTest();
|
|
|
|
}
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var tests = [
|
2014-12-05 04:50:45 +03:00
|
|
|
function test_no_params(done) {
|
|
|
|
function listener(event, params) {
|
|
|
|
is(event, "test-event-1", "Correct event name");
|
2020-07-27 20:02:35 +03:00
|
|
|
ok(!params, "No param object");
|
2014-12-05 04:50:45 +03:00
|
|
|
gContentAPI.observe(null);
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
|
|
|
|
gContentAPI.observe(listener, () => {
|
|
|
|
UITour.notify("test-event-1");
|
|
|
|
});
|
|
|
|
},
|
|
|
|
function test_param_string(done) {
|
|
|
|
function listener(event, params) {
|
|
|
|
is(event, "test-event-2", "Correct event name");
|
|
|
|
is(params, "a param", "Correct param string");
|
|
|
|
gContentAPI.observe(null);
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
|
|
|
|
gContentAPI.observe(listener, () => {
|
|
|
|
UITour.notify("test-event-2", "a param");
|
|
|
|
});
|
|
|
|
},
|
|
|
|
function test_param_object(done) {
|
|
|
|
function listener(event, params) {
|
|
|
|
is(event, "test-event-3", "Correct event name");
|
|
|
|
is(
|
|
|
|
JSON.stringify(params),
|
|
|
|
JSON.stringify({ key: "something" }),
|
|
|
|
"Correct param object"
|
|
|
|
);
|
|
|
|
gContentAPI.observe(null);
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
|
|
|
|
gContentAPI.observe(listener, () => {
|
|
|
|
UITour.notify("test-event-3", { key: "something" });
|
|
|
|
});
|
|
|
|
},
|
2015-01-22 00:21:41 +03:00
|
|
|
function test_background_tab(done) {
|
|
|
|
function listener(event, params) {
|
|
|
|
is(event, "test-event-background-1", "Correct event name");
|
2020-07-27 20:02:35 +03:00
|
|
|
ok(!params, "No param object");
|
2015-01-22 00:21:41 +03:00
|
|
|
gContentAPI.observe(null);
|
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
|
|
|
|
gContentAPI.observe(listener, () => {
|
2017-05-15 22:49:50 +03:00
|
|
|
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
|
2015-01-22 00:21:41 +03:00
|
|
|
isnot(
|
|
|
|
gBrowser.selectedTab,
|
|
|
|
gTestTab,
|
|
|
|
"Make sure the selected tab changed"
|
|
|
|
);
|
|
|
|
|
|
|
|
UITour.notify("test-event-background-1");
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// Make sure the tab isn't torn down when switching back to the tour one.
|
|
|
|
function test_background_then_foreground_tab(done) {
|
|
|
|
let blankTab = null;
|
|
|
|
function listener(event, params) {
|
|
|
|
is(event, "test-event-4", "Correct event name");
|
2020-07-27 20:02:35 +03:00
|
|
|
ok(!params, "No param object");
|
2015-01-22 00:21:41 +03:00
|
|
|
gContentAPI.observe(null);
|
|
|
|
gBrowser.removeTab(blankTab);
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
|
|
|
|
gContentAPI.observe(listener, () => {
|
2017-05-15 22:49:50 +03:00
|
|
|
blankTab = gBrowser.selectedTab = BrowserTestUtils.addTab(
|
|
|
|
gBrowser,
|
|
|
|
"about:blank"
|
|
|
|
);
|
2015-01-22 00:21:41 +03:00
|
|
|
isnot(
|
|
|
|
gBrowser.selectedTab,
|
|
|
|
gTestTab,
|
|
|
|
"Make sure the selected tab changed"
|
|
|
|
);
|
|
|
|
gBrowser.selectedTab = gTestTab;
|
|
|
|
is(gBrowser.selectedTab, gTestTab, "Switch back to the test tab");
|
|
|
|
|
|
|
|
UITour.notify("test-event-4");
|
|
|
|
});
|
|
|
|
},
|
|
|
|
];
|