Closed Bug 805838 Opened 12 years ago Closed 11 years ago

Allow JavaScript Marionette tests to import a script for common code

Categories

(Remote Protocol :: Marionette, defect)

defect
Not set
normal

Tracking

(firefox27 fixed, b2g-v1.2 fixed)

RESOLVED FIXED
mozilla27
Tracking Status
firefox27 --- fixed
b2g-v1.2 --- fixed

People

(Reporter: davehunt, Assigned: aknow)

References

Details

Attachments

(2 files, 1 obsolete file)

In order to reduce duplication across WebAPI tests, it would be beneficial to allow importing of JavaScript files containing common functions.
Blocks: 805452
We'll have a way to import scripts as soon as we land the change in this bug.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → DUPLICATE
I believe it will be good to keep this bug open regarding any dependency we have here to create Marionette tests. Bug 797912 is too general to understand why we depend on it. Usually we add a dependency in such a case.
Status: RESOLVED → REOPENED
Depends on: 797912
Resolution: DUPLICATE → ---
Whiteboard: [needs bug 797912]
Yes, this won't be helped by bug 797912, because this will need to call back into the client to fetch the script to load.
This will require a completely separate implementation from bug 797912, so am removing that as a dependency.
No longer depends on: 797912
Whiteboard: [needs bug 797912]
What's the current status of this one? I've raise a duplicate bug 917223 and come here from that bug. Another duplicate Bug 734189 suggest a node.js-style 'require' statement. For that solution, We might need to handle the scope issue and manipulate the js script. In bug 917223, my initial idea is to introduce a tag in the test script MARIONETTE_JS_HEADER = 'head.js'; We could just simply prepend the head.js and the run the script. It could be implement in marionette client.
I like the head.js approach, as it's considerably simpler than a 'require' implementation.
Assignee: nobody → szchen
Attached patch Add MARIONETTE_HEAD_JS support (obsolete) — Splinter Review
Attachment #806416 - Flags: review?(jgriffin)
Example test case that use head.js to do some common setup and teardown works.
Attachment #806417 - Attachment description: 0001-Example-test-with-head.js.patch → Example test with head.js
(In reply to Szu-Yu Chen [:aknow] from comment #9) > Created attachment 806416 [details] [diff] [review] > Add MARIONETTE_HEAD_JS support Some limitation now. 1. Only allow to prepend 1 head.js. 2. Not allow nested HEAD. We should not put the line of MARIONETTE_HEAD_JS = xxx in some head.js It's not hard to break the above limitations. However, I would like to keep them as the restrictions and make everything simple.
Comment on attachment 806416 [details] [diff] [review] Add MARIONETTE_HEAD_JS support Review of attachment 806416 [details] [diff] [review]: ----------------------------------------------------------------- Looks great, thanks for the patch!
Attachment #806416 - Flags: review?(jgriffin) → review+
We should also update the mdn for the new test flag (MARIONETTE_HEAD_JS). https://developer.mozilla.org/en-US/docs/Marionette/Marionette_JavaScript_Tests
Status: REOPENED → RESOLVED
Closed: 12 years ago11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla27
Blocks: 945959
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: