summaryrefslogtreecommitdiffstats
path: root/browser/components/uitour/test/browser_UITour_observe.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /browser/components/uitour/test/browser_UITour_observe.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/components/uitour/test/browser_UITour_observe.js')
-rw-r--r--browser/components/uitour/test/browser_UITour_observe.js85
1 files changed, 85 insertions, 0 deletions
diff --git a/browser/components/uitour/test/browser_UITour_observe.js b/browser/components/uitour/test/browser_UITour_observe.js
new file mode 100644
index 000000000..b4b435659
--- /dev/null
+++ b/browser/components/uitour/test/browser_UITour_observe.js
@@ -0,0 +1,85 @@
+"use strict";
+
+var gTestTab;
+var gContentAPI;
+var gContentWindow;
+
+function test() {
+ requestLongerTimeout(2);
+ UITourTest();
+}
+
+var tests = [
+ function test_no_params(done) {
+ function listener(event, params) {
+ is(event, "test-event-1", "Correct event name");
+ is(params, null, "No param object");
+ 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"});
+ });
+ },
+ function test_background_tab(done) {
+ function listener(event, params) {
+ is(event, "test-event-background-1", "Correct event name");
+ is(params, null, "No param object");
+ gContentAPI.observe(null);
+ gBrowser.removeCurrentTab();
+ done();
+ }
+
+ gContentAPI.observe(listener, () => {
+ gBrowser.selectedTab = gBrowser.addTab("about:blank");
+ 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");
+ is(params, null, "No param object");
+ gContentAPI.observe(null);
+ gBrowser.removeTab(blankTab);
+ done();
+ }
+
+ gContentAPI.observe(listener, () => {
+ blankTab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+ 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");
+ });
+ },
+];