Closed Bug 1128773 Opened 9 years ago Closed 7 years ago

Executing javascript function loaded with import_script fails

Categories

(Remote Protocol :: Marionette, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: erahm, Unassigned)

Details

(Keywords: pi-marionette-server)

While running the full AWSY tests I ran into some situations where running the function |createCheckpoint| that is defined in a separate js script[1] that gets loaded fails due to |createCheckpoint| not being defined.

Code snippet:
>        self.logger.info("starting checkpoint %s..." % checkpoint)
>        js = os.path.abspath(os.path.join(__file__, os.path.pardir, "checkpoint.js"))
>        self.marionette.import_script(js)
>        checkpoint = None
>        try:
>          checkpoint = self.marionette.execute_async_script("createCheckpoint(\"%s\")" % checkpoint, script_timeout=60000)
>        except JavascriptException, e:
>          self.logger.error("Checkpoint JavaScript error: %s" % e)

And the error:
>17:57.57 LOG: MainThread ERROR Checkpoint JavaScript error: JavascriptException: ReferenceError: createCheckpoint is not defined
>stacktrace:
>        execute_async_script @test_memory_usage.py, line 217
>        inline javascript, line 0
>        src: "__marionetteParams.push(returnFunc);let marionetteScriptFinished = returnFunc;let __marionetteFunc = function() >{createCheckpoint("None")};__marionetteFunc.apply(null, __marionetteParams);"

[1] https://github.com/EricRahm/areweslimyet/blob/marionette/benchtester/checkpoint.js
Do you have anything else to offer about when this fails and when it doesn't? This looks to me like a very typical use of import_script.
(In reply to Chris Manchester [:chmanchester] from comment #1)
> Do you have anything else to offer about when this fails and when it
> doesn't? This looks to me like a very typical use of import_script.

I'll attempt to reproduce and reduce locally.
This causes about a 75% failure rate for AWSY runs. That snippet of code is run 32 times over the duration of a test. It's hard for me to tell how quickly it fails unfortunately.
I spent a fair amount of time trying to reduce this to a small test case outside of AWSY and had no luck. As a work-around I just load the script through python rather than |import_script| and then pass that to |execute_async_script|. This seems to be working reasonably well and I haven't encountered any errors.
import_script was removed as a feature.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.