summaryrefslogtreecommitdiffstats
path: root/embedding/components/windowwatcher/test/browser_new_content_window_from_chrome_principal.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 /embedding/components/windowwatcher/test/browser_new_content_window_from_chrome_principal.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 'embedding/components/windowwatcher/test/browser_new_content_window_from_chrome_principal.js')
-rw-r--r--embedding/components/windowwatcher/test/browser_new_content_window_from_chrome_principal.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/embedding/components/windowwatcher/test/browser_new_content_window_from_chrome_principal.js b/embedding/components/windowwatcher/test/browser_new_content_window_from_chrome_principal.js
new file mode 100644
index 000000000..c8a24d43e
--- /dev/null
+++ b/embedding/components/windowwatcher/test/browser_new_content_window_from_chrome_principal.js
@@ -0,0 +1,34 @@
+"use strict";
+
+/**
+ * Tests that if chrome-privileged code calls .open() on an
+ * unprivileged window, that the principal in the newly
+ * opened window is appropriately set.
+ */
+add_task(function* test_chrome_opens_window() {
+ // This magic value of 2 means that by default, when content tries
+ // to open a new window, it'll actually open in a new window instead
+ // of a new tab.
+ yield SpecialPowers.pushPrefEnv({"set": [
+ ["browser.link.open_newwindow", 2],
+ ]});
+
+ let newWinPromise = BrowserTestUtils.waitForNewWindow(true, "http://example.com/");
+
+ yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() {
+ content.open("http://example.com/", "_blank");
+ });
+
+ let win = yield newWinPromise;
+ let browser = win.gBrowser.selectedBrowser;
+
+ yield ContentTask.spawn(browser, null, function*() {
+ Assert.ok(!content.document.nodePrincipal.isSystemPrincipal,
+ "We should not have a system principal.")
+ Assert.equal(content.document.nodePrincipal.origin,
+ "http://example.com",
+ "Should have the example.com principal");
+ });
+
+ yield BrowserTestUtils.closeWindow(win);
+}); \ No newline at end of file