[Pkg-mozext-commits] [requestpolicy] 241/280: new mozmill test: testRequestLogShowsUriWithoutHost

David Prévot taffit at moszumanska.debian.org
Sat May 2 20:30:34 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository requestpolicy.

commit 16e1f4a0bf2b87c551cd5ba4fd88ece4722d726f
Author: Martin Kimmerle <dev at 256k.de>
Date:   Sat Mar 21 03:16:34 2015 +0100

    new mozmill test: testRequestLogShowsUriWithoutHost
    
    This commit adds a mozmill test which ensures that the request
    log will display URIs without a host.
---
 src/content/ui/xul-trees.js                        |   5 +-
 tests/mozmill/tests/manifest.ini                   |   1 +
 tests/mozmill/tests/testRequestLog/manifest.ini    |   1 +
 .../tests/testRequestLog/testUriWithoutHost.js     | 100 +++++++++++++++++++++
 4 files changed, 105 insertions(+), 2 deletions(-)

diff --git a/src/content/ui/xul-trees.js b/src/content/ui/xul-trees.js
index 203d50a..fab25d1 100644
--- a/src/content/ui/xul-trees.js
+++ b/src/content/ui/xul-trees.js
@@ -30,7 +30,7 @@ exports.toolbarbutton = [
   {parent: {special: {type: "subobject", id: "navigator-toolbox",
       tree: ["palette"]}}, // ("#navigator-toolbox".palette)
     tag: "toolbarbutton", id: "requestpolicyToolbarButton",
-    label: "RequestPolicy", tooltiptext: "RequestPolicy",//"<b>RequestPolicy</b><br />test",
+    label: "RequestPolicy", tooltiptext: "RequestPolicy",
     popup: "rp-popup"
   }
 ];
@@ -168,7 +168,8 @@ exports.mainTree = [
         {tag: "label", id: "requestpolicy-requestLog-title",
             control: "requestpolicy-requestLog-frame",
             value: "&rp.requestLog.title;", crop: "end"},
-        {tag: "button", label: "&rp.requestLog.clear;",
+        {tag: "button", id: "requestpolicy-requestLog-clear",
+            label: "&rp.requestLog.clear;",
             oncommand: "requestpolicy.overlay.clearRequestLog();"},
         {tag: "vbox", flex: "1"},
         {tag: "toolbarbutton", id: "requestpolicy-requestLog-close",
diff --git a/tests/mozmill/tests/manifest.ini b/tests/mozmill/tests/manifest.ini
index 7bfc351..5a10e51 100644
--- a/tests/mozmill/tests/manifest.ini
+++ b/tests/mozmill/tests/manifest.ini
@@ -3,3 +3,4 @@
 [include:testLinks/manifest.ini]
 [include:testPolicy/manifest.ini]
 [include:testRedirect/manifest.ini]
+[include:testRequestLog/manifest.ini]
diff --git a/tests/mozmill/tests/testRequestLog/manifest.ini b/tests/mozmill/tests/testRequestLog/manifest.ini
new file mode 100644
index 0000000..d3343f5
--- /dev/null
+++ b/tests/mozmill/tests/testRequestLog/manifest.ini
@@ -0,0 +1 @@
+[testUnknownScheme.js]
diff --git a/tests/mozmill/tests/testRequestLog/testUriWithoutHost.js b/tests/mozmill/tests/testRequestLog/testUriWithoutHost.js
new file mode 100644
index 0000000..8ba7dc4
--- /dev/null
+++ b/tests/mozmill/tests/testRequestLog/testUriWithoutHost.js
@@ -0,0 +1,100 @@
+/* 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/. */
+
+"use strict";
+
+/* global require, mozmill */
+/* exported setupModule, teardownModule, testUnknownScheme */
+
+var rpRootDir = "../../";
+var rpConst = require(rpRootDir + "lib/constants");
+var rootDir = rpRootDir + rpConst.mozmillTestsRootDir;
+
+var tabs = require(rootDir + "firefox/lib/tabs");
+
+var rpUtils = require(rpRootDir + "lib/rp-utils");
+
+const TBB_ID = "requestpolicyToolbarButton";
+var TEST_URL = "http://www.maindomain.test/scheme-unknown-and-without-host.html";
+
+
+var setupModule = function(aModule) {
+  /* global controller, tabBrowser */
+  aModule.controller = mozmill.getBrowserController();
+  aModule.tabBrowser = new tabs.tabBrowser(aModule.controller);
+  aModule.tabBrowser.closeAllTabs();
+
+  let tbb = findElement.ID(aModule.controller.window.document, TBB_ID);
+  // open the menu
+  tbb.click();
+  // wait for the menu
+  findElement.ID(controller.window.document, "rp-popup").waitForElement();
+  // open the request log
+  findElement.ID(controller.window.document, "rp-link-request-log").click();
+  // close the menu
+  tbb.click();
+
+  aModule.requestLogDoc = aModule.controller.window.document
+      .getElementById("requestpolicy-requestLog-frame").contentDocument;
+  aModule.controller.waitForPageLoad(aModule.requestLogDoc);
+
+  aModule.clearButton = findElement.ID(aModule.controller.window.document,
+                                       "requestpolicy-requestLog-clear");
+  aModule.clearButton.click();
+
+  var tree = aModule.requestLogDoc
+      .getElementById("requestpolicy-requestLog-tree")
+  aModule.treeView = tree.view;
+  aModule.destCol = tree.columns
+      .getNamedColumn("requestpolicy-requestLog-destination");
+}
+
+var teardownModule = function(aModule) {
+  let closeButton = findElement.ID(aModule.controller.window.document,
+                                   "requestpolicy-requestLog-close");
+  closeButton.click();
+  aModule.tabBrowser.closeAllTabs();
+}
+
+
+function getDestination(aRow) {
+  return treeView.getCellText(aRow, destCol);
+}
+
+function getDestinations() {
+  var destinations = [];
+  for (let i = 0, len = treeView.rowCount; i < len; ++i) {
+    destinations.push(getDestination(i));
+  }
+  return destinations;
+}
+
+function countDestination(aCompareValue) {
+  return getDestinations().filter(function (aValue) {
+    return aCompareValue === aValue;
+  }).length;
+}
+
+
+/**
+ * Test that the request log will display URIs without
+ * a host.
+ */
+var testRequestLogShowsUriWithoutHost = function() {
+  controller.open(TEST_URL);
+  controller.waitForPageLoad();
+
+  let link = rpUtils.getLink(controller);
+  let linkURI = link.getNode().href;
+
+  assert.equal(countDestination(linkURI), 0,
+               "There is no entry in the request log with '" + linkURI +
+               "' as the destination.");
+
+  link.click();
+
+  assert.equal(countDestination(linkURI), 1,
+               "There is exactly one entry in the request log with '" +
+               linkURI + "' as the destination.");
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git



More information about the Pkg-mozext-commits mailing list