Skip to content

Instantly share code, notes, and snippets.

@modeswitch
Created September 4, 2014 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save modeswitch/1f8dc018331b625c7431 to your computer and use it in GitHub Desktop.
Save modeswitch/1f8dc018331b625c7431 to your computer and use it in GitHub Desktop.
/* 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/TabState.jsm", local);
let cloudSync = local.CloudSync();
let opentabs = [];
waitForExplicitFinish();
let testURL = "http://mochi.test:8888/services/" +
"cloudsync/tests/mochitest/other_window.html";
function handleTabChangeEvent () {
cloudSync.tabs.removeEventListener("change", handleTabChangeEvent);
ok(true, "tab change event");
cloudSync.tabs.getLocalTabs().then(
function (tabs) {
let expectedTabsFound = 0;
for (let tab of tabs) {
if (tab.url == "chrome://mochitests/content/chrome/services/cloudsync/tests/mochitest/other_window.html?a=1" ||
tab.url == "chrome://mochitests/content/chrome/services/cloudsync/tests/mochitest/other_window.html?b=%C3%A5%20%C3%A4%20%C3%B6") {
}
expectedTabsFound ++;
}
is(expectedTabsFound, 2, "found the tabs we opened");
opentabs.forEach(function (tab) {
gBrowser.removeTab(tab);
});
finish();
}
)
}
cloudSync.tabs.addEventListener("change", handleTabChangeEvent);
opentabs.push(gBrowser.addTab(testURL+"?a=1"));
opentabs.push(gBrowser.addTab(testURL+"?b=å%20ä%20ö"));
opentabs.forEach(function(tab) {
local.TabState.flush(tab.linkedBrowser);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment