Bug 1338375 Part 2: Check that new http browser window opened from file URI page works.
authorBob Owen <bobowencode@gmail.com>
Tue, 28 Feb 2017 07:28:36 +0000
changeset 374242 08710fe142c895e87acdb1eaea5b420f07faee07
parent 374241 a009a402bd99d26d2f7b7041fe73131b75a034b4
child 374243 0f64b24c40c4c0773e8354d6c161a68c23500f85
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1338375
milestone54.0a1
Bug 1338375 Part 2: Check that new http browser window opened from file URI page works.
browser/base/content/test/general/browser.ini
browser/base/content/test/general/browser_new_http_window_opened_from_file_tab.js
browser/base/content/test/general/file_with_link_to_http.html
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -37,16 +37,17 @@ support-files =
   file_bug970276_popup2.html
   file_bug970276_favicon1.ico
   file_bug970276_favicon2.ico
   file_documentnavigation_frameset.html
   file_double_close_tab.html
   file_favicon_change.html
   file_favicon_change_not_in_document.html
   file_fullscreen-window-open.html
+  file_with_link_to_http.html
   head.js
   healthreport_pingData.js
   healthreport_testRemoteCommands.html
   moz.png
   navigating_window_with_download.html
   offlineQuotaNotification.cacheManifest
   offlineQuotaNotification.html
   page_style_sample.html
@@ -283,16 +284,17 @@ skip-if = e10s # Bug 863514 - no gesture
 skip-if = toolkit == "windows" # Disabled on Windows due to frequent failures (bug 969405)
 [browser_menuButtonFitts.js]
 skip-if = os != "win" # The Fitts Law menu button is only supported on Windows (bug 969376)
 [browser_middleMouse_noJSPaste.js]
 subsuite = clipboard
 [browser_minimize.js]
 [browser_misused_characters_in_strings.js]
 [browser_modifiedclick_inherit_principal.js]
+[browser_new_http_window_opened_from_file_tab.js]
 [browser_offlineQuotaNotification.js]
 skip-if = os == "linux" && !debug # bug 1304273
 [browser_feed_discovery.js]
 support-files = feed_discovery.html
 [browser_gZipOfflineChild.js]
 support-files = test_offline_gzip.html gZipOfflineChild.cacheManifest gZipOfflineChild.cacheManifest^headers^ gZipOfflineChild.html gZipOfflineChild.html^headers^
 [browser_overflowScroll.js]
 [browser_pageInfo.js]
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/general/browser_new_http_window_opened_from_file_tab.js
@@ -0,0 +1,54 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+
+const TEST_FILE = "file_with_link_to_http.html";
+const TEST_HTTP = "http://example.org/";
+
+// Test for bug 1338375.
+add_task(function* () {
+  // Open file:// page.
+  let dir = getChromeDir(getResolvedURI(gTestPath));
+  dir.append(TEST_FILE);
+  const uriString = Services.io.newFileURI(dir).spec;
+  let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, uriString);
+  registerCleanupFunction(function* () {
+    yield BrowserTestUtils.removeTab(tab);
+  });
+  let browser = tab.linkedBrowser;
+
+  // Set pref to open in new window.
+  Services.prefs.setIntPref("browser.link.open_newwindow", 2);
+  registerCleanupFunction(function() {
+    Services.prefs.clearUserPref("browser.link.open_newwindow");
+  });
+
+  // Open new http window from JavaScript in file:// page and check that we get
+  // a new window with the correct page and features.
+  let promiseNewWindow = BrowserTestUtils.waitForNewWindow(true, TEST_HTTP);
+  yield ContentTask.spawn(browser, TEST_HTTP, uri => {
+    content.open(uri, "_blank");
+  });
+  let win = yield promiseNewWindow;
+  registerCleanupFunction(function* () {
+    yield BrowserTestUtils.closeWindow(win);
+  });
+  ok(win, "Check that an http window loaded when using window.open.");
+  ok(win.menubar.visible,
+     "Check that the menu bar on the new window is visible.")
+  ok(win.toolbar.visible,
+     "Check that the tool bar on the new window is visible.")
+
+  // Open new http window from a link in file:// page and check that we get a
+  // new window with the correct page and features.
+  promiseNewWindow = BrowserTestUtils.waitForNewWindow(true, TEST_HTTP);
+  yield BrowserTestUtils.synthesizeMouseAtCenter("#linkToExample", {}, browser);
+  let win2 = yield promiseNewWindow;
+  registerCleanupFunction(function* () {
+    yield BrowserTestUtils.closeWindow(win2);
+  });
+  ok(win2, "Check that an http window loaded when using link.");
+  ok(win2.menubar.visible,
+     "Check that the menu bar on the new window is visible.")
+  ok(win2.toolbar.visible,
+     "Check that the tool bar on the new window is visible.")
+});
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/general/file_with_link_to_http.html
@@ -0,0 +1,9 @@
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>Test page for Bug 1338375</title>
+</head>
+<body>
+  <a id="linkToExample" href="http://example.org" target="_blank">example.org</a>
+</body>
+</html>