Closed Bug 602455 Opened 14 years ago Closed 14 years ago

With CommonJS global mozmill objects are not in module scope anymore

Categories

(Testing Graveyard :: Mozmill, defect)

defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: whimboo, Assigned: whimboo)

References

Details

(Keywords: regression, Whiteboard: [mozmill-1.5.1+])

Attachments

(2 files)

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.
Attached patch test caseSplinter Review
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.
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
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
Attached patch Patch v1Splinter Review
Proposed patch which should at least retain access to the global objects from within the modules.
Attachment #481476 - Flags: review?
Attachment #481476 - Flags: review? → review?(harthur)
Comment on attachment 481476 [details] [diff] [review]
Patch v1

looks good
Attachment #481476 - Flags: review?(harthur) → review+
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.
(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: nobody → hskupin
Status: NEW → ASSIGNED
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.

Attachment

General

Created:
Updated:
Size: