MozRepl::RemoteObject: [Exception... "Illegal value" nsresult: "0x800 +70057 (NS_ERROR _ILLEGAL_VALUE)" location: "JS frame :: chrome://mozrepl/content/repl +.js -> file:/// C:/Documents%20and%20Settings/Administrator/Programdata/Mozilla/Firefo +x/Profiles/kaq7 hscq.default/mozrepl.tmp.js :: anonymous :: line 5" data: no] at C:\D +ocuments and Se ttings\Administrator\Skrivebord\PRINTLOOKER\firefox.pl line 40

I get this error when running this script:

#Start use WWW::Mechanize::FireFox #URL $url = 'http://host/url/site'; #New instance my $mech = WWW::Mechanize::FireFox->new(); #Exitkode my $EXITCODE = 0; #Get content of URL $mech->get($url); $str = 'javascript:InstallPrinter()'; eval_in_page_with_redefined_alert($mech,$str, sub { print "Caught aler +t(): @_" }); #$eval_in_page=>('javascript:InstallPrinter()'); #$mech->get('javascript:InstallPrinter()'); sub eval_in_page_with_redefined_alert { my ($self,$str,$redefined_alert) = @_; my $eval_in_sandbox = $self->repl->declare(<<'JS'); function (w,str,myalert) { var unsafeWin = w.wrappedJSObject; var safeWin = XPCNativeWrapper(unsafeWin); var sandbox = Components.utils.Sandbox(safeWin); sandbox.window = safeWin; sandbox.window.alert = myalert; // <-- sandbox.alert = myalert; // <-- sandbox.document = sandbox.window.document; sandbox.__proto__ = unsafeWin; var res = Components.utils.evalInSandbox(str, sandbox); return [res,typeof(res)]; }; JS my $window = $self->tab->{linkedBrowser}->{contentWindow}; my $uri = $self->uri; return @{ $eval_in_sandbox->("$uri",$window,$redefined_alert ) }; };

In reply to Re^8: fetch HTML page, do javascript, read output from alert/msgbox by TheFlyingCorpse
in thread fetch HTML page, do javascript, read output from alert/msgbox by TheFlyingCorpse

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.