summaryrefslogtreecommitdiffstats
path: root/dom/broadcastchannel/tests/browser_private_browsing.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 /dom/broadcastchannel/tests/browser_private_browsing.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 'dom/broadcastchannel/tests/browser_private_browsing.js')
-rw-r--r--dom/broadcastchannel/tests/browser_private_browsing.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/dom/broadcastchannel/tests/browser_private_browsing.js b/dom/broadcastchannel/tests/browser_private_browsing.js
new file mode 100644
index 000000000..5724225fc
--- /dev/null
+++ b/dom/broadcastchannel/tests/browser_private_browsing.js
@@ -0,0 +1,74 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+const URL = "http://mochi.test:8888/browser/dom/broadcastchannel/tests/blank.html";
+
+add_task(function*() {
+ var win1 = OpenBrowserWindow({private: true});
+ var win1Promise = new win1.Promise(resolve => {
+ win1.addEventListener("load", function onLoad() {
+ win1.removeEventListener("load", onLoad, false);
+ resolve();
+ });
+ });
+ yield win1Promise;
+
+ var win2 = OpenBrowserWindow({private: false});
+ var win2Promise = new win2.Promise(resolve => {
+ win2.addEventListener("load", function onLoad() {
+ win2.removeEventListener("load", onLoad, false);
+ resolve();
+ });
+ });
+ yield win2Promise;
+
+ var tab1 = win1.gBrowser.addTab(URL);
+ yield BrowserTestUtils.browserLoaded(win1.gBrowser.getBrowserForTab(tab1));
+ var browser1 = gBrowser.getBrowserForTab(tab1);
+
+ var tab2 = win2.gBrowser.addTab(URL);
+ yield BrowserTestUtils.browserLoaded(win2.gBrowser.getBrowserForTab(tab2));
+ var browser2 = gBrowser.getBrowserForTab(tab2);
+
+ var p1 = ContentTask.spawn(browser1, null, function(opts) {
+ return new content.window.Promise(resolve => {
+ content.window.bc = new content.window.BroadcastChannel('foobar');
+ content.window.bc.onmessage = function(e) { resolve(e.data); }
+ });
+ });
+
+ var p2 = ContentTask.spawn(browser2, null, function(opts) {
+ return new content.window.Promise(resolve => {
+ content.window.bc = new content.window.BroadcastChannel('foobar');
+ content.window.bc.onmessage = function(e) { resolve(e.data); }
+ });
+ });
+
+ yield ContentTask.spawn(browser1, null, function(opts) {
+ return new content.window.Promise(resolve => {
+ var bc = new content.window.BroadcastChannel('foobar');
+ bc.postMessage('hello world from private browsing');
+ resolve();
+ });
+ });
+
+ yield ContentTask.spawn(browser2, null, function(opts) {
+ return new content.window.Promise(resolve => {
+ var bc = new content.window.BroadcastChannel('foobar');
+ bc.postMessage('hello world from non private browsing');
+ resolve();
+ });
+ });
+
+ var what1 = yield p1;
+ ok(what1, 'hello world from private browsing', 'No messages received from the other window.');
+
+ var what2 = yield p2;
+ ok(what1, 'hello world from non private browsing', 'No messages received from the other window.');
+
+ yield BrowserTestUtils.removeTab(tab1);
+ yield BrowserTestUtils.closeWindow(win1);
+
+ yield BrowserTestUtils.removeTab(tab2);
+ yield BrowserTestUtils.closeWindow(win2);
+});