With CommonJS global mozmill objects are not in module scope anymore

VERIFIED FIXED

Status

Testing Graveyard
Mozmill
VERIFIED FIXED
7 years ago
a year ago

People

(Reporter: whimboo, Assigned: whimboo)

Tracking

({regression})

Trunk
regression
Dependency tree / graph

Details

(Whiteboard: [mozmill-1.5.1+])

Attachments

(2 attachments)

(Assignee)

Description

7 years ago
With the update to CommonJS I'm not able to access the mozmill object from within modules anymore. It's only available inside the tests itself. That's kinda bad because we have some instances where we call mozmill.controller.sleep without having to pass a controller instance into the helper function.

See the attachment which contains an example test and module. Once you remove the mozmill parameter from the setup function, the code will fail.
(Assignee)

Comment 1

7 years ago
Created attachment 481455 [details] [diff] [review]
test case
(Assignee)

Comment 2

7 years ago
It can be solved by putting the mozmill object into the globals array. We should also check to which other objects modules should have access to.
(Assignee)

Comment 3

7 years ago
And one more thing. Would there be a way to set a module id? I would really like to replace the MODULE_NAME with module.id, i.e:

OLD: var MODULE_NAME = 'UtilsAPI';
New: module.id = 'utils';

But there is no global module object in the scope. See http://wiki.commonjs.org/wiki/Modules/1.1#Sample_Code
(Assignee)

Comment 4

7 years ago
Beside Mozmill it also affects elementslib.
Summary: With CommonJS mozmill object is not in module scope anymore → With CommonJS global mozmill objects are not in module scope anymore
(Assignee)

Comment 5

7 years ago
Created attachment 481476 [details] [diff] [review]
Patch v1

Proposed patch which should at least retain access to the global objects from within the modules.
Attachment #481476 - Flags: review?
(Assignee)

Updated

7 years ago
Attachment #481476 - Flags: review? → review?(harthur)
Comment on attachment 481476 [details] [diff] [review]
Patch v1

looks good
Attachment #481476 - Flags: review?(harthur) → review+
(Assignee)

Comment 7

7 years ago
Heather, could you also give me feedback for comment 3? That would be great.
(In reply to comment #3)
> And one more thing. Would there be a way to set a module id? I would really
> like to replace the MODULE_NAME with module.id, i.e:
> 
> OLD: var MODULE_NAME = 'UtilsAPI';
> New: module.id = 'utils';
> 
> But there is no global module object in the scope. See
> http://wiki.commonjs.org/wiki/Modules/1.1#Sample_Code

Right now we're kind of at the mercy of the Jetpack SDK's module loader, though we could hack in better CommonJS support. Right now you can just name the file what you want the module name to be.
(Assignee)

Comment 9

7 years ago
(In reply to comment #8)
> Right now we're kind of at the mercy of the Jetpack SDK's module loader, though
> we could hack in better CommonJS support. Right now you can just name the file
> what you want the module name to be.

Alright. That would work.

Would it be possible to give this bug approval for Mozmill 1.5.1?
Whiteboard: [mozmill-1.5.1?] → [mozmill-1.5.1+]
(Assignee)

Updated

7 years ago
Assignee: nobody → hskupin
Status: NEW → ASSIGNED
(Assignee)

Comment 10

7 years ago
Landed as:
http://github.com/mozautomation/mozmill/commit/6a93c3e6cd0c0a6cc6f08ce99f6238b90eab1521 (master)
http://github.com/mozautomation/mozmill/commit/23676c4fa3ce6001b15c7359d455b3c5a3b9aebc (hotfix-1.5.1)
Status: ASSIGNED → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → FIXED
(Assignee)

Updated

7 years ago
Blocks: 602365
Verified fixed with 1.5.1rc1
Status: RESOLVED → VERIFIED
Product: Testing → Testing Graveyard
You need to log in before you can comment on or make changes to this bug.