Bug 819351: move import script file creation/deletion to marionette actor and have it deleted on session delete. r=jgriffin

This commit is contained in:
David Burns 2012-12-14 16:11:02 +00:00
parent 279790b352
commit 8e27609578
5 changed files with 40 additions and 13 deletions

View File

@ -18,13 +18,13 @@ class TestImportScript(MarionetteTestCase):
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();"))

View File

@ -0,0 +1,28 @@
# 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 os
from marionette_test import MarionetteTestCase
class TestImportScriptContent(MarionetteTestCase):
def test_importing_script_then_reusing_it(self):
test_html = self.marionette.absolute_url("test_windows.html")
self.marionette.navigate(test_html)
js = os.path.abspath(os.path.join(__file__, os.path.pardir, "importscript.js"))
self.current_window = self.marionette.current_window_handle
link = self.marionette.find_element("link text", "Open new window")
link.click()
windows = self.marionette.window_handles
windows.remove(self.current_window)
self.marionette.switch_to_window(windows[0])
self.marionette.import_script(js)
self.marionette.close()
self.marionette.switch_to_window(self.current_window)
self.assertEqual("i'm a test function!", self.marionette.execute_script("return testFunc();"))

View File

@ -13,6 +13,8 @@ skip = false
[test_getstatus.py]
[test_import_script.py]
[test_import_script_content.py.py]
b2g = false
[test_click.py]
b2g = false
[test_selected.py]

View File

@ -1880,16 +1880,17 @@ MarionetteDriverActor.prototype = {
} 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;

View File

@ -40,7 +40,7 @@ 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().
@ -65,7 +65,8 @@ function registerSelf() {
let register = sendSyncMessage("Marionette:register", msg);
if (register[0]) {
listenerId = register[0];
listenerId = register[0].id;
importedScripts = FileUtils.File(register[0].importedScripts);
startListeners();
}
}
@ -215,11 +216,6 @@ function deleteSession(msg) {
// reset frame to the top-most frame
curWindow = content;
curWindow.focus();
try {
importedScripts.remove(false);
}
catch (e) {
}
}
/*