[Pkg-mozext-commits] [requestpolicy] 246/280: [mozmill] create menu-utils
David Prévot
taffit at moszumanska.debian.org
Sat May 2 20:30:35 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 845c76e0934c370394c0310f35f010004f71599e
Author: Martin Kimmerle <dev at 256k.de>
Date: Thu Apr 23 17:58:17 2015 +0200
[mozmill] create menu-utils
This commit also changes the way the menu is opened, so that it
works also in case the toolbar button is not visible.
---
tests/mozmill/lib/menu-utils.js | 71 ++++++++++++++++++++++++++++++++++
tests/mozmill/lib/request-log-utils.js | 27 ++++++-------
2 files changed, 83 insertions(+), 15 deletions(-)
diff --git a/tests/mozmill/lib/menu-utils.js b/tests/mozmill/lib/menu-utils.js
new file mode 100644
index 0000000..eaff551
--- /dev/null
+++ b/tests/mozmill/lib/menu-utils.js
@@ -0,0 +1,71 @@
+/* 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 rpRootDir = "../";
+var rpConst = require(rpRootDir + "lib/constants");
+var rootDir = rpRootDir + rpConst.mozmillTestsRootDir;
+
+
+/**
+ * @constructor
+ * @param {MozMillController} aController
+ */
+function Menu(aController) {
+ this.controller = aController;
+ this.window = this.controller.window;
+}
+
+/**
+ * @return {MozMillElement}
+ */
+Menu.prototype.getPopup = function () {
+ return findElement.ID(this.window.document, "rp-popup");
+};
+
+/**
+ * @param {string} aState
+ */
+Menu.prototype.waitForPopupState = function (aState) {
+ var popupNode = this.getPopup().getNode();
+
+ this.controller.waitFor(
+ function () {
+ return popupNode.state === aState;
+ },
+ "The menu popup's state (" + popupNode.state +
+ ") equals '" + aState + "'.");
+};
+
+/**
+ * Opens or closes the menu.
+ * @param {string} aState
+ * @this {Menu}
+ */
+function ensurePopupState(aState = "closed") {
+ var popupNode = this.getPopup().getNode();
+
+ if (popupNode.state === aState) {
+ return;
+ }
+
+ {
+ // actually open or close the menu
+ let functionName = (aState === "open" ? "openPopup" : "hidePopup");
+ popupNode[functionName]();
+ }
+
+ this.waitForPopupState(aState);
+};
+
+Menu.prototype.open = function () {
+ ensurePopupState.call(this, "open");
+};
+
+Menu.prototype.close = function () {
+ ensurePopupState.call(this, "closed");
+};
+
+exports.Menu = Menu;
diff --git a/tests/mozmill/lib/request-log-utils.js b/tests/mozmill/lib/request-log-utils.js
index e0dfdac..a901936 100644
--- a/tests/mozmill/lib/request-log-utils.js
+++ b/tests/mozmill/lib/request-log-utils.js
@@ -8,11 +8,11 @@ var rpRootDir = "../";
var rpConst = require(rpRootDir + "lib/constants");
var rootDir = rpRootDir + rpConst.mozmillTestsRootDir;
+var menuUtils = require(rpRootDir + "lib/menu-utils");
+
var prefs = require(rootDir + "lib/prefs");
var tabs = require(rootDir + "firefox/lib/tabs");
-const TBB_ID = "requestpolicyToolbarButton";
-
function RequestLog(aController) {
this.controller = aController;
@@ -20,19 +20,16 @@ function RequestLog(aController) {
}
RequestLog.prototype.open = function () {
- let tbb = findElement.ID(this.windowDoc, TBB_ID);
- // open the menu
- tbb.click();
- // wait for the menu
- let popup = findElement.ID(this.windowDoc, "rp-popup");
- popup.waitForElement();
- // open the request log
- findElement.ID(this.windowDoc, "rp-link-request-log").click();
- // close the menu
- popup.getNode().hidePopup();
- this.controller.waitFor(function () {
- return popup.getNode().state === "closed";
- }, "The menu has been closed.");
+ {
+ let menu = new menuUtils.Menu(this.controller);
+ menu.open();
+
+ // open the request log
+ findElement.ID(this.windowDoc, "rp-link-request-log").click();
+
+ // close the menu
+ menu.close();
+ }
let iframe = this.windowDoc.getElementById("requestpolicy-requestLog-frame");
this.requestLogDoc = iframe.contentDocument;
--
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