diff --git a/testing/peptest/peptest/extension/resource/mozmill/driver/controller.js b/testing/peptest/peptest/extension/resource/mozmill/driver/controller.js index 56f39a43b95..176d5ea3032 100644 --- a/testing/peptest/peptest/extension/resource/mozmill/driver/controller.js +++ b/testing/peptest/peptest/extension/resource/mozmill/driver/controller.js @@ -67,12 +67,12 @@ waitForEvents.prototype = { init : function waitForEvents_init(node, events) { if (node.getNode != undefined) node = node.getNode(); - + this.events = events; this.node = node; node.firedEvents = {}; this.registry = {}; - + for each(e in events) { var listener = function(event) { this.firedEvents[event.type] = true; @@ -92,7 +92,7 @@ waitForEvents.prototype = { utils.waitFor(function() { return this.node.firedEvents[e] == true; }, "Timeout happened before event '" + ex +"' was fired.", timeout, interval); - + this.node.removeEventListener(e, this.registry[e], true); } } @@ -281,10 +281,10 @@ var MozMillController = function (window) { } // constructs a MozMillElement from the controller's window -MozMillController.prototype.__defineGetter__("windowElement", function() { - if (this._windowElement == undefined) - this._windowElement = new mozelement.MozMillElement(undefined, undefined, {'element': this.window}); - return this._windowElement; +MozMillController.prototype.__defineGetter__("rootElement", function() { + if (this._rootElement == undefined) + this._rootElement = new mozelement.MozMillElement(undefined, undefined, {'element': this.window.document.documentElement}); + return this._rootElement; }); MozMillController.prototype.sleep = utils.sleep; @@ -308,7 +308,7 @@ MozMillController.prototype.open = function(url) /** * Take a screenshot of specified node - * + * * @param {element} node * the window or DOM element to capture * @param {string} name @@ -322,7 +322,7 @@ MozMillController.prototype.screenShot = function _screenShot(node, name, save, if (!node) { throw new Error("node is undefined"); } - + // Unwrap the node and highlights if ("getNode" in node) node = node.getNode(); if (highlights) { @@ -332,7 +332,7 @@ MozMillController.prototype.screenShot = function _screenShot(node, name, save, } } } - + // If save is false, a dataURL is used // Include both in the report anyway to avoid confusion and make the report easier to parse var filepath, dataURL; @@ -419,7 +419,7 @@ MozMillController.prototype.startUserShutdown = function (timeout, restart, next this.window.setTimeout(broker.sendMessage, timeout, 'userShutdown', 0); } -MozMillController.prototype.restartApplication = function (next, resetProfile) +MozMillController.prototype.restartApplication = function (next, resetProfile) { // restart the application via the python runner // - next : name of the next test function to run after restart @@ -433,7 +433,7 @@ MozMillController.prototype.restartApplication = function (next, resetProfile) utils.getMethodInWindows('goQuitApplication')(); } -MozMillController.prototype.stopApplication = function (resetProfile) +MozMillController.prototype.stopApplication = function (resetProfile) { // stop the application via the python runner // - resetProfile : whether to reset the profile after shutdown @@ -488,7 +488,7 @@ MozMillController.prototype.assertText = function (el, text) { //Assert that a specified node exists MozMillController.prototype.assertNode = function (el) { logDeprecatedAssert("assertNode"); - + //this.window.focus(); var element = el.getNode(); if (!element){ @@ -502,7 +502,7 @@ MozMillController.prototype.assertNode = function (el) { // Assert that a specified node doesn't exist MozMillController.prototype.assertNodeNotExist = function (el) { logDeprecatedAssert("assertNodeNotExist"); - + //this.window.focus(); try { var element = el.getNode(); @@ -523,7 +523,7 @@ MozMillController.prototype.assertNodeNotExist = function (el) { //Assert that a form element contains the expected value MozMillController.prototype.assertValue = function (el, value) { logDeprecatedAssert("assertValue"); - + //this.window.focus(); var n = el.getNode(); @@ -550,7 +550,7 @@ MozMillController.prototype.assert = function(callback, message, thisObject) //Assert that a provided value is selected in a select element MozMillController.prototype.assertSelected = function (el, value) { logDeprecatedAssert("assertSelected"); - + //this.window.focus(); var n = el.getNode(); var validator = value; @@ -566,7 +566,7 @@ MozMillController.prototype.assertSelected = function (el, value) { //Assert that a provided checkbox is checked MozMillController.prototype.assertChecked = function (el) { logDeprecatedAssert("assertChecked"); - + //this.window.focus(); var element = el.getNode(); @@ -581,7 +581,7 @@ MozMillController.prototype.assertChecked = function (el) { // Assert that a provided checkbox is not checked MozMillController.prototype.assertNotChecked = function (el) { logDeprecatedAssert("assertNotChecked"); - + var element = el.getNode(); if (!element) { @@ -596,7 +596,7 @@ MozMillController.prototype.assertNotChecked = function (el) { return false; }; -/** +/** * Assert that an element's javascript property exists or has a particular value * * if val is undefined, will return true if the property exists. @@ -604,7 +604,7 @@ MozMillController.prototype.assertNotChecked = function (el) { */ MozMillController.prototype.assertJSProperty = function(el, attrib, val) { logDeprecatedAssert("assertJSProperty"); - + var element = el.getNode(); if (!element){ throw new Error("could not find element " + el.getInfo()); @@ -615,13 +615,13 @@ MozMillController.prototype.assertJSProperty = function(el, attrib, val) { if (res) { broker.pass({'function':'Controller.assertJSProperty("' + el.getInfo() + '") : ' + val}); } else { - throw new Error("Controller.assertJSProperty(" + el.getInfo() + ") : " + + throw new Error("Controller.assertJSProperty(" + el.getInfo() + ") : " + (val === undefined ? "property '" + attrib + "' doesn't exist" : val + " == " + value)); } return res; }; -/** +/** * Assert that an element's javascript property doesn't exist or doesn't have a particular value * * if val is undefined, will return true if the property doesn't exist. @@ -629,7 +629,7 @@ MozMillController.prototype.assertJSProperty = function(el, attrib, val) { */ MozMillController.prototype.assertNotJSProperty = function(el, attrib, val) { logDeprecatedAssert("assertNotJSProperty"); - + var element = el.getNode(); if (!element){ throw new Error("could not find element " + el.getInfo()); @@ -646,7 +646,7 @@ MozMillController.prototype.assertNotJSProperty = function(el, attrib, val) { return res; }; -/** +/** * Assert that an element's dom property exists or has a particular value * * if val is undefined, will return true if the property exists. @@ -654,7 +654,7 @@ MozMillController.prototype.assertNotJSProperty = function(el, attrib, val) { */ MozMillController.prototype.assertDOMProperty = function(el, attrib, val) { logDeprecatedAssert("assertDOMProperty"); - + var element = el.getNode(); if (!element){ throw new Error("could not find element " + el.getInfo()); @@ -664,18 +664,18 @@ MozMillController.prototype.assertDOMProperty = function(el, attrib, val) { if (res && val !== undefined) { value = element.getAttribute(attrib); res = (String(value) == String(val)); - } - + } + if (res) { broker.pass({'function':'Controller.assertDOMProperty("' + el.getInfo() + '") : ' + val}); } else { - throw new Error("Controller.assertDOMProperty(" + el.getInfo() + ") : " + + throw new Error("Controller.assertDOMProperty(" + el.getInfo() + ") : " + (val === undefined ? "property '" + attrib + "' doesn't exist" : val + " == " + value)); } return res; }; -/** +/** * Assert that an element's dom property doesn't exist or doesn't have a particular value * * if val is undefined, will return true if the property doesn't exist. @@ -683,7 +683,7 @@ MozMillController.prototype.assertDOMProperty = function(el, attrib, val) { */ MozMillController.prototype.assertNotDOMProperty = function(el, attrib, val) { logDeprecatedAssert("assertNotDOMProperty"); - + var element = el.getNode(); if (!element){ throw new Error("could not find element " + el.getInfo()); @@ -693,11 +693,11 @@ MozMillController.prototype.assertNotDOMProperty = function(el, attrib, val) { if (res && val !== undefined) { value = element.getAttribute(attrib); res = (String(value) == String(val)); - } + } if (!res) { broker.pass({'function':'Controller.assertNotDOMProperty("' + el.getInfo() + '") : ' + val}); } else { - throw new Error("Controller.assertNotDOMProperty(" + el.getInfo() + ") : " + + throw new Error("Controller.assertNotDOMProperty(" + el.getInfo() + ") : " + (val == undefined ? "property '" + attrib + "' exists" : val + " == " + value)); } return !res; @@ -720,7 +720,7 @@ MozMillController.prototype.assertPropertyNotExist = function(el, attrib) { // for broken images (in Safari only) but works reliably MozMillController.prototype.assertImageLoaded = function (el) { logDeprecatedAssert("assertImageLoaded"); - + //this.window.focus(); var img = el.getNode(); if (!img || img.tagName != 'IMG') { @@ -959,16 +959,16 @@ controllerAdditions = { * Use the MozMillElement object instead (https://developer.mozilla.org/en/Mozmill/Mozmill_Element_Object) */ MozMillController.prototype.select = function (elem, index, option, value) { - return elem.select(index, option, value); + return elem.select(index, option, value); }; MozMillController.prototype.keypress = function(aTarget, aKey, aModifiers, aExpectedEvent) { - if (aTarget == null) { aTarget = this.windowElement; } + if (aTarget == null) { aTarget = this.rootElement; } return aTarget.keypress(aKey, aModifiers, aExpectedEvent); } MozMillController.prototype.type = function (aTarget, aText, aExpectedEvent) { - if (aTarget == null) { aTarget = this.windowElement; } + if (aTarget == null) { aTarget = this.rootElement; } var that = this; var retval = true; diff --git a/testing/peptest/peptest/extension/resource/mozmill/driver/mozelement.js b/testing/peptest/peptest/extension/resource/mozmill/driver/mozelement.js index 614de6e3881..22620d24c7a 100644 --- a/testing/peptest/peptest/extension/resource/mozmill/driver/mozelement.js +++ b/testing/peptest/peptest/extension/resource/mozmill/driver/mozelement.js @@ -36,7 +36,7 @@ * * ***** END LICENSE BLOCK ***** */ -var EXPORTED_SYMBOLS = ["Elem", "Selector", "ID", "Link", "XPath", "Name", "Lookup", +var EXPORTED_SYMBOLS = ["Elem", "Selector", "ID", "Link", "XPath", "Name", "Lookup", "MozMillElement", "MozMillCheckBox", "MozMillRadio", "MozMillDropList", "MozMillTextBox", "subclasses", ]; @@ -55,9 +55,10 @@ var subclasses = [MozMillCheckBox, MozMillRadio, MozMillDropList, MozMillTextBox * Returns an new instance of a MozMillElement * The type of the element is automatically determined */ -function createInstance(locatorType, locator, elem) { +function createInstance(locatorType, locator, elem, document) { if (elem) { - var args = {"element":elem}; + var args = { "element": elem, + "document": document }; for (var i = 0; i < subclasses.length; ++i) { if (subclasses[i].isType(elem)) { return new subclasses[i](locatorType, locator, args); @@ -72,28 +73,28 @@ var Elem = function(node) { return createInstance("Elem", node, node); }; -var Selector = function(_document, selector, index) { - return createInstance("Selector", selector, elementslib.Selector(_document, selector, index)); +var Selector = function(document, selector, index) { + return createInstance("Selector", selector, elementslib.Selector(document, selector, index), document); }; -var ID = function(_document, nodeID) { - return createInstance("ID", nodeID, elementslib.ID(_document, nodeID)); +var ID = function(document, nodeID) { + return createInstance("ID", nodeID, elementslib.ID(document, nodeID), document); }; -var Link = function(_document, linkName) { - return createInstance("Link", linkName, elementslib.Link(_document, linkName)); +var Link = function(document, linkName) { + return createInstance("Link", linkName, elementslib.Link(document, linkName), document); }; -var XPath = function(_document, expr) { - return createInstance("XPath", expr, elementslib.XPath(_document, expr)); +var XPath = function(document, expr) { + return createInstance("XPath", expr, elementslib.XPath(document, expr), document); }; -var Name = function(_document, nName) { - return createInstance("Name", nName, elementslib.Name(_document, nName)); +var Name = function(document, nName) { + return createInstance("Name", nName, elementslib.Name(document, nName), document); }; -var Lookup = function(_document, expression) { - return createInstance("Lookup", expression, elementslib.Lookup(_document, expression)); +var Lookup = function(document, expression) { + return createInstance("Lookup", expression, elementslib.Lookup(document, expression), document); }; @@ -121,7 +122,7 @@ MozMillElement.isType = function(node) { MozMillElement.prototype.__defineGetter__("element", function() { if (this._element == undefined) { if (elementslib[this._locatorType]) { - this._element = elementslib[this._locatorType](this._document, this._locator); + this._element = elementslib[this._locatorType](this._document, this._locator); } else if (this._locatorType == "Elem") { this._element = this._locator; } else { @@ -479,7 +480,7 @@ MozMillRadio.prototype.select = function(index) { if (!this.element) { throw new Error("could not find element " + this.getInfo()); } - + if (this.element.localName.toLowerCase() == "radiogroup") { var element = this.element.getElementsByTagName("radio")[index || 0]; new MozMillRadio("Elem", element).click(); @@ -487,7 +488,7 @@ MozMillRadio.prototype.select = function(index) { var element = this.element; this.click(); } - + utils.waitFor(function() { // If we have a XUL element, unwrap its XPCNativeWrapper if (element.namespaceURI == "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul") { @@ -581,7 +582,7 @@ MozMillDropList.prototype.select = function (indx, option, value) { this.element = utils.unwrapNode(this.element); // Get the list of menuitems menuitems = this.element.getElementsByTagName("menupopup")[0].getElementsByTagName("menuitem"); - + var item = null; if (indx != undefined) { diff --git a/testing/peptest/peptest/extension/resource/mozmill/stdlib/EventUtils.js b/testing/peptest/peptest/extension/resource/mozmill/stdlib/EventUtils.js index 6267e41715d..3ea1410e133 100644 --- a/testing/peptest/peptest/extension/resource/mozmill/stdlib/EventUtils.js +++ b/testing/peptest/peptest/extension/resource/mozmill/stdlib/EventUtils.js @@ -698,7 +698,7 @@ function synthesizeQuerySelectedText(aWindow) { var utils = _getDOMWindowUtils(aWindow); if (!utils) { - return nsnull; + return null; } return utils.sendQueryContentEvent(utils.QUERY_SELECTED_TEXT, 0, 0, 0, 0); } @@ -718,7 +718,7 @@ function synthesizeQueryTextContent(aOffset, aLength, aWindow) { var utils = _getDOMWindowUtils(aWindow); if (!utils) { - return nsnull; + return null; } return utils.sendQueryContentEvent(utils.QUERY_TEXT_CONTENT, aOffset, aLength, 0, 0); @@ -737,7 +737,7 @@ function synthesizeQueryCaretRect(aOffset, aWindow) { var utils = _getDOMWindowUtils(aWindow); if (!utils) { - return nsnull; + return null; } return utils.sendQueryContentEvent(utils.QUERY_CARET_RECT, aOffset, 0, 0, 0); @@ -758,7 +758,7 @@ function synthesizeQueryTextRect(aOffset, aLength, aWindow) { var utils = _getDOMWindowUtils(aWindow); if (!utils) { - return nsnull; + return null; } return utils.sendQueryContentEvent(utils.QUERY_TEXT_RECT, aOffset, aLength, 0, 0); @@ -775,7 +775,7 @@ function synthesizeQueryEditorRect(aWindow) { var utils = _getDOMWindowUtils(aWindow); if (!utils) { - return nsnull; + return null; } return utils.sendQueryContentEvent(utils.QUERY_EDITOR_RECT, 0, 0, 0, 0); } @@ -792,7 +792,7 @@ function synthesizeCharAtPoint(aX, aY, aWindow) { var utils = _getDOMWindowUtils(aWindow); if (!utils) { - return nsnull; + return null; } return utils.sendQueryContentEvent(utils.QUERY_CHARACTER_AT_POINT, 0, 0, aX, aY); diff --git a/testing/peptest/peptest/extension/resource/pep/api.js b/testing/peptest/peptest/extension/resource/pep/api.js index 7704243eaf9..339341f5926 100644 --- a/testing/peptest/peptest/extension/resource/pep/api.js +++ b/testing/peptest/peptest/extension/resource/pep/api.js @@ -37,38 +37,82 @@ var EXPORTED_SYMBOLS = ['PepAPI']; var results = {}; Components.utils.import('resource://pep/results.js', results); -var log = {}; Components.utils.import('resource://pep/logger.js', log); -var utils = {}; Components.utils.import('resource://pep/utils.js', utils); +var log = {}; Components.utils.import('resource://pep/logger.js', log); +var utils = {}; Components.utils.import('resource://pep/utils.js', utils); +var mozmill = {}; Components.utils.import('resource://mozmill/driver/mozmill.js', mozmill); +var securableModule = {}; +Components.utils.import('resource://mozmill/stdlib/securable-module.js', securableModule); const wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator); + .getService(Components.interfaces.nsIWindowMediator); +const ios = Components.classes["@mozilla.org/network/io-service;1"] + .getService(Components.interfaces.nsIIOService); /** * This is the API exposed to tests - * Any properties of this object will be directly injected into test scope + * Any properties of this object will be injected into test scope + * under the 'pep' namespace. */ function PepAPI(test) { this.test = test; this.log = new Log(this.test.name); this.resultHandler = new results.ResultHandler(this.test.name); + + this.file = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + this.file.initWithPath(this.test.path); } +/** + * Performs an action during which responsiveness is measured + */ PepAPI.prototype.performAction = function(actionName, func) { this.resultHandler.startAction(actionName); func(); this.resultHandler.endAction(); }; +/** + * Returns the most recently used window of windowType + */ PepAPI.prototype.getWindow = function(windowType) { if (windowType === undefined) { windowType = "navigator:browser"; } - return wm.getMostRecentWindow(windowType); }; +/** + * Load a file on the local filesystem + * module - path on the local file of the module to load (no extension) + */ +PepAPI.prototype.require = function(module) { + let loader = new securableModule.Loader({ + rootPaths: [ios.newFileURI(this.file.parent).spec], + defaultPrincipal: "system", + globals: { Cc: Components.classes, + Ci: Components.interfaces, + Cr: Components.results, + Cu: Components.utils, + // mozmill scopes for compatibility with mozmill shared libraries + // https://developer.mozilla.org/en/Mozmill_Tests/Shared_Modules + mozmill: mozmill, + // quick hack to keep backwards compatibility with mozmill 1.5.x + elementslib: mozmill.findElement, + findElement: mozmill.findElement, + persisted: {}, + }, + }); + return loader.require(module); +}; + +/** + * Sleep for a number of milliseconds + */ PepAPI.prototype.sleep = function(milliseconds) { utils.sleep(milliseconds); }; -// Logging wrapper for tests +/** + * Logging wrapper for tests + */ function Log(testName) { this.testName = testName; } diff --git a/testing/peptest/peptest/runpeptests.py b/testing/peptest/peptest/runpeptests.py index 274da06449b..b1acaf919a6 100644 --- a/testing/peptest/peptest/runpeptests.py +++ b/testing/peptest/peptest/runpeptests.py @@ -36,6 +36,7 @@ from optparse import OptionParser from mozprofile import FirefoxProfile, ThunderbirdProfile, Profile +from mozprofile.permissions import ServerLocations from mozrunner import FirefoxRunner, ThunderbirdRunner, Runner from mozhttpd import MozHttpd from manifestparser import TestManifest @@ -68,8 +69,22 @@ class Peptest(): self.logger = mozlog.getLogger('PEP') # create the profile + enable_proxy = False + locations = ServerLocations() + if self.options.proxyLocations: + if not self.options.serverPath: + self.logger.warning('Can\'t set up proxy without server path') + else: + enable_proxy = True + locations.read(self.options.proxyLocations, False) + locations.add_host(host='127.0.0.1', + port=self.options.serverPort, + options='primary,privileged') + self.profile = self.profile_class(profile=self.options.profilePath, - addons=[os.path.join(here, 'extension')]) + addons=[os.path.join(here, 'extension')], + locations=locations, + proxy=enable_proxy) # fork a server to serve the test related files if self.options.serverPath: @@ -143,7 +158,8 @@ class Peptest(): return self.logger.debug('Starting server on port ' + str(self.options.serverPort)) self.server = MozHttpd(port=self.options.serverPort, - docroot=self.options.serverPath) + docroot=self.options.serverPath, + proxy_host_dirs=self.options.proxyHostDirs) self.server.start(block=False) def stop(self): @@ -302,6 +318,20 @@ class PeptestOptions(OptionParser): help="path to the profile to use. " "If none specified, a temporary profile is created") + self.add_option("--proxy", + action="store", type="string", dest="proxyLocations", + default=None, + help="path to a server-location file specifying " + "domains to proxy. --server-path must also be " + "specified.") + + self.add_option("--proxy-host-dirs", + action="store_true", dest="proxyHostDirs", + default=False, + help="proxied requests are served from directories " + "named by requested host. --proxy must also be " + "specified.") + self.add_option("--server-port", action="store", type="int", dest="serverPort", default=8888, diff --git a/testing/peptest/tests/firefox/examples/example_tests.ini b/testing/peptest/tests/firefox/examples/example_tests.ini deleted file mode 100644 index 6d42ac761dd..00000000000 --- a/testing/peptest/tests/firefox/examples/example_tests.ini +++ /dev/null @@ -1,7 +0,0 @@ -[test_contextMenu.js] -[test_openBlankTab.js] -[test_openBookmarksMenu.js] -failThreshold = 40 -[test_searchGoogle.js] -[test_openWindow.js] -[test_resizeWindow.js] diff --git a/testing/peptest/tests/firefox/firefox_all.ini b/testing/peptest/tests/firefox/firefox_all.ini index 73439806141..11e933c6764 100644 --- a/testing/peptest/tests/firefox/firefox_all.ini +++ b/testing/peptest/tests/firefox/firefox_all.ini @@ -1,2 +1,6 @@ -# All Firefox tests - include other manifests here -[include:examples/example_tests.ini] +[test_contextMenu.js] +[test_openBlankTab.js] +[test_openBookmarksMenu.js] +failThreshold = 40 +[test_openWindow.js] +[test_resizeWindow.js] diff --git a/testing/peptest/tests/firefox/server-locations.txt b/testing/peptest/tests/firefox/server-locations.txt new file mode 100644 index 00000000000..3ab12109838 --- /dev/null +++ b/testing/peptest/tests/firefox/server-locations.txt @@ -0,0 +1,3 @@ +http://mozilla.org privileged +http://mozillians.org privileged + diff --git a/testing/peptest/tests/firefox/server/index.html b/testing/peptest/tests/firefox/server/index.html new file mode 100644 index 00000000000..2a9d466bb98 --- /dev/null +++ b/testing/peptest/tests/firefox/server/index.html @@ -0,0 +1,6 @@ + + +This is a big test! + + + diff --git a/testing/peptest/tests/firefox/server/mozilla.org/index.html b/testing/peptest/tests/firefox/server/mozilla.org/index.html new file mode 100644 index 00000000000..8f2f60c34c9 --- /dev/null +++ b/testing/peptest/tests/firefox/server/mozilla.org/index.html @@ -0,0 +1,6 @@ + + +Test mozilla home page. + + + diff --git a/testing/peptest/tests/firefox/server/mozilla.org/index.html.orig b/testing/peptest/tests/firefox/server/mozilla.org/index.html.orig new file mode 100644 index 00000000000..7e12a4e62de --- /dev/null +++ b/testing/peptest/tests/firefox/server/mozilla.org/index.html.orig @@ -0,0 +1,8 @@ + + + + + + diff --git a/testing/peptest/tests/firefox/server/mozillians.org/index.html b/testing/peptest/tests/firefox/server/mozillians.org/index.html new file mode 100644 index 00000000000..3f02dc0fdd0 --- /dev/null +++ b/testing/peptest/tests/firefox/server/mozillians.org/index.html @@ -0,0 +1,6 @@ + + +Test mozillians home page. + + + diff --git a/testing/peptest/tests/firefox/examples/test_contextMenu.js b/testing/peptest/tests/firefox/test_contextMenu.js similarity index 90% rename from testing/peptest/tests/firefox/examples/test_contextMenu.js rename to testing/peptest/tests/firefox/test_contextMenu.js index b32b1a32fe3..cdf7cfe2313 100644 --- a/testing/peptest/tests/firefox/examples/test_contextMenu.js +++ b/testing/peptest/tests/firefox/test_contextMenu.js @@ -41,7 +41,6 @@ * on various context menus in both content and chrome. */ -// Import mozmill and initialize a controller Components.utils.import("resource://mozmill/driver/mozmill.js"); let c = getBrowserController(); @@ -49,29 +48,29 @@ let c = getBrowserController(); c.open("http://mozilla.org"); c.waitForPageLoad(); -// Grab reference to element on page (this is the element in this case) -let page = findElement.ID(c.tabs.activeTab, 'header'); // Perform our first action, reload. // It is very important to only place things that we // are interested in testing inside of a performAction call pep.performAction('content_reload', function() { - page.rightClick(); - page.keypress('r'); + // controller.rootElement is the global window object + // wrapped inside of a MozMillElement + c.rootElement.rightClick(); + c.rootElement.keypress('r'); }); c.waitForPageLoad(); -c.open("http://google.com"); +c.open("http://mozillians.org"); c.waitForPageLoad(); -page = findElement.ID(c.tabs.activeTab, 'main'); // Perform our second action, go back pep.performAction('content_back', function() { - page.rightClick(); - page.keypress('b'); + c.rootElement.rightClick(); + c.rootElement.keypress('b'); }); // Bug 699400 - waitForPageLoad times out when pressing back button -c.sleep(100); +c.sleep(500); +// get a reference to the element with id 'home' page = findElement.ID(c.tabs.activeTab, 'home'); // Perform our third action, scroll through context menu pep.performAction('content_scroll', function() { diff --git a/testing/peptest/tests/firefox/examples/test_openBlankTab.js b/testing/peptest/tests/firefox/test_openBlankTab.js similarity index 93% rename from testing/peptest/tests/firefox/examples/test_openBlankTab.js rename to testing/peptest/tests/firefox/test_openBlankTab.js index 7a4bb8e00fe..62ad1cdc936 100644 --- a/testing/peptest/tests/firefox/examples/test_openBlankTab.js +++ b/testing/peptest/tests/firefox/test_openBlankTab.js @@ -43,11 +43,10 @@ c.open('http://mozilla.org'); c.waitForPageLoad(); // Only put things you want to test for responsiveness inside a perfom action call -let page = findElement.ID(c.tabs.activeTab, "home"); pep.performAction('open_blank_tab', function() { - page.keypress('t', {'ctrlKey': true}); + c.rootElement.keypress('t', {'ctrlKey': true}); }); pep.performAction('close_blank_tab', function() { - page.keypress('w', {'ctrlKey': true}); + c.rootElement.keypress('w', {'ctrlKey': true}); }); diff --git a/testing/peptest/tests/firefox/examples/test_openBookmarksMenu.js b/testing/peptest/tests/firefox/test_openBookmarksMenu.js similarity index 100% rename from testing/peptest/tests/firefox/examples/test_openBookmarksMenu.js rename to testing/peptest/tests/firefox/test_openBookmarksMenu.js diff --git a/testing/peptest/tests/firefox/examples/test_openWindow.js b/testing/peptest/tests/firefox/test_openWindow.js similarity index 97% rename from testing/peptest/tests/firefox/examples/test_openWindow.js rename to testing/peptest/tests/firefox/test_openWindow.js index 66f828c04a8..8caea2dbbc2 100644 --- a/testing/peptest/tests/firefox/examples/test_openWindow.js +++ b/testing/peptest/tests/firefox/test_openWindow.js @@ -35,7 +35,6 @@ * * ***** END LICENSE BLOCK ***** */ -// Import mozmill and initialize a controller Components.utils.import("resource://mozmill/driver/mozmill.js"); let controller = getBrowserController(); diff --git a/testing/peptest/tests/firefox/examples/test_resizeWindow.js b/testing/peptest/tests/firefox/test_resizeWindow.js similarity index 100% rename from testing/peptest/tests/firefox/examples/test_resizeWindow.js rename to testing/peptest/tests/firefox/test_resizeWindow.js diff --git a/testing/peptest/tests/firefox/examples/test_searchGoogle.js b/testing/peptest/tests/firefox/test_searchGoogle.js similarity index 96% rename from testing/peptest/tests/firefox/examples/test_searchGoogle.js rename to testing/peptest/tests/firefox/test_searchGoogle.js index 8e8051a5811..a9e15debe91 100644 --- a/testing/peptest/tests/firefox/examples/test_searchGoogle.js +++ b/testing/peptest/tests/firefox/test_searchGoogle.js @@ -39,12 +39,12 @@ Components.utils.import("resource://mozmill/driver/mozmill.js"); let controller = getBrowserController(); -controller.open("http://google.ca"); +controller.open("http://google.com"); controller.waitForPageLoad(); let textbox = findElement.ID(controller.tabs.activeTab, 'lst-ib'); let button = findElement.Name(controller.tabs.activeTab, 'btnK'); -pep.performAction('enterText', function() { +pep.performAction('enter_text', function() { textbox.sendKeys('foobar'); button.click(); }); diff --git a/testing/testsuite-targets.mk b/testing/testsuite-targets.mk index 2ad6870e289..25462ab184e 100644 --- a/testing/testsuite-targets.mk +++ b/testing/testsuite-targets.mk @@ -271,8 +271,12 @@ xpcshell-tests-remote: # Runs peptest, for usage see: https://developer.mozilla.org/en/Peptest#Running_Tests RUN_PEPTEST = \ rm -f ./$@.log && \ - $(PYTHON) _tests/peptest/runtests.py --binary=$(browser_path) $(PEPTEST_PATH_ARG) \ - --log-file=./$@.log $(SYMBOLS_PATH) $(EXTRA_TEST_ARGS) + $(PYTHON) _tests/peptest/runtests.py --binary=$(browser_path) \ + $(PEPTEST_PATH_ARG) \ + --proxy=_tests/peptest/tests/firefox/server-locations.txt \ + --proxy-host-dirs \ + --server-path=_tests/peptest/tests/firefox/server \ + --log-file=./$@.log $(SYMBOLS_PATH) $(EXTRA_TEST_ARGS) peptest: $(RUN_PEPTEST)