I'm not a gaia marionette expert, but isn't it because execute_script
evaluates the script in your input.html document with content priviledges
(i.e. with same priviledges than a regular webpage)?
Regular webpages can't have access to domWindowUtils...


2014-03-27 11:07 GMT+01:00 Phoebe Chang <[email protected]>:

>  Hi all,
>
> I'm recently trying to write marionette test case for text selection, and
> have faced some problem on how to send an input character to where the
> caret is.
>
> I tried to use sendKeyEvent in nsIDOMWindowUtils with
> marionette.execute_script. Here's the code.
>
> *from marionette_test import MarionetteTestCase*
> *from marionette import Actions*
>
> *class TestTouchCaret(MarionetteTestCase):*
> *    def test_touchcaret(self):*
> *    test_html = self.marionette.absolute_url("input.html")*
> *    self.marionette.navigate(test_html)*
> *    element = self.marionette.find_element(By.ID, "foo")*
> *    self.assertEqual("ABC", self.marionette.execute_script("return
> arguments[0].value;", [element]))*
>
> *    element.tap(0,0)*
> *    self.marionette.execute_script("""*
> *          let Ci = Components.interfaces;*
> *          var win = document.defaultView;*
> *          let domWindowUtils =
> win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);*
> *          domWindowUtils.sendKeyEvent('keypress', 0, 96, 0);*
> *          """)*
>
> but it kept sending
>   *JavascriptException: JavascriptException: [Exception... "Could not
> convert JavaScript argument arg 0 [nsISupports.QueryInterface]"  nsresult:
> "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)"  location: "JS frame :: dummy
> file :: __marionetteFunc :: line 3"  data: no]*
>
> I'm not sure what the problem is, can anyone who is familiar with
> marionette help me figure this out? thanks.
>
> _______________________________________________
> dev-b2g mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-b2g
>
>
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g

Reply via email to