[Pkg-mozext-commits] [requestpolicy] 89/280: bug found: not always display the redir.notif.bar!
David Prévot
taffit at moszumanska.debian.org
Sat May 2 20:30:04 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 202237789ac4e021c7dcda31d5d76e0dee0bdb83
Author: Martin Kimmerle <dev at 256k.de>
Date: Wed Dec 31 15:39:22 2014 +0100
bug found: not always display the redir.notif.bar!
Currently the redirection notification bar is displayed if *any*
request in a Tab causes a redirect. But instead, it should only
be displayed in case of an explicit user interaction, i.e an url
is entered in the location bar or a link has been clicked.
A mozmill test has already been created, but it's disabled for
now: tests/mozmill/tests/testRedirect/testInlineRedirect.js
---
src/content/lib/request-processor.redirects.js | 10 ++++
tests/content/redirect-inline-image.html | 19 +++++++
tests/mozmill/tests/testRedirect/manifest.ini | 1 +
.../tests/testRedirect/testInlineRedirect.js | 61 ++++++++++++++++++++++
4 files changed, 91 insertions(+)
diff --git a/src/content/lib/request-processor.redirects.js b/src/content/lib/request-processor.redirects.js
index 76bced3..51d9c89 100644
--- a/src/content/lib/request-processor.redirects.js
+++ b/src/content/lib/request-processor.redirects.js
@@ -249,6 +249,16 @@ let RequestProcessor = (function(self) {
// show the URL of the previously displayed page.
httpChannel.cancel(Cr.NS_BINDING_ABORTED);
+ // TODO: show the redirect notification *only* when
+ // a) a link has been clicked
+ // b) an url has been entered.
+ // In any other case the redirect should *not* cause a notific.
+ // bar to be displayed, because the redirect hasn't been caused by
+ // *explicit* user interaction.
+ // Examples for such other cases are inline elements whose
+ // destination causes a redirect (via a HTTP Header), e.g. <img>.
+ // Note: As soon as this is fixed, enable this mozmill test:
+ // tests/mozmill/tests/testRedirect/testInlineRedirect.js
showRedirectNotification(request) || Logger.warning(
Logger.TYPE_HEADER_REDIRECT,
"A redirect has been observed, but it was not possible to notify " +
diff --git a/tests/content/redirect-inline-image.html b/tests/content/redirect-inline-image.html
new file mode 100644
index 0000000..d14c6d5
--- /dev/null
+++ b/tests/content/redirect-inline-image.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ </head>
+ <body>
+
+ <p>
+ This page contains inline images.
+ The `src` of the <img> produces a redirect.
+ </p>
+
+ <img src="redirect-http-location-header-png.php" />
+ <img src="http://www.maindomain.test/redirect-http-location-header-png.php" />
+ <img src="http://www.otherdomain.test/redirect-http-location-header-png.php" />
+ <img src="http://www.otherdomain.test/redirect-http-location-header-png.php" />
+
+ </body>
+</html>
diff --git a/tests/mozmill/tests/testRedirect/manifest.ini b/tests/mozmill/tests/testRedirect/manifest.ini
index c680174..f432235 100644
--- a/tests/mozmill/tests/testRedirect/manifest.ini
+++ b/tests/mozmill/tests/testRedirect/manifest.ini
@@ -2,3 +2,4 @@
[testAutoRedirect.js]
[testLinkClickRedirect.js]
+#[testInlineRedirect.js]
diff --git a/tests/mozmill/tests/testRedirect/testInlineRedirect.js b/tests/mozmill/tests/testRedirect/testInlineRedirect.js
new file mode 100644
index 0000000..08c3384
--- /dev/null
+++ b/tests/mozmill/tests/testRedirect/testInlineRedirect.js
@@ -0,0 +1,61 @@
+/* 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";
+
+var {assert, expect} = require("../../../../../../lib/assertions");
+var prefs = require("../../../../../lib/prefs");
+var tabs = require("../../../../../lib/tabs");
+
+var rpUtils = require("../../lib/rp-utils");
+var rpConst = require("../../lib/constants");
+
+var testURLPrePath = "http://www.maindomain.test/";
+var urlsWithInlineRedirect = [
+ "redirect-inline-image.html",
+];
+
+
+var setupModule = function(aModule) {
+ aModule.controller = mozmill.getBrowserController();
+ aModule.tabBrowser = new tabs.tabBrowser(aModule.controller);
+ aModule.tabBrowser.closeAllTabs();
+
+ prefs.preferences.setPref(rpConst.PREF_DEFAULT_ALLOW, false);
+}
+
+var teardownModule = function(aModule) {
+ prefs.preferences.clearUserPref(rpConst.PREF_DEFAULT_ALLOW);
+ aModule.tabBrowser.closeAllTabs();
+}
+
+
+/**
+ * This test ensures that the redirection notification bar is *not* shown when
+ * an inline element such as <img> has caused a redirect.
+ */
+var testInlineRedirect = function() {
+ var tabIndex = tabBrowser.selectedIndex;
+
+ var panel = tabBrowser.getTabPanelElement(tabIndex,
+ '/{"value":"' + rpConst.REDIRECT_NOTIFICATION_VALUE + '"}');
+
+ for (let testURL of urlsWithInlineRedirect) {
+ testURL = testURLPrePath + testURL;
+ controller.open(testURL);
+
+ controller.waitForPageLoad();
+ controller.sleep(1000);
+
+ expect.ok(!panel.exists(), "The redirect notification bar is hidden.");
+
+ tabBrowser.closeAllTabs();
+
+ // It's necessary to wait for the notification panel to be closed. If we
+ // don't wait for that to happen, the next URL in urlsWithInlineRedirect
+ // might already be displayed while the panel is still there.
+ controller.waitFor((() => !panel.exists()), "No panel is being displayed " +
+ "because all tabs have been closed.");
+ }
+}
--
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