mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 929175: Part 1: Allow Marionette to switch to frameset frames. ; r=mdas
This commit is contained in:
parent
8907ae425f
commit
5862bc2115
@ -95,7 +95,7 @@ FrameManager.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
//This is just 'switch to OOP frame'. We're handling this here so we can maintain a list of remoteFrames.
|
||||
//This is just 'switch to OOP frame'. We're handling this here so we can maintain a list of remoteFrames.
|
||||
switchToFrame: function FM_switchToFrame(message) {
|
||||
// Switch to a remote frame.
|
||||
let frameWindow = Services.wm.getOuterWindowWithId(message.json.win); //get the original frame window
|
||||
@ -126,7 +126,7 @@ FrameManager.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here, then we need to load the frame script in this frame,
|
||||
// If we get here, then we need to load the frame script in this frame,
|
||||
// and set the frame's ChromeMessageSender as the active message manager the server will listen to
|
||||
this.addMessageManagerListeners(mm);
|
||||
logger.info("frame-manager load script: " + mm.toString());
|
||||
|
@ -1807,11 +1807,11 @@ function switchToFrame(msg) {
|
||||
checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
}
|
||||
let foundFrame = null;
|
||||
let frames = []; //curFrame.document.getElementsByTagName("iframe");
|
||||
let parWindow = null; //curFrame.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
let frames = [];
|
||||
let parWindow = null;
|
||||
// Check of the curFrame reference is dead
|
||||
try {
|
||||
frames = curFrame.document.getElementsByTagName("iframe");
|
||||
frames = curFrame.frames;
|
||||
//Until Bug 761935 lands, we won't have multiple nested OOP iframes. We will only have one.
|
||||
//parWindow will refer to the iframe above the nested OOP frame.
|
||||
parWindow = curFrame.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
@ -1823,7 +1823,8 @@ function switchToFrame(msg) {
|
||||
msg.json.id = null;
|
||||
msg.json.element = null;
|
||||
}
|
||||
if ((msg.json.id == null) && (msg.json.element == null)) {
|
||||
|
||||
if ((msg.json.id === null || msg.json.id === undefined) && (msg.json.element == null)) {
|
||||
// returning to root frame
|
||||
sendSyncMessage("Marionette:switchedToFrame", { frameValue: null });
|
||||
|
||||
@ -1839,52 +1840,47 @@ function switchToFrame(msg) {
|
||||
if (elementManager.seenItems[msg.json.element] != undefined) {
|
||||
let wantedFrame;
|
||||
try {
|
||||
wantedFrame = elementManager.getKnownElement(msg.json.element, curFrame); //HTMLIFrameElement
|
||||
wantedFrame = elementManager.getKnownElement(msg.json.element, curFrame); //Frame Element
|
||||
}
|
||||
catch(e) {
|
||||
sendError(e.message, e.code, e.stack, command_id);
|
||||
}
|
||||
for (let i = 0; i < frames.length; i++) {
|
||||
// use XPCNativeWrapper to compare elements; see bug 834266
|
||||
if (XPCNativeWrapper(frames[i]) == XPCNativeWrapper(wantedFrame)) {
|
||||
curFrame = frames[i];
|
||||
foundFrame = i;
|
||||
|
||||
if (frames.length > 0) {
|
||||
for (let i = 0; i < frames.length; i++) {
|
||||
logger.info("frame[i] is " + frames[i].frameElement);
|
||||
// use XPCNativeWrapper to compare elements; see bug 834266
|
||||
if (XPCNativeWrapper(frames[i].frameElement) == XPCNativeWrapper(wantedFrame)) {
|
||||
logger.info("we have found it")
|
||||
curFrame = frames[i].frameElement;
|
||||
foundFrame = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(foundFrame == null) {
|
||||
// Either the frame has been removed or we have a OOP frame
|
||||
// so lets just get all the iframes and do a quick loop before
|
||||
// throwing in the towel
|
||||
let iframes = curFrame.document.getElementsByTagName("iframe");
|
||||
for (var i = 0; i < iframes.length; i++) {
|
||||
if (XPCNativeWrapper(iframes[i]) == XPCNativeWrapper(wantedFrame)) {
|
||||
curFrame = iframes[i];
|
||||
foundFrame = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (foundFrame == null) {
|
||||
switch(typeof(msg.json.id)) {
|
||||
case "string" :
|
||||
let foundById = null;
|
||||
for (let i = 0; i < frames.length; i++) {
|
||||
//give precedence to name
|
||||
let frame = frames[i];
|
||||
let name = utils.getElementAttribute(frame, 'name');
|
||||
let id = utils.getElementAttribute(frame, 'id');
|
||||
if (name == msg.json.id) {
|
||||
foundFrame = i;
|
||||
break;
|
||||
} else if ((foundById == null) && (id == msg.json.id)) {
|
||||
foundById = i;
|
||||
}
|
||||
}
|
||||
if ((foundFrame == null) && (foundById != null)) {
|
||||
foundFrame = foundById;
|
||||
curFrame = frames[foundFrame];
|
||||
}
|
||||
break;
|
||||
case "number":
|
||||
if (frames[msg.json.id] != undefined) {
|
||||
foundFrame = msg.json.id;
|
||||
curFrame = frames[foundFrame];
|
||||
}
|
||||
break;
|
||||
if (typeof(msg.json.id) === 'number') {
|
||||
foundFrame = frames[msg.json.id].frameElement;
|
||||
curFrame = foundFrame;
|
||||
foundFrame = elementManager.addToKnownElements(curFrame);
|
||||
}
|
||||
}
|
||||
if (foundFrame == null) {
|
||||
sendError("Unable to locate frame: " + msg.json.id, 8, null, command_id);
|
||||
return;
|
||||
sendError("Unable to locate frame: " + (msg.json.id || msg.json.element), 8, null, command_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
sandbox = null;
|
||||
@ -1898,8 +1894,8 @@ function switchToFrame(msg) {
|
||||
// The frame we want to switch to is a remote (out-of-process) frame;
|
||||
// notify our parent to handle the switch.
|
||||
curFrame = content;
|
||||
sendToServer('Marionette:switchToFrame', {frame: foundFrame,
|
||||
win: parWindow,
|
||||
sendToServer('Marionette:switchToFrame', {win: parWindow,
|
||||
frame: foundFrame,
|
||||
command_id: command_id});
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user