Created
December 8, 2012 01:10
-
-
Save AutomatedTester/4237990 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # HG changeset patch | |
| # User David Burns <dburns@mozilla.com> | |
| # Date 1354928718 0 | |
| # Node ID a68f803c07e399a059adbeb1c0182a991d22099b | |
| # Parent 7a37a4baac4f70ffb2cd29f2bd6cfb69a593dceb | |
| [mq]: bug819351 | |
| diff --git a/testing/marionette/client/marionette/tests/unit/test_import_script.py b/testing/marionette/client/marionette/tests/unit/test_import_script.py | |
| --- a/testing/marionette/client/marionette/tests/unit/test_import_script.py | |
| +++ b/testing/marionette/client/marionette/tests/unit/test_import_script.py | |
| @@ -13,22 +13,31 @@ class TestImportScript(MarionetteTestCas | |
| self.assertEqual("i'm a test function!", self.marionette.execute_script("return testFunc();")) | |
| self.assertEqual("i'm a test function!", self.marionette.execute_async_script("marionetteScriptFinished(testFunc());")) | |
| def test_importing_another_script_and_check_they_append(self): | |
| firstjs = os.path.abspath( | |
| os.path.join(__file__, os.path.pardir, "importscript.js")) | |
| secondjs = os.path.abspath( | |
| os.path.join(__file__, os.path.pardir, "importanotherscript.js")) | |
| - | |
| + | |
| self.marionette.import_script(firstjs) | |
| self.marionette.import_script(secondjs) | |
| self.assertEqual("i'm a test function!", | |
| self.marionette.execute_script("return testFunc();")) | |
| - | |
| + | |
| self.assertEqual("i'm yet another test function!", | |
| self.marionette.execute_script("return testAnotherFunc();")) | |
| + def test_importing_script_then_reusing_it(self): | |
| + test_html = self.marionette.absolute_url("test_import_frames.html") | |
| + self.marionette.navigate(test_html) | |
| + js = os.path.abspath(os.path.join(__file__, os.path.pardir, "importscript.js")) | |
| + self.marionette.import_script(js) | |
| + self.marionette.switch_to_frame("myIframe") | |
| + self.assertEqual("i'm a test function!", self.marionette.execute_script("return testFunc();")) | |
| + | |
| + | |
| class TestImportScriptChrome(TestImportScript): | |
| def setUp(self): | |
| MarionetteTestCase.setUp(self) | |
| self.marionette.set_context("chrome") | |
| diff --git a/testing/marionette/marionette-actors.js b/testing/marionette/marionette-actors.js | |
| --- a/testing/marionette/marionette-actors.js | |
| +++ b/testing/marionette/marionette-actors.js | |
| @@ -1875,26 +1875,27 @@ MarionetteDriverActor.prototype = { | |
| } | |
| let browserType; | |
| try { | |
| browserType = message.target.getAttribute("type"); | |
| } catch (ex) { | |
| // browserType remains undefined. | |
| } | |
| - let reg; | |
| + let reg = {}; | |
| if (!browserType || browserType != "content") { | |
| - reg = this.curBrowser.register(this.generateFrameId(message.json.value), | |
| + reg.id = this.curBrowser.register(this.generateFrameId(message.json.value), | |
| message.json.href); | |
| } | |
| - this.curBrowser.elementManager.seenItems[reg] = listenerWindow; //add to seenItems | |
| + this.curBrowser.elementManager.seenItems[reg.id] = listenerWindow; //add to seenItems | |
| + reg.importedScripts = this.importedScripts.path; | |
| if (nullPrevious && (this.curBrowser.curFrameId != null)) { | |
| this.sendAsync("newSession", {B2G: (appName == "B2G")}); | |
| if (this.curBrowser.newSession) { | |
| - this.sendResponse(reg); | |
| + this.sendResponse(reg.id); | |
| } | |
| } | |
| return reg; | |
| } | |
| }, | |
| /** | |
| * for non-e10s eventListening | |
| */ | |
| diff --git a/testing/marionette/marionette-listener.js b/testing/marionette/marionette-listener.js | |
| --- a/testing/marionette/marionette-listener.js | |
| +++ b/testing/marionette/marionette-listener.js | |
| @@ -1,13 +1,18 @@ | |
| /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | |
| /* 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/. */ | |
| +// import logger | |
| +Cu.import("resource://gre/modules/services-common/log4moz.js"); | |
| +let logger = Log4Moz.repository.getLogger("Marionette"); | |
| +logger.info('marionette-listener.js loaded'); | |
| + | |
| let {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; | |
| let uuidGen = Cc["@mozilla.org/uuid-generator;1"] | |
| .getService(Ci.nsIUUIDGenerator); | |
| let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"] | |
| .getService(Ci.mozIJSSubScriptLoader); | |
| @@ -35,17 +40,17 @@ let isB2G = false; | |
| let marionetteTestName; | |
| let winUtil = content.QueryInterface(Ci.nsIInterfaceRequestor) | |
| .getInterface(Ci.nsIDOMWindowUtils); | |
| let listenerId = null; //unique ID of this listener | |
| let activeFrame = null; | |
| let curWindow = content; | |
| let elementManager = new ElementManager([]); | |
| -let importedScripts = FileUtils.getFile('TmpD', ['marionettescript']); | |
| +let importedScripts = null; | |
| // The sandbox we execute test scripts in. Gets lazily created in | |
| // createExecuteContentSandbox(). | |
| let sandbox; | |
| // Flag to indicate whether an async script is currently running or not. | |
| let asyncTestRunning = false; | |
| let asyncTestCommandId; | |
| @@ -59,18 +64,23 @@ let checkTimer = Cc["@mozilla.org/timer; | |
| * If the actor returns an ID, we start the listeners. Otherwise, nothing happens. | |
| */ | |
| function registerSelf() { | |
| Services.io.manageOfflineStatus = false; | |
| Services.io.offline = false; | |
| let msg = {value: winUtil.outerWindowID, href: content.location.href}; | |
| let register = sendSyncMessage("Marionette:register", msg); | |
| + logger.info("register is " + JSON.stringify(register)) | |
| + logger.info("register is type " +typeof register) | |
| + logger.info("register is an array? " + Array.isArray(register)) | |
| + | |
| if (register[0]) { | |
| - listenerId = register[0]; | |
| + listenerId = register[0].id; | |
| + importedScripts = FileUtils.File(register[0].importedScripts); | |
| startListeners(); | |
| } | |
| } | |
| /** | |
| * Add a message listener that's tied to our listenerId. | |
| */ | |
| function addMessageListenerId(messageName, handler) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment