jdic
  1. jdic
  2. JDIC-505

browser.executeScript(String) always returns an empty string

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Operating System: Mac OS X
      Platform: Macintosh

    • Issuezilla Id:
      505

      Description

      as an example:
      browser.executeScript("document.getElementById('foo').value;")
      should return the value of the foo element, but it always returns ""

        Activity

        Hide
        wjanssens added a comment -

        The problem seems to be here:

        public String executeScript(final String javaScript) {
        StringBuffer sb = new StringBuffer();
        Object[] args =

        { javaScript, sb }

        ;
        sendMsg(runJS, args);
        return sb.toString();
        }

        According to http://devworld.apple.com/documentation/Java/Reference/1.4.2/appledoc/api/com/
        apple/eawt/CocoaComponent.html#sendMessage(int,%20java.lang.Object) calls to sendMessage are
        asynchronous, so even though the native code is appending the result of the call to the StringBuffer, the
        executeScript method has already returned.

        Show
        wjanssens added a comment - The problem seems to be here: public String executeScript(final String javaScript) { StringBuffer sb = new StringBuffer(); Object[] args = { javaScript, sb } ; sendMsg(runJS, args); return sb.toString(); } According to http://devworld.apple.com/documentation/Java/Reference/1.4.2/appledoc/api/com/ apple/eawt/CocoaComponent.html#sendMessage(int,%20java.lang.Object) calls to sendMessage are asynchronous, so even though the native code is appending the result of the call to the StringBuffer, the executeScript method has already returned.

          People

          • Assignee:
            michael_shan
            Reporter:
            wjanssens
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: