summaryrefslogtreecommitdiffstats
path: root/services/cloudsync/tests/mochitest/browser_tabEvents.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 /services/cloudsync/tests/mochitest/browser_tabEvents.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 'services/cloudsync/tests/mochitest/browser_tabEvents.js')
-rw-r--r--services/cloudsync/tests/mochitest/browser_tabEvents.js79
1 files changed, 79 insertions, 0 deletions
diff --git a/services/cloudsync/tests/mochitest/browser_tabEvents.js b/services/cloudsync/tests/mochitest/browser_tabEvents.js
new file mode 100644
index 000000000..9d80090a0
--- /dev/null
+++ b/services/cloudsync/tests/mochitest/browser_tabEvents.js
@@ -0,0 +1,79 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+function test() {
+
+ let local = {};
+
+ Components.utils.import("resource://gre/modules/CloudSync.jsm", local);
+ Components.utils.import("resource:///modules/sessionstore/TabStateFlusher.jsm", local);
+
+ let cloudSync = local.CloudSync();
+ let opentabs = [];
+
+ waitForExplicitFinish();
+
+ let testURL = "chrome://mochitests/content/browser/services/cloudsync/tests/mochitest/other_window.html";
+ let expected = [
+ testURL,
+ testURL+"?x=1",
+ testURL+"?x=%20a",
+ // testURL+"?x=å",
+ ];
+
+ let nevents = 0;
+ let nflushed = 0;
+ function handleTabChangeEvent () {
+ cloudSync.tabs.removeEventListener("change", handleTabChangeEvent);
+ ++ nevents;
+ info("tab change event " + nevents);
+ next();
+ }
+
+ function getLocalTabs() {
+ cloudSync.tabs.getLocalTabs().then(
+ function (tabs) {
+ for (let tab of tabs) {
+ ok(expected.indexOf(tab.url) >= 0, "found an expected tab");
+ }
+
+ is(tabs.length, expected.length, "found the right number of tabs");
+
+ opentabs.forEach(function (tab) {
+ gBrowser.removeTab(tab);
+ });
+
+ is(nevents, 1, "expected number of change events");
+
+ finish();
+ }
+ )
+ }
+
+ cloudSync.tabs.addEventListener("change", handleTabChangeEvent);
+
+ expected.forEach(function(url) {
+ let tab = gBrowser.addTab(url);
+
+ function flush() {
+ tab.linkedBrowser.removeEventListener("load", flush, true);
+ local.TabStateFlusher.flush(tab.linkedBrowser).then(() => {
+ ++ nflushed;
+ info("flushed " + nflushed);
+ next();
+ });
+ }
+
+ tab.linkedBrowser.addEventListener("load", flush, true);
+
+ opentabs.push(tab);
+ });
+
+ function next() {
+ if (nevents == 1 && nflushed == expected.length) {
+ getLocalTabs();
+ }
+ }
+
+}