Bug 1004089: Allow frame switching in marionette when switching by index and the frame is OOP; r=mdas

This commit is contained in:
David Burns 2014-04-30 22:59:25 +01:00
parent ec28e13723
commit 8ac5a89123
3 changed files with 42 additions and 4 deletions

View File

@ -79,6 +79,36 @@ class TestSwitchRemoteFrame(MarionetteTestCase):
""")
self.assertFalse(main_process)
def test_we_can_switch_to_a_remote_frame_by_index(self):
# test if we can revisit a remote frame (this takes a different codepath)
self.marionette.navigate(self.marionette.absolute_url("test.html"))
self.marionette.execute_script("SpecialPowers.addPermission('browser', true, document)")
self.marionette.execute_script("""
let iframe = document.createElement("iframe");
SpecialPowers.wrap(iframe).mozbrowser = true;
SpecialPowers.wrap(iframe).remote = true;
iframe.id = "remote_iframe";
iframe.style.height = "100px";
iframe.style.width = "100%%";
iframe.src = "%s";
document.body.appendChild(iframe);
""" % self.marionette.absolute_url("test.html"))
self.marionette.switch_to_frame(0)
main_process = self.marionette.execute_script("""
return SpecialPowers.isMainProcess();
""")
self.assertFalse(main_process)
self.marionette.switch_to_frame()
main_process = self.marionette.execute_script("""
return SpecialPowers.isMainProcess();
""")
self.assertTrue(main_process)
self.marionette.switch_to_frame(0)
main_process = self.marionette.execute_script("""
return SpecialPowers.isMainProcess();
""")
self.assertFalse(main_process)
def tearDown(self):
if self.oop_by_default is None:
self.marionette.execute_script("""

View File

@ -85,7 +85,6 @@ browser = false
[test_switch_frame.py]
[test_switch_frame_chrome.py]
[test_switch_remote_frame.py]
browser = false
[test_pagesource.py]
b2g = false

View File

@ -1871,9 +1871,18 @@ function switchToFrame(msg) {
}
if (foundFrame == null) {
if (typeof(msg.json.id) === 'number') {
foundFrame = frames[msg.json.id].frameElement;
curFrame = foundFrame;
foundFrame = elementManager.addToKnownElements(curFrame);
try {
foundFrame = frames[msg.json.id].frameElement;
curFrame = foundFrame;
foundFrame = elementManager.addToKnownElements(curFrame);
} catch (e) {
// Since window.frames does not return OOP frames it will throw
// and we land up here. Let's not give up and check if there are
// iframes and switch to the indexed frame there
let iframes = curFrame.document.getElementsByTagName("iframe");
curFrame = iframes[msg.json.id];
foundFrame = msg.json.id
}
}
}
if (foundFrame == null) {