bard / mozrepl

Remotely control Firefox and other Mozilla apps with JavaScript
https://github.com/bard/mozrepl/wiki/
511 stars 64 forks source link

repl gets cleared after entering content #37

Closed nkkarthik closed 11 years ago

nkkarthik commented 11 years ago

Please look at the below interaction.

repl> repl
[object Object] - {onOutput: function() {...}, onQuit: function() {...}, _name: "repl", ...}
repl> repl.enter
function() {...}
repl> repl.enter(content)
[object Window] - {window: {...}, document: {...}, navigator: {...}, location: {...}, ...}
repl> repl.enter
repl> repl
[object Object] - {onOutput: function() {...}, onQuit: function() {...}, _name: "repl", ...}
repl> 

What could I be doing wrong here, let me know, please.
This happens only with some pages... but it consistently happens with those pages.

nkkarthik commented 11 years ago

I tested it again. It doesn't work with FF 17 or 18. I went back to 16.0.2 and it seems to work now.

fmancinelli commented 11 years ago

Got the same exact issue.

repl> repl.enter(content); repl> repl.back(); !!! TypeError: repl.back is not a function

This is a pity because it makes moz.el unusable from Emacs if you want to load your JS buffer to the current HTML page via C-c C-l

Any idea about how to fix this?

fmancinelli commented 11 years ago

If this can help it only happens when you do a repl.enter(content) when a HTML page is loaded in a tab. For example, if you do it when the add-ons tab is focused, everything works as expected.

This on Firefox 20.0.1

nkkarthik commented 11 years ago

Yeah, I too noticed that it works with add-ons tab. I am not sure why this happens and, sadly, don't have time to debug the issue (keeping aside whether I can debug it in the first place :) ). For now just sticking with Firefox v16.

windompeak commented 11 years ago

Yes, I can reproduce this bug as well for any FF v17+. A big show-stopper for my use cases.

xatom commented 11 years ago

While I am having the same issue, there's a simple workaround since you don't need to enter the content object in order use its methods:

content.document.location.href = "http://maps.google.com";
// get the context of the visible tab and save it
var maps = content.document;

var searchInput = maps.getElementById("gbqfq");
content.alert(searchInput.value);
searchInput.value = "from: new york city, ny to: chicago, il";
maps.getElementById("gbqfb").click();

I apologize for the sloppy code.

ricardo4621 commented 10 years ago

I'm seeing this issue again in FF 25 with this patched version.

repl> repl.enter(content.document); [object HTMLDocument] - {location: {...}, global-zeroclipboard-flash-bridge: function() {...}, jQuery203084890703625190040.053885937142066576: 2, jQuery203084890703625190040.3173927485539211: 55, getElementsByName: function() {...}, getItems: function() {...}, open: function() {...}, ...} repl> repl.home(); !!! TypeError: repl is undefined

However, repl.enter(content); repl.enter(document);

works as intended to enter content.document

vapniks commented 9 years ago

I get the same problem with firefox 40.0

repl> repl.enter(content.document)
repl> repl.look() 
!!! ReferenceError: repl is not defined

Details:

Even if I enter one at a time:

repl> repl.enter(content)
repl> repl.enter(document)
repl> repl.look()
!!! ReferenceError: repl is not defined

Details: