services/sync/tps/extensions/mozmill/resource/driver/controller.js

Wed, 31 Dec 2014 07:53:36 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:53:36 +0100
branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
permissions
-rw-r--r--

Correct small whitespace inconsistency, lost while renaming variables.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, you can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 var EXPORTED_SYMBOLS = ["MozMillController", "globalEventRegistry",
michael@0 6 "sleep", "windowMap"];
michael@0 7
michael@0 8 const Cc = Components.classes;
michael@0 9 const Ci = Components.interfaces;
michael@0 10 const Cu = Components.utils;
michael@0 11
michael@0 12 var EventUtils = {}; Cu.import('resource://mozmill/stdlib/EventUtils.js', EventUtils);
michael@0 13
michael@0 14 var assertions = {}; Cu.import('resource://mozmill/modules/assertions.js', assertions);
michael@0 15 var broker = {}; Cu.import('resource://mozmill/driver/msgbroker.js', broker);
michael@0 16 var elementslib = {}; Cu.import('resource://mozmill/driver/elementslib.js', elementslib);
michael@0 17 var errors = {}; Cu.import('resource://mozmill/modules/errors.js', errors);
michael@0 18 var mozelement = {}; Cu.import('resource://mozmill/driver/mozelement.js', mozelement);
michael@0 19 var utils = {}; Cu.import('resource://mozmill/stdlib/utils.js', utils);
michael@0 20 var windows = {}; Cu.import('resource://mozmill/modules/windows.js', windows);
michael@0 21
michael@0 22 // Declare most used utils functions in the controller namespace
michael@0 23 var assert = new assertions.Assert();
michael@0 24 var waitFor = assert.waitFor;
michael@0 25
michael@0 26 var sleep = utils.sleep;
michael@0 27
michael@0 28 // For Mozmill 1.5 backward compatibility
michael@0 29 var windowMap = windows.map;
michael@0 30
michael@0 31 waitForEvents = function () {
michael@0 32 }
michael@0 33
michael@0 34 waitForEvents.prototype = {
michael@0 35 /**
michael@0 36 * Initialize list of events for given node
michael@0 37 */
michael@0 38 init: function waitForEvents_init(node, events) {
michael@0 39 if (node.getNode != undefined)
michael@0 40 node = node.getNode();
michael@0 41
michael@0 42 this.events = events;
michael@0 43 this.node = node;
michael@0 44 node.firedEvents = {};
michael@0 45 this.registry = {};
michael@0 46
michael@0 47 for each (var e in events) {
michael@0 48 var listener = function (event) {
michael@0 49 this.firedEvents[event.type] = true;
michael@0 50 }
michael@0 51
michael@0 52 this.registry[e] = listener;
michael@0 53 this.registry[e].result = false;
michael@0 54 this.node.addEventListener(e, this.registry[e], true);
michael@0 55 }
michael@0 56 },
michael@0 57
michael@0 58 /**
michael@0 59 * Wait until all assigned events have been fired
michael@0 60 */
michael@0 61 wait: function waitForEvents_wait(timeout, interval) {
michael@0 62 for (var e in this.registry) {
michael@0 63 assert.waitFor(function () {
michael@0 64 return this.node.firedEvents[e] == true;
michael@0 65 }, "waitForEvents.wait(): Event '" + ex + "' has been fired.", timeout, interval);
michael@0 66
michael@0 67 this.node.removeEventListener(e, this.registry[e], true);
michael@0 68 }
michael@0 69 }
michael@0 70 }
michael@0 71
michael@0 72 /**
michael@0 73 * Class to handle menus and context menus
michael@0 74 *
michael@0 75 * @constructor
michael@0 76 * @param {MozMillController} controller
michael@0 77 * Mozmill controller of the window under test
michael@0 78 * @param {string} menuSelector
michael@0 79 * jQuery like selector string of the element
michael@0 80 * @param {object} document
michael@0 81 * Document to use for finding the menu
michael@0 82 * [optional - default: aController.window.document]
michael@0 83 */
michael@0 84 var Menu = function (controller, menuSelector, document) {
michael@0 85 this._controller = controller;
michael@0 86 this._menu = null;
michael@0 87
michael@0 88 document = document || controller.window.document;
michael@0 89 var node = document.querySelector(menuSelector);
michael@0 90 if (node) {
michael@0 91 // We don't unwrap nodes automatically yet (Bug 573185)
michael@0 92 node = node.wrappedJSObject || node;
michael@0 93 this._menu = new mozelement.Elem(node);
michael@0 94 } else {
michael@0 95 throw new Error("Menu element '" + menuSelector + "' not found.");
michael@0 96 }
michael@0 97 }
michael@0 98
michael@0 99 Menu.prototype = {
michael@0 100
michael@0 101 /**
michael@0 102 * Open and populate the menu
michael@0 103 *
michael@0 104 * @param {ElemBase} contextElement
michael@0 105 * Element whose context menu has to be opened
michael@0 106 * @returns {Menu} The Menu instance
michael@0 107 */
michael@0 108 open: function Menu_open(contextElement) {
michael@0 109 // We have to open the context menu
michael@0 110 var menu = this._menu.getNode();
michael@0 111 if ((menu.localName == "popup" || menu.localName == "menupopup") &&
michael@0 112 contextElement && contextElement.exists()) {
michael@0 113 this._controller.rightClick(contextElement);
michael@0 114 assert.waitFor(function () {
michael@0 115 return menu.state == "open";
michael@0 116 }, "Context menu has been opened.");
michael@0 117 }
michael@0 118
michael@0 119 // Run through the entire menu and populate with dynamic entries
michael@0 120 this._buildMenu(menu);
michael@0 121
michael@0 122 return this;
michael@0 123 },
michael@0 124
michael@0 125 /**
michael@0 126 * Close the menu
michael@0 127 *
michael@0 128 * @returns {Menu} The Menu instance
michael@0 129 */
michael@0 130 close: function Menu_close() {
michael@0 131 var menu = this._menu.getNode();
michael@0 132
michael@0 133 this._controller.keypress(this._menu, "VK_ESCAPE", {});
michael@0 134 assert.waitFor(function () {
michael@0 135 return menu.state == "closed";
michael@0 136 }, "Context menu has been closed.");
michael@0 137
michael@0 138 return this;
michael@0 139 },
michael@0 140
michael@0 141 /**
michael@0 142 * Retrieve the specified menu entry
michael@0 143 *
michael@0 144 * @param {string} itemSelector
michael@0 145 * jQuery like selector string of the menu item
michael@0 146 * @returns {ElemBase} Menu element
michael@0 147 * @throws Error If menu element has not been found
michael@0 148 */
michael@0 149 getItem: function Menu_getItem(itemSelector) {
michael@0 150 // Run through the entire menu and populate with dynamic entries
michael@0 151 this._buildMenu(this._menu.getNode());
michael@0 152
michael@0 153 var node = this._menu.getNode().querySelector(itemSelector);
michael@0 154
michael@0 155 if (!node) {
michael@0 156 throw new Error("Menu entry '" + itemSelector + "' not found.");
michael@0 157 }
michael@0 158
michael@0 159 return new mozelement.Elem(node);
michael@0 160 },
michael@0 161
michael@0 162 /**
michael@0 163 * Click the specified menu entry
michael@0 164 *
michael@0 165 * @param {string} itemSelector
michael@0 166 * jQuery like selector string of the menu item
michael@0 167 *
michael@0 168 * @returns {Menu} The Menu instance
michael@0 169 */
michael@0 170 click: function Menu_click(itemSelector) {
michael@0 171 this._controller.click(this.getItem(itemSelector));
michael@0 172
michael@0 173 return this;
michael@0 174 },
michael@0 175
michael@0 176 /**
michael@0 177 * Synthesize a keypress against the menu
michael@0 178 *
michael@0 179 * @param {string} key
michael@0 180 * Key to press
michael@0 181 * @param {object} modifier
michael@0 182 * Key modifiers
michael@0 183 * @see MozMillController#keypress
michael@0 184 *
michael@0 185 * @returns {Menu} The Menu instance
michael@0 186 */
michael@0 187 keypress: function Menu_keypress(key, modifier) {
michael@0 188 this._controller.keypress(this._menu, key, modifier);
michael@0 189
michael@0 190 return this;
michael@0 191 },
michael@0 192
michael@0 193 /**
michael@0 194 * Opens the context menu, click the specified entry and
michael@0 195 * make sure that the menu has been closed.
michael@0 196 *
michael@0 197 * @param {string} itemSelector
michael@0 198 * jQuery like selector string of the element
michael@0 199 * @param {ElemBase} contextElement
michael@0 200 * Element whose context menu has to be opened
michael@0 201 *
michael@0 202 * @returns {Menu} The Menu instance
michael@0 203 */
michael@0 204 select: function Menu_select(itemSelector, contextElement) {
michael@0 205 this.open(contextElement);
michael@0 206 this.click(itemSelector);
michael@0 207 this.close();
michael@0 208 },
michael@0 209
michael@0 210 /**
michael@0 211 * Recursive function which iterates through all menu elements and
michael@0 212 * populates the menus with dynamic menu entries.
michael@0 213 *
michael@0 214 * @param {node} menu
michael@0 215 * Top menu node whose elements have to be populated
michael@0 216 */
michael@0 217 _buildMenu: function Menu__buildMenu(menu) {
michael@0 218 var items = menu ? menu.childNodes : null;
michael@0 219
michael@0 220 Array.forEach(items, function (item) {
michael@0 221 // When we have a menu node, fake a click onto it to populate
michael@0 222 // the sub menu with dynamic entries
michael@0 223 if (item.tagName == "menu") {
michael@0 224 var popup = item.querySelector("menupopup");
michael@0 225
michael@0 226 if (popup) {
michael@0 227 var popupEvent = this._controller.window.document.createEvent("MouseEvent");
michael@0 228 popupEvent.initMouseEvent("popupshowing", true, true,
michael@0 229 this._controller.window, 0, 0, 0, 0, 0,
michael@0 230 false, false, false, false, 0, null);
michael@0 231 popup.dispatchEvent(popupEvent);
michael@0 232
michael@0 233 this._buildMenu(popup);
michael@0 234 }
michael@0 235 }
michael@0 236 }, this);
michael@0 237 }
michael@0 238 };
michael@0 239
michael@0 240 var MozMillController = function (window) {
michael@0 241 this.window = window;
michael@0 242
michael@0 243 this.mozmillModule = {};
michael@0 244 Cu.import('resource://mozmill/driver/mozmill.js', this.mozmillModule);
michael@0 245
michael@0 246 var self = this;
michael@0 247 assert.waitFor(function () {
michael@0 248 return window != null && self.isLoaded();
michael@0 249 }, "controller(): Window has been initialized.");
michael@0 250
michael@0 251 // Ensure to focus the window which will move it virtually into the foreground
michael@0 252 // when focusmanager.testmode is set enabled.
michael@0 253 this.window.focus();
michael@0 254
michael@0 255 var windowType = window.document.documentElement.getAttribute('windowtype');
michael@0 256 if (controllerAdditions[windowType] != undefined ) {
michael@0 257 this.prototype = new utils.Copy(this.prototype);
michael@0 258 controllerAdditions[windowType](this);
michael@0 259 this.windowtype = windowType;
michael@0 260 }
michael@0 261 }
michael@0 262
michael@0 263 /**
michael@0 264 * Returns the global browser object of the window
michael@0 265 *
michael@0 266 * @returns {Object} The browser object
michael@0 267 */
michael@0 268 MozMillController.prototype.__defineGetter__("browserObject", function () {
michael@0 269 return utils.getBrowserObject(this.window);
michael@0 270 });
michael@0 271
michael@0 272 // constructs a MozMillElement from the controller's window
michael@0 273 MozMillController.prototype.__defineGetter__("rootElement", function () {
michael@0 274 if (this._rootElement == undefined) {
michael@0 275 let docElement = this.window.document.documentElement;
michael@0 276 this._rootElement = new mozelement.MozMillElement("Elem", docElement);
michael@0 277 }
michael@0 278
michael@0 279 return this._rootElement;
michael@0 280 });
michael@0 281
michael@0 282 MozMillController.prototype.sleep = utils.sleep;
michael@0 283 MozMillController.prototype.waitFor = assert.waitFor;
michael@0 284
michael@0 285 // Open the specified url in the current tab
michael@0 286 MozMillController.prototype.open = function (url) {
michael@0 287 switch (this.mozmillModule.Application) {
michael@0 288 case "Firefox":
michael@0 289 case "MetroFirefox":
michael@0 290 // Stop a running page load to not overlap requests
michael@0 291 if (this.browserObject.selectedBrowser) {
michael@0 292 this.browserObject.selectedBrowser.stop();
michael@0 293 }
michael@0 294
michael@0 295 this.browserObject.loadURI(url);
michael@0 296 break;
michael@0 297
michael@0 298 default:
michael@0 299 throw new Error("MozMillController.open not supported.");
michael@0 300 }
michael@0 301
michael@0 302 broker.pass({'function':'Controller.open()'});
michael@0 303 }
michael@0 304
michael@0 305 /**
michael@0 306 * Take a screenshot of specified node
michael@0 307 *
michael@0 308 * @param {Element} node
michael@0 309 * The window or DOM element to capture
michael@0 310 * @param {String} name
michael@0 311 * The name of the screenshot used in reporting and as filename
michael@0 312 * @param {Boolean} save
michael@0 313 * If true saves the screenshot as 'name.jpg' in tempdir,
michael@0 314 * otherwise returns a dataURL
michael@0 315 * @param {Element[]} highlights
michael@0 316 * A list of DOM elements to highlight by drawing a red rectangle around them
michael@0 317 *
michael@0 318 * @returns {Object} Object which contains properties like filename, dataURL,
michael@0 319 * name and timestamp of the screenshot
michael@0 320 */
michael@0 321 MozMillController.prototype.screenshot = function (node, name, save, highlights) {
michael@0 322 if (!node) {
michael@0 323 throw new Error("node is undefined");
michael@0 324 }
michael@0 325
michael@0 326 // Unwrap the node and highlights
michael@0 327 if ("getNode" in node) {
michael@0 328 node = node.getNode();
michael@0 329 }
michael@0 330
michael@0 331 if (highlights) {
michael@0 332 for (var i = 0; i < highlights.length; ++i) {
michael@0 333 if ("getNode" in highlights[i]) {
michael@0 334 highlights[i] = highlights[i].getNode();
michael@0 335 }
michael@0 336 }
michael@0 337 }
michael@0 338
michael@0 339 // If save is false, a dataURL is used
michael@0 340 // Include both in the report anyway to avoid confusion and make the report easier to parse
michael@0 341 var screenshot = {"filename": undefined,
michael@0 342 "dataURL": utils.takeScreenshot(node, highlights),
michael@0 343 "name": name,
michael@0 344 "timestamp": new Date().toLocaleString()};
michael@0 345
michael@0 346 if (!save) {
michael@0 347 return screenshot;
michael@0 348 }
michael@0 349
michael@0 350 // Save the screenshot to disk
michael@0 351
michael@0 352 let {filename, failure} = utils.saveDataURL(screenshot.dataURL, name);
michael@0 353 screenshot.filename = filename;
michael@0 354 screenshot.failure = failure;
michael@0 355
michael@0 356 if (failure) {
michael@0 357 broker.log({'function': 'controller.screenshot()',
michael@0 358 'message': 'Error writing to file: ' + screenshot.filename});
michael@0 359 } else {
michael@0 360 // Send the screenshot object to python over jsbridge
michael@0 361 broker.sendMessage("screenshot", screenshot);
michael@0 362 broker.pass({'function': 'controller.screenshot()'});
michael@0 363 }
michael@0 364
michael@0 365 return screenshot;
michael@0 366 }
michael@0 367
michael@0 368 /**
michael@0 369 * Checks if the specified window has been loaded
michael@0 370 *
michael@0 371 * @param {DOMWindow} [aWindow=this.window] Window object to check for loaded state
michael@0 372 */
michael@0 373 MozMillController.prototype.isLoaded = function (aWindow) {
michael@0 374 var win = aWindow || this.window;
michael@0 375
michael@0 376 return windows.map.getValue(utils.getWindowId(win), "loaded") || false;
michael@0 377 };
michael@0 378
michael@0 379 MozMillController.prototype.__defineGetter__("waitForEvents", function () {
michael@0 380 if (this._waitForEvents == undefined) {
michael@0 381 this._waitForEvents = new waitForEvents();
michael@0 382 }
michael@0 383
michael@0 384 return this._waitForEvents;
michael@0 385 });
michael@0 386
michael@0 387 /**
michael@0 388 * Wrapper function to create a new instance of a menu
michael@0 389 * @see Menu
michael@0 390 */
michael@0 391 MozMillController.prototype.getMenu = function (menuSelector, document) {
michael@0 392 return new Menu(this, menuSelector, document);
michael@0 393 };
michael@0 394
michael@0 395 MozMillController.prototype.__defineGetter__("mainMenu", function () {
michael@0 396 return this.getMenu("menubar");
michael@0 397 });
michael@0 398
michael@0 399 MozMillController.prototype.__defineGetter__("menus", function () {
michael@0 400 logDeprecated('controller.menus', 'Use controller.mainMenu instead');
michael@0 401 });
michael@0 402
michael@0 403 MozMillController.prototype.waitForImage = function (aElement, timeout, interval) {
michael@0 404 this.waitFor(function () {
michael@0 405 return aElement.getNode().complete == true;
michael@0 406 }, "timeout exceeded for waitForImage " + aElement.getInfo(), timeout, interval);
michael@0 407
michael@0 408 broker.pass({'function':'Controller.waitForImage()'});
michael@0 409 }
michael@0 410
michael@0 411 MozMillController.prototype.startUserShutdown = function (timeout, restart, next, resetProfile) {
michael@0 412 if (restart && resetProfile) {
michael@0 413 throw new Error("You can't have a user-restart and reset the profile; there is a race condition");
michael@0 414 }
michael@0 415
michael@0 416 let shutdownObj = {
michael@0 417 'user': true,
michael@0 418 'restart': Boolean(restart),
michael@0 419 'next': next,
michael@0 420 'resetProfile': Boolean(resetProfile),
michael@0 421 'timeout': timeout
michael@0 422 };
michael@0 423
michael@0 424 broker.sendMessage('shutdown', shutdownObj);
michael@0 425 }
michael@0 426
michael@0 427 /**
michael@0 428 * Restart the application
michael@0 429 *
michael@0 430 * @param {string} aNext
michael@0 431 * Name of the next test function to run after restart
michael@0 432 * @param {boolean} [aFlags=undefined]
michael@0 433 * Additional flags how to handle the shutdown or restart. The attributes
michael@0 434 * eRestarti386 (0x20) and eRestartx86_64 (0x30) have not been documented yet.
michael@0 435 * @see https://developer.mozilla.org/nsIAppStartup#Attributes
michael@0 436 */
michael@0 437 MozMillController.prototype.restartApplication = function (aNext, aFlags) {
michael@0 438 var flags = Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart;
michael@0 439
michael@0 440 if (aFlags) {
michael@0 441 flags |= aFlags;
michael@0 442 }
michael@0 443
michael@0 444 broker.sendMessage('shutdown', {'user': false,
michael@0 445 'restart': true,
michael@0 446 'flags': flags,
michael@0 447 'next': aNext,
michael@0 448 'timeout': 0 });
michael@0 449
michael@0 450 // We have to ensure to stop the test from continuing until the application is
michael@0 451 // shutting down. The only way to do that is by throwing an exception.
michael@0 452 throw new errors.ApplicationQuitError();
michael@0 453 }
michael@0 454
michael@0 455 /**
michael@0 456 * Stop the application
michael@0 457 *
michael@0 458 * @param {boolean} [aResetProfile=false]
michael@0 459 * Whether to reset the profile during restart
michael@0 460 * @param {boolean} [aFlags=undefined]
michael@0 461 * Additional flags how to handle the shutdown or restart. The attributes
michael@0 462 * eRestarti386 and eRestartx86_64 have not been documented yet.
michael@0 463 * @see https://developer.mozilla.org/nsIAppStartup#Attributes
michael@0 464 */
michael@0 465 MozMillController.prototype.stopApplication = function (aResetProfile, aFlags) {
michael@0 466 var flags = Ci.nsIAppStartup.eAttemptQuit;
michael@0 467
michael@0 468 if (aFlags) {
michael@0 469 flags |= aFlags;
michael@0 470 }
michael@0 471
michael@0 472 broker.sendMessage('shutdown', {'user': false,
michael@0 473 'restart': false,
michael@0 474 'flags': flags,
michael@0 475 'resetProfile': aResetProfile,
michael@0 476 'timeout': 0 });
michael@0 477
michael@0 478 // We have to ensure to stop the test from continuing until the application is
michael@0 479 // shutting down. The only way to do that is by throwing an exception.
michael@0 480 throw new errors.ApplicationQuitError();
michael@0 481 }
michael@0 482
michael@0 483 //Browser navigation functions
michael@0 484 MozMillController.prototype.goBack = function () {
michael@0 485 this.window.content.history.back();
michael@0 486 broker.pass({'function':'Controller.goBack()'});
michael@0 487
michael@0 488 return true;
michael@0 489 }
michael@0 490
michael@0 491 MozMillController.prototype.goForward = function () {
michael@0 492 this.window.content.history.forward();
michael@0 493 broker.pass({'function':'Controller.goForward()'});
michael@0 494
michael@0 495 return true;
michael@0 496 }
michael@0 497
michael@0 498 MozMillController.prototype.refresh = function () {
michael@0 499 this.window.content.location.reload(true);
michael@0 500 broker.pass({'function':'Controller.refresh()'});
michael@0 501
michael@0 502 return true;
michael@0 503 }
michael@0 504
michael@0 505 function logDeprecated(funcName, message) {
michael@0 506 broker.log({'function': funcName + '() - DEPRECATED',
michael@0 507 'message': funcName + '() is deprecated. ' + message});
michael@0 508 }
michael@0 509
michael@0 510 function logDeprecatedAssert(funcName) {
michael@0 511 logDeprecated('controller.' + funcName,
michael@0 512 '. Use the generic `assertion` module instead.');
michael@0 513 }
michael@0 514
michael@0 515 MozMillController.prototype.assertText = function (el, text) {
michael@0 516 logDeprecatedAssert("assertText");
michael@0 517
michael@0 518 var n = el.getNode();
michael@0 519
michael@0 520 if (n && n.innerHTML == text) {
michael@0 521 broker.pass({'function': 'Controller.assertText()'});
michael@0 522 } else {
michael@0 523 throw new Error("could not validate element " + el.getInfo() +
michael@0 524 " with text "+ text);
michael@0 525 }
michael@0 526
michael@0 527 return true;
michael@0 528 };
michael@0 529
michael@0 530 /**
michael@0 531 * Assert that a specified node exists
michael@0 532 */
michael@0 533 MozMillController.prototype.assertNode = function (el) {
michael@0 534 logDeprecatedAssert("assertNode");
michael@0 535
michael@0 536 //this.window.focus();
michael@0 537 var element = el.getNode();
michael@0 538 if (!element) {
michael@0 539 throw new Error("could not find element " + el.getInfo());
michael@0 540 }
michael@0 541
michael@0 542 broker.pass({'function': 'Controller.assertNode()'});
michael@0 543 return true;
michael@0 544 };
michael@0 545
michael@0 546 /**
michael@0 547 * Assert that a specified node doesn't exist
michael@0 548 */
michael@0 549 MozMillController.prototype.assertNodeNotExist = function (el) {
michael@0 550 logDeprecatedAssert("assertNodeNotExist");
michael@0 551
michael@0 552 try {
michael@0 553 var element = el.getNode();
michael@0 554 } catch (e) {
michael@0 555 broker.pass({'function': 'Controller.assertNodeNotExist()'});
michael@0 556 }
michael@0 557
michael@0 558 if (element) {
michael@0 559 throw new Error("Unexpectedly found element " + el.getInfo());
michael@0 560 } else {
michael@0 561 broker.pass({'function':'Controller.assertNodeNotExist()'});
michael@0 562 }
michael@0 563
michael@0 564 return true;
michael@0 565 };
michael@0 566
michael@0 567 /**
michael@0 568 * Assert that a form element contains the expected value
michael@0 569 */
michael@0 570 MozMillController.prototype.assertValue = function (el, value) {
michael@0 571 logDeprecatedAssert("assertValue");
michael@0 572
michael@0 573 var n = el.getNode();
michael@0 574
michael@0 575 if (n && n.value == value) {
michael@0 576 broker.pass({'function': 'Controller.assertValue()'});
michael@0 577 } else {
michael@0 578 throw new Error("could not validate element " + el.getInfo() +
michael@0 579 " with value " + value);
michael@0 580 }
michael@0 581
michael@0 582 return false;
michael@0 583 };
michael@0 584
michael@0 585 /**
michael@0 586 * Check if the callback function evaluates to true
michael@0 587 */
michael@0 588 MozMillController.prototype.assert = function (callback, message, thisObject) {
michael@0 589 logDeprecatedAssert("assert");
michael@0 590
michael@0 591 utils.assert(callback, message, thisObject);
michael@0 592 broker.pass({'function': ": controller.assert('" + callback + "')"});
michael@0 593
michael@0 594 return true;
michael@0 595 }
michael@0 596
michael@0 597 /**
michael@0 598 * Assert that a provided value is selected in a select element
michael@0 599 */
michael@0 600 MozMillController.prototype.assertSelected = function (el, value) {
michael@0 601 logDeprecatedAssert("assertSelected");
michael@0 602
michael@0 603 var n = el.getNode();
michael@0 604 var validator = value;
michael@0 605
michael@0 606 if (n && n.options[n.selectedIndex].value == validator) {
michael@0 607 broker.pass({'function':'Controller.assertSelected()'});
michael@0 608 } else {
michael@0 609 throw new Error("could not assert value for element " + el.getInfo() +
michael@0 610 " with value " + value);
michael@0 611 }
michael@0 612
michael@0 613 return true;
michael@0 614 };
michael@0 615
michael@0 616 /**
michael@0 617 * Assert that a provided checkbox is checked
michael@0 618 */
michael@0 619 MozMillController.prototype.assertChecked = function (el) {
michael@0 620 logDeprecatedAssert("assertChecked");
michael@0 621
michael@0 622 var element = el.getNode();
michael@0 623
michael@0 624 if (element && element.checked == true) {
michael@0 625 broker.pass({'function':'Controller.assertChecked()'});
michael@0 626 } else {
michael@0 627 throw new Error("assert failed for checked element " + el.getInfo());
michael@0 628 }
michael@0 629
michael@0 630 return true;
michael@0 631 };
michael@0 632
michael@0 633 /**
michael@0 634 * Assert that a provided checkbox is not checked
michael@0 635 */
michael@0 636 MozMillController.prototype.assertNotChecked = function (el) {
michael@0 637 logDeprecatedAssert("assertNotChecked");
michael@0 638
michael@0 639 var element = el.getNode();
michael@0 640
michael@0 641 if (!element) {
michael@0 642 throw new Error("Could not find element" + el.getInfo());
michael@0 643 }
michael@0 644
michael@0 645 if (!element.hasAttribute("checked") || element.checked != true) {
michael@0 646 broker.pass({'function': 'Controller.assertNotChecked()'});
michael@0 647 } else {
michael@0 648 throw new Error("assert failed for not checked element " + el.getInfo());
michael@0 649 }
michael@0 650
michael@0 651 return true;
michael@0 652 };
michael@0 653
michael@0 654 /**
michael@0 655 * Assert that an element's javascript property exists or has a particular value
michael@0 656 *
michael@0 657 * if val is undefined, will return true if the property exists.
michael@0 658 * if val is specified, will return true if the property exists and has the correct value
michael@0 659 */
michael@0 660 MozMillController.prototype.assertJSProperty = function (el, attrib, val) {
michael@0 661 logDeprecatedAssert("assertJSProperty");
michael@0 662
michael@0 663 var element = el.getNode();
michael@0 664
michael@0 665 if (!element){
michael@0 666 throw new Error("could not find element " + el.getInfo());
michael@0 667 }
michael@0 668
michael@0 669 var value = element[attrib];
michael@0 670 var res = (value !== undefined && (val === undefined ? true :
michael@0 671 String(value) == String(val)));
michael@0 672 if (res) {
michael@0 673 broker.pass({'function':'Controller.assertJSProperty("' + el.getInfo() + '") : ' + val});
michael@0 674 } else {
michael@0 675 throw new Error("Controller.assertJSProperty(" + el.getInfo() + ") : " +
michael@0 676 (val === undefined ? "property '" + attrib +
michael@0 677 "' doesn't exist" : val + " == " + value));
michael@0 678 }
michael@0 679
michael@0 680 return true;
michael@0 681 };
michael@0 682
michael@0 683 /**
michael@0 684 * Assert that an element's javascript property doesn't exist or doesn't have a particular value
michael@0 685 *
michael@0 686 * if val is undefined, will return true if the property doesn't exist.
michael@0 687 * if val is specified, will return true if the property doesn't exist or doesn't have the specified value
michael@0 688 */
michael@0 689 MozMillController.prototype.assertNotJSProperty = function (el, attrib, val) {
michael@0 690 logDeprecatedAssert("assertNotJSProperty");
michael@0 691
michael@0 692 var element = el.getNode();
michael@0 693
michael@0 694 if (!element){
michael@0 695 throw new Error("could not find element " + el.getInfo());
michael@0 696 }
michael@0 697
michael@0 698 var value = element[attrib];
michael@0 699 var res = (val === undefined ? value === undefined : String(value) != String(val));
michael@0 700 if (res) {
michael@0 701 broker.pass({'function':'Controller.assertNotProperty("' + el.getInfo() + '") : ' + val});
michael@0 702 } else {
michael@0 703 throw new Error("Controller.assertNotJSProperty(" + el.getInfo() + ") : " +
michael@0 704 (val === undefined ? "property '" + attrib +
michael@0 705 "' exists" : val + " != " + value));
michael@0 706 }
michael@0 707
michael@0 708 return true;
michael@0 709 };
michael@0 710
michael@0 711 /**
michael@0 712 * Assert that an element's dom property exists or has a particular value
michael@0 713 *
michael@0 714 * if val is undefined, will return true if the property exists.
michael@0 715 * if val is specified, will return true if the property exists and has the correct value
michael@0 716 */
michael@0 717 MozMillController.prototype.assertDOMProperty = function (el, attrib, val) {
michael@0 718 logDeprecatedAssert("assertDOMProperty");
michael@0 719
michael@0 720 var element = el.getNode();
michael@0 721
michael@0 722 if (!element){
michael@0 723 throw new Error("could not find element " + el.getInfo());
michael@0 724 }
michael@0 725
michael@0 726 var value, res = element.hasAttribute(attrib);
michael@0 727 if (res && val !== undefined) {
michael@0 728 value = element.getAttribute(attrib);
michael@0 729 res = (String(value) == String(val));
michael@0 730 }
michael@0 731
michael@0 732 if (res) {
michael@0 733 broker.pass({'function':'Controller.assertDOMProperty("' + el.getInfo() + '") : ' + val});
michael@0 734 } else {
michael@0 735 throw new Error("Controller.assertDOMProperty(" + el.getInfo() + ") : " +
michael@0 736 (val === undefined ? "property '" + attrib +
michael@0 737 "' doesn't exist" : val + " == " + value));
michael@0 738 }
michael@0 739
michael@0 740 return true;
michael@0 741 };
michael@0 742
michael@0 743 /**
michael@0 744 * Assert that an element's dom property doesn't exist or doesn't have a particular value
michael@0 745 *
michael@0 746 * if val is undefined, will return true if the property doesn't exist.
michael@0 747 * if val is specified, will return true if the property doesn't exist or doesn't have the specified value
michael@0 748 */
michael@0 749 MozMillController.prototype.assertNotDOMProperty = function (el, attrib, val) {
michael@0 750 logDeprecatedAssert("assertNotDOMProperty");
michael@0 751
michael@0 752 var element = el.getNode();
michael@0 753
michael@0 754 if (!element) {
michael@0 755 throw new Error("could not find element " + el.getInfo());
michael@0 756 }
michael@0 757
michael@0 758 var value, res = element.hasAttribute(attrib);
michael@0 759 if (res && val !== undefined) {
michael@0 760 value = element.getAttribute(attrib);
michael@0 761 res = (String(value) == String(val));
michael@0 762 }
michael@0 763
michael@0 764 if (!res) {
michael@0 765 broker.pass({'function':'Controller.assertNotDOMProperty("' + el.getInfo() + '") : ' + val});
michael@0 766 } else {
michael@0 767 throw new Error("Controller.assertNotDOMProperty(" + el.getInfo() + ") : " +
michael@0 768 (val == undefined ? "property '" + attrib +
michael@0 769 "' exists" : val + " == " + value));
michael@0 770 }
michael@0 771
michael@0 772 return true;
michael@0 773 };
michael@0 774
michael@0 775 /**
michael@0 776 * Assert that a specified image has actually loaded. The Safari workaround results
michael@0 777 * in additional requests for broken images (in Safari only) but works reliably
michael@0 778 */
michael@0 779 MozMillController.prototype.assertImageLoaded = function (el) {
michael@0 780 logDeprecatedAssert("assertImageLoaded");
michael@0 781
michael@0 782 var img = el.getNode();
michael@0 783
michael@0 784 if (!img || img.tagName != 'IMG') {
michael@0 785 throw new Error('Controller.assertImageLoaded() failed.')
michael@0 786 return false;
michael@0 787 }
michael@0 788
michael@0 789 var comp = img.complete;
michael@0 790 var ret = null; // Return value
michael@0 791
michael@0 792 // Workaround for Safari -- it only supports the
michael@0 793 // complete attrib on script-created images
michael@0 794 if (typeof comp == 'undefined') {
michael@0 795 test = new Image();
michael@0 796 // If the original image was successfully loaded,
michael@0 797 // src for new one should be pulled from cache
michael@0 798 test.src = img.src;
michael@0 799 comp = test.complete;
michael@0 800 }
michael@0 801
michael@0 802 // Check the complete attrib. Note the strict
michael@0 803 // equality check -- we don't want undefined, null, etc.
michael@0 804 // --------------------------
michael@0 805 if (comp === false) {
michael@0 806 // False -- Img failed to load in IE/Safari, or is
michael@0 807 // still trying to load in FF
michael@0 808 ret = false;
michael@0 809 } else if (comp === true && img.naturalWidth == 0) {
michael@0 810 // True, but image has no size -- image failed to
michael@0 811 // load in FF
michael@0 812 ret = false;
michael@0 813 } else {
michael@0 814 // Otherwise all we can do is assume everything's
michael@0 815 // hunky-dory
michael@0 816 ret = true;
michael@0 817 }
michael@0 818
michael@0 819 if (ret) {
michael@0 820 broker.pass({'function':'Controller.assertImageLoaded'});
michael@0 821 } else {
michael@0 822 throw new Error('Controller.assertImageLoaded() failed.')
michael@0 823 }
michael@0 824
michael@0 825 return true;
michael@0 826 };
michael@0 827
michael@0 828 /**
michael@0 829 * Drag one element to the top x,y coords of another specified element
michael@0 830 */
michael@0 831 MozMillController.prototype.mouseMove = function (doc, start, dest) {
michael@0 832 // if one of these elements couldn't be looked up
michael@0 833 if (typeof start != 'object'){
michael@0 834 throw new Error("received bad coordinates");
michael@0 835 }
michael@0 836
michael@0 837 if (typeof dest != 'object'){
michael@0 838 throw new Error("received bad coordinates");
michael@0 839 }
michael@0 840
michael@0 841 var triggerMouseEvent = function (element, clientX, clientY) {
michael@0 842 clientX = clientX ? clientX: 0;
michael@0 843 clientY = clientY ? clientY: 0;
michael@0 844
michael@0 845 // make the mouse understand where it is on the screen
michael@0 846 var screenX = element.boxObject.screenX ? element.boxObject.screenX : 0;
michael@0 847 var screenY = element.boxObject.screenY ? element.boxObject.screenY : 0;
michael@0 848
michael@0 849 var evt = element.ownerDocument.createEvent('MouseEvents');
michael@0 850 if (evt.initMouseEvent) {
michael@0 851 evt.initMouseEvent('mousemove', true, true, element.ownerDocument.defaultView,
michael@0 852 1, screenX, screenY, clientX, clientY);
michael@0 853 } else {
michael@0 854 evt.initEvent('mousemove', true, true);
michael@0 855 }
michael@0 856
michael@0 857 element.dispatchEvent(evt);
michael@0 858 };
michael@0 859
michael@0 860 // Do the initial move to the drag element position
michael@0 861 triggerMouseEvent(doc.body, start[0], start[1]);
michael@0 862 triggerMouseEvent(doc.body, dest[0], dest[1]);
michael@0 863
michael@0 864 broker.pass({'function':'Controller.mouseMove()'});
michael@0 865 return true;
michael@0 866 }
michael@0 867
michael@0 868 /**
michael@0 869 * Drag an element to the specified offset on another element, firing mouse and
michael@0 870 * drag events. Adapted from ChromeUtils.js synthesizeDrop()
michael@0 871 *
michael@0 872 * @deprecated Use the MozMillElement object
michael@0 873 *
michael@0 874 * @param {MozElement} aSrc
michael@0 875 * Source element to be dragged
michael@0 876 * @param {MozElement} aDest
michael@0 877 * Destination element over which the drop occurs
michael@0 878 * @param {Number} [aOffsetX=element.width/2]
michael@0 879 * Relative x offset for dropping on the aDest element
michael@0 880 * @param {Number} [aOffsetY=element.height/2]
michael@0 881 * Relative y offset for dropping on the aDest element
michael@0 882 * @param {DOMWindow} [aSourceWindow=this.element.ownerDocument.defaultView]
michael@0 883 * Custom source Window to be used.
michael@0 884 * @param {String} [aDropEffect="move"]
michael@0 885 * Effect used for the drop event
michael@0 886 * @param {Object[]} [aDragData]
michael@0 887 * An array holding custom drag data to be used during the drag event
michael@0 888 * Format: [{ type: "text/plain", "Text to drag"}, ...]
michael@0 889 *
michael@0 890 * @returns {String} the captured dropEffect
michael@0 891 */
michael@0 892 MozMillController.prototype.dragToElement = function (aSrc, aDest, aOffsetX,
michael@0 893 aOffsetY, aSourceWindow,
michael@0 894 aDropEffect, aDragData) {
michael@0 895 logDeprecated("controller.dragToElement", "Use the MozMillElement object.");
michael@0 896 return aSrc.dragToElement(aDest, aOffsetX, aOffsetY, aSourceWindow, null,
michael@0 897 aDropEffect, aDragData);
michael@0 898 };
michael@0 899
michael@0 900 function Tabs(controller) {
michael@0 901 this.controller = controller;
michael@0 902 }
michael@0 903
michael@0 904 Tabs.prototype.getTab = function (index) {
michael@0 905 return this.controller.browserObject.browsers[index].contentDocument;
michael@0 906 }
michael@0 907
michael@0 908 Tabs.prototype.__defineGetter__("activeTab", function () {
michael@0 909 return this.controller.browserObject.selectedBrowser.contentDocument;
michael@0 910 });
michael@0 911
michael@0 912 Tabs.prototype.selectTab = function (index) {
michael@0 913 // GO in to tab manager and grab the tab by index and call focus.
michael@0 914 }
michael@0 915
michael@0 916 Tabs.prototype.findWindow = function (doc) {
michael@0 917 for (var i = 0; i <= (this.controller.window.frames.length - 1); i++) {
michael@0 918 if (this.controller.window.frames[i].document == doc) {
michael@0 919 return this.controller.window.frames[i];
michael@0 920 }
michael@0 921 }
michael@0 922
michael@0 923 throw new Error("Cannot find window for document. Doc title == " + doc.title);
michael@0 924 }
michael@0 925
michael@0 926 Tabs.prototype.getTabWindow = function (index) {
michael@0 927 return this.findWindow(this.getTab(index));
michael@0 928 }
michael@0 929
michael@0 930 Tabs.prototype.__defineGetter__("activeTabWindow", function () {
michael@0 931 return this.findWindow(this.activeTab);
michael@0 932 });
michael@0 933
michael@0 934 Tabs.prototype.__defineGetter__("length", function () {
michael@0 935 return this.controller.browserObject.browsers.length;
michael@0 936 });
michael@0 937
michael@0 938 Tabs.prototype.__defineGetter__("activeTabIndex", function () {
michael@0 939 var browser = this.controller.browserObject;
michael@0 940
michael@0 941 switch(this.controller.mozmillModule.Application) {
michael@0 942 case "MetroFirefox":
michael@0 943 return browser.tabs.indexOf(browser.selectedTab);
michael@0 944 case "Firefox":
michael@0 945 default:
michael@0 946 return browser.tabContainer.selectedIndex;
michael@0 947 }
michael@0 948 });
michael@0 949
michael@0 950 Tabs.prototype.selectTabIndex = function (aIndex) {
michael@0 951 var browser = this.controller.browserObject;
michael@0 952
michael@0 953 switch(this.controller.mozmillModule.Application) {
michael@0 954 case "MetroFirefox":
michael@0 955 browser.selectedTab = browser.tabs[aIndex];
michael@0 956 break;
michael@0 957 case "Firefox":
michael@0 958 default:
michael@0 959 browser.selectTabAtIndex(aIndex);
michael@0 960 }
michael@0 961 }
michael@0 962
michael@0 963 function browserAdditions (controller) {
michael@0 964 controller.tabs = new Tabs(controller);
michael@0 965
michael@0 966 controller.waitForPageLoad = function (aDocument, aTimeout, aInterval) {
michael@0 967 var timeout = aTimeout || 30000;
michael@0 968 var win = null;
michael@0 969 var timed_out = false;
michael@0 970
michael@0 971 // If a user tries to do waitForPageLoad(2000), this will assign the
michael@0 972 // interval the first arg which is most likely what they were expecting
michael@0 973 if (typeof(aDocument) == "number"){
michael@0 974 timeout = aDocument;
michael@0 975 }
michael@0 976
michael@0 977 // If we have a real document use its default view
michael@0 978 if (aDocument && (typeof(aDocument) === "object") &&
michael@0 979 "defaultView" in aDocument)
michael@0 980 win = aDocument.defaultView;
michael@0 981
michael@0 982 // If no document has been specified, fallback to the default view of the
michael@0 983 // currently selected tab browser
michael@0 984 win = win || this.browserObject.selectedBrowser.contentWindow;
michael@0 985
michael@0 986 // Wait until the content in the tab has been loaded
michael@0 987 try {
michael@0 988 this.waitFor(function () {
michael@0 989 return windows.map.hasPageLoaded(utils.getWindowId(win));
michael@0 990 }, "Timeout", timeout, aInterval);
michael@0 991 }
michael@0 992 catch (ex if ex instanceof errors.TimeoutError) {
michael@0 993 timed_out = true;
michael@0 994 }
michael@0 995 finally {
michael@0 996 state = 'URI=' + win.document.location.href +
michael@0 997 ', readyState=' + win.document.readyState;
michael@0 998 message = "controller.waitForPageLoad(" + state + ")";
michael@0 999
michael@0 1000 if (timed_out) {
michael@0 1001 throw new errors.AssertionError(message);
michael@0 1002 }
michael@0 1003
michael@0 1004 broker.pass({'function': message});
michael@0 1005 }
michael@0 1006 }
michael@0 1007 }
michael@0 1008
michael@0 1009 var controllerAdditions = {
michael@0 1010 'navigator:browser' :browserAdditions
michael@0 1011 };
michael@0 1012
michael@0 1013 /**
michael@0 1014 * DEPRECATION WARNING
michael@0 1015 *
michael@0 1016 * The following methods have all been DEPRECATED as of Mozmill 2.0
michael@0 1017 */
michael@0 1018 MozMillController.prototype.assertProperty = function (el, attrib, val) {
michael@0 1019 logDeprecatedAssert("assertProperty");
michael@0 1020
michael@0 1021 return this.assertJSProperty(el, attrib, val);
michael@0 1022 };
michael@0 1023
michael@0 1024 MozMillController.prototype.assertPropertyNotExist = function (el, attrib) {
michael@0 1025 logDeprecatedAssert("assertPropertyNotExist");
michael@0 1026 return this.assertNotJSProperty(el, attrib);
michael@0 1027 };
michael@0 1028
michael@0 1029 /**
michael@0 1030 * DEPRECATION WARNING
michael@0 1031 *
michael@0 1032 * The following methods have all been DEPRECATED as of Mozmill 2.0
michael@0 1033 * Use the MozMillElement object instead (https://developer.mozilla.org/en/Mozmill/Mozmill_Element_Object)
michael@0 1034 */
michael@0 1035 MozMillController.prototype.select = function (aElement, index, option, value) {
michael@0 1036 logDeprecated("controller.select", "Use the MozMillElement object.");
michael@0 1037
michael@0 1038 return aElement.select(index, option, value);
michael@0 1039 };
michael@0 1040
michael@0 1041 MozMillController.prototype.keypress = function (aElement, aKey, aModifiers, aExpectedEvent) {
michael@0 1042 logDeprecated("controller.keypress", "Use the MozMillElement object.");
michael@0 1043
michael@0 1044 if (!aElement) {
michael@0 1045 aElement = new mozelement.MozMillElement("Elem", this.window);
michael@0 1046 }
michael@0 1047
michael@0 1048 return aElement.keypress(aKey, aModifiers, aExpectedEvent);
michael@0 1049 }
michael@0 1050
michael@0 1051 MozMillController.prototype.type = function (aElement, aText, aExpectedEvent) {
michael@0 1052 logDeprecated("controller.type", "Use the MozMillElement object.");
michael@0 1053
michael@0 1054 if (!aElement) {
michael@0 1055 aElement = new mozelement.MozMillElement("Elem", this.window);
michael@0 1056 }
michael@0 1057
michael@0 1058 var that = this;
michael@0 1059 var retval = true;
michael@0 1060 Array.forEach(aText, function (letter) {
michael@0 1061 if (!that.keypress(aElement, letter, {}, aExpectedEvent)) {
michael@0 1062 retval = false; }
michael@0 1063 });
michael@0 1064
michael@0 1065 return retval;
michael@0 1066 }
michael@0 1067
michael@0 1068 MozMillController.prototype.mouseEvent = function (aElement, aOffsetX, aOffsetY, aEvent, aExpectedEvent) {
michael@0 1069 logDeprecated("controller.mouseEvent", "Use the MozMillElement object.");
michael@0 1070
michael@0 1071 return aElement.mouseEvent(aOffsetX, aOffsetY, aEvent, aExpectedEvent);
michael@0 1072 }
michael@0 1073
michael@0 1074 MozMillController.prototype.click = function (aElement, left, top, expectedEvent) {
michael@0 1075 logDeprecated("controller.click", "Use the MozMillElement object.");
michael@0 1076
michael@0 1077 return aElement.click(left, top, expectedEvent);
michael@0 1078 }
michael@0 1079
michael@0 1080 MozMillController.prototype.doubleClick = function (aElement, left, top, expectedEvent) {
michael@0 1081 logDeprecated("controller.doubleClick", "Use the MozMillElement object.");
michael@0 1082
michael@0 1083 return aElement.doubleClick(left, top, expectedEvent);
michael@0 1084 }
michael@0 1085
michael@0 1086 MozMillController.prototype.mouseDown = function (aElement, button, left, top, expectedEvent) {
michael@0 1087 logDeprecated("controller.mouseDown", "Use the MozMillElement object.");
michael@0 1088
michael@0 1089 return aElement.mouseDown(button, left, top, expectedEvent);
michael@0 1090 };
michael@0 1091
michael@0 1092 MozMillController.prototype.mouseOut = function (aElement, button, left, top, expectedEvent) {
michael@0 1093 logDeprecated("controller.mouseOut", "Use the MozMillElement object.");
michael@0 1094
michael@0 1095 return aElement.mouseOut(button, left, top, expectedEvent);
michael@0 1096 };
michael@0 1097
michael@0 1098 MozMillController.prototype.mouseOver = function (aElement, button, left, top, expectedEvent) {
michael@0 1099 logDeprecated("controller.mouseOver", "Use the MozMillElement object.");
michael@0 1100
michael@0 1101 return aElement.mouseOver(button, left, top, expectedEvent);
michael@0 1102 };
michael@0 1103
michael@0 1104 MozMillController.prototype.mouseUp = function (aElement, button, left, top, expectedEvent) {
michael@0 1105 logDeprecated("controller.mouseUp", "Use the MozMillElement object.");
michael@0 1106
michael@0 1107 return aElement.mouseUp(button, left, top, expectedEvent);
michael@0 1108 };
michael@0 1109
michael@0 1110 MozMillController.prototype.middleClick = function (aElement, left, top, expectedEvent) {
michael@0 1111 logDeprecated("controller.middleClick", "Use the MozMillElement object.");
michael@0 1112
michael@0 1113 return aElement.middleClick(aElement, left, top, expectedEvent);
michael@0 1114 }
michael@0 1115
michael@0 1116 MozMillController.prototype.rightClick = function (aElement, left, top, expectedEvent) {
michael@0 1117 logDeprecated("controller.rightClick", "Use the MozMillElement object.");
michael@0 1118
michael@0 1119 return aElement.rightClick(left, top, expectedEvent);
michael@0 1120 }
michael@0 1121
michael@0 1122 MozMillController.prototype.check = function (aElement, state) {
michael@0 1123 logDeprecated("controller.check", "Use the MozMillElement object.");
michael@0 1124
michael@0 1125 return aElement.check(state);
michael@0 1126 }
michael@0 1127
michael@0 1128 MozMillController.prototype.radio = function (aElement) {
michael@0 1129 logDeprecated("controller.radio", "Use the MozMillElement object.");
michael@0 1130
michael@0 1131 return aElement.select();
michael@0 1132 }
michael@0 1133
michael@0 1134 MozMillController.prototype.waitThenClick = function (aElement, timeout, interval) {
michael@0 1135 logDeprecated("controller.waitThenClick", "Use the MozMillElement object.");
michael@0 1136
michael@0 1137 return aElement.waitThenClick(timeout, interval);
michael@0 1138 }
michael@0 1139
michael@0 1140 MozMillController.prototype.waitForElement = function (aElement, timeout, interval) {
michael@0 1141 logDeprecated("controller.waitForElement", "Use the MozMillElement object.");
michael@0 1142
michael@0 1143 return aElement.waitForElement(timeout, interval);
michael@0 1144 }
michael@0 1145
michael@0 1146 MozMillController.prototype.waitForElementNotPresent = function (aElement, timeout, interval) {
michael@0 1147 logDeprecated("controller.waitForElementNotPresent", "Use the MozMillElement object.");
michael@0 1148
michael@0 1149 return aElement.waitForElementNotPresent(timeout, interval);
michael@0 1150 }

mercurial