Bug 1367583 - Add a unit test for links in resource:// listings. r=mossop
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 25 May 2017 10:54:01 +0900
changeset 409054 04d8a87a833d8cd534bb4faa1ec2d45e32415bdb
parent 409053 cc7b19b52df4b1c25d003d2e6deb2007f780cfa6
child 409055 adff9e8ebb3c68949003d8e8b4691a6a5afe4bc8
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1367583
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1367583 - Add a unit test for links in resource:// listings. r=mossop
netwerk/test/browser/browser.ini
netwerk/test/browser/browser_resource_navigation.js
--- a/netwerk/test/browser/browser.ini
+++ b/netwerk/test/browser/browser.ini
@@ -4,8 +4,9 @@ support-files =
 
 [browser_about_cache.js]
 [browser_NetUtil.js]
 [browser_child_resource.js]
 skip-if = e10s && debug && os == "linux" && bits == 64
 [browser_post_file.js]
 [browser_nsIFormPOSTActionChannel.js]
 skip-if = e10s # protocol handler and channel does not work in content process
+[browser_resource_navigation.js]
new file mode 100644
--- /dev/null
+++ b/netwerk/test/browser/browser_resource_navigation.js
@@ -0,0 +1,53 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+"use strict";
+
+add_task(async function() {
+  info("Make sure navigation through links in resource:// pages work");
+
+  await BrowserTestUtils.withNewTab({ gBrowser, url: "resource://gre/" }, async function(browser) {
+    // Following a directory link shall properly open the directory (bug 1224046)
+    await ContentTask.spawn(browser, {}, function() {
+      let link = Array.prototype.filter.call(content.document.getElementsByClassName('dir'), function(element) {
+        let name = element.textContent;
+        // Depending whether resource:// is backed by jar: or file://,
+        // directories either have a trailing slash or they don't.
+        if (name.endsWith("/")) {
+          name = name.slice(0, -1);
+        }
+        return name == "components";
+      })[0];
+      // First ensure the link is in the viewport
+      link.scrollIntoView();
+      // Then click on it.
+      link.click();
+    });
+
+    await BrowserTestUtils.browserLoaded(browser, undefined, "resource://gre/components/");
+
+    // Following the parent link shall properly open the parent (bug 1366180)
+    await ContentTask.spawn(browser, {}, function() {
+      let link = content.document.getElementById('UI_goUp').getElementsByTagName('a')[0];
+      // The link should always be high enough in the page to be in the viewport.
+      link.click();
+    });
+
+    await BrowserTestUtils.browserLoaded(browser, undefined, "resource://gre/");
+
+    // Following a link to a given file shall properly open the file.
+    await ContentTask.spawn(browser, {}, function() {
+      let link = Array.prototype.filter.call(content.document.getElementsByClassName('file'), function(element) {
+        return element.textContent == "greprefs.js";
+      })[0];
+      link.scrollIntoView();
+      link.click();
+    });
+
+    await BrowserTestUtils.browserLoaded(browser, undefined, "resource://gre/greprefs.js");
+
+    ok(true, "Got to the end of the test!");
+  });
+});