Closed Bug 1319995 Opened 4 years ago Closed 4 years ago

Set the substituting handler of the resources of "formautofill" in xpcshell tests

Categories

(Toolkit :: Form Manager, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla53
Tracking Status
firefox53 --- fixed

People

(Reporter: lchang, Assigned: lchang)

References

Details

(Whiteboard: [form autofill:M1])

Attachments

(1 file)

I just learnt that it might be a proper way to load addon resources in xpcshell tests.
Hi Matt,

By changing to this we don't need to mock "defineLazyModuleGetter" (and even "Cu.import") in "head.js" anymore. I think it would be more intuitive and helpful for further tests' implementation. Could you take a look? Thanks.
Comment on attachment 8813957 [details]
Bug 1319995 - Set the substituting handler of the resources of "formautofill" in xpcshell tests;

https://reviewboard.mozilla.org/r/95262/#review95572

r=me with the cleanup.

::: browser/extensions/formautofill/test/unit/head.js:21
(Diff revision 1)
> +// Register the resource path of formautofill
> +let resHandler = Services.io.getProtocolHandler("resource")
> +                            .QueryInterface(Ci.nsISubstitutingProtocolHandler);
> +let dataURI = NetUtil.newURI(do_get_file(".", true));
> +resHandler.setSubstitution("formautofill", dataURI);

Cool. It seems like we should also have a registerCleanup… in head.js to revert this at the end of each test so it doesn't leak into non-autofill tests.
"A null baseURI removes the specified substitution."
Attachment #8813957 - Flags: review?(MattN+bmo) → review+
Comment on attachment 8813957 [details]
Bug 1319995 - Set the substituting handler of the resources of "formautofill" in xpcshell tests;

https://reviewboard.mozilla.org/r/95262/#review95572

> Cool. It seems like we should also have a registerCleanup… in head.js to revert this at the end of each test so it doesn't leak into non-autofill tests.
> "A null baseURI removes the specified substitution."

Thanks for pointing it out. I end up added the clean-up code in tail.js so we can avoid forgetting to do that in each test.
Tests passed.
Keywords: checkin-needed
Pushed by ihsiao@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/82018512953d
Set the substituting handler of the resources of "formautofill" in xpcshell tests; r=MattN
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/82018512953d
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
Flags: qe-verify-
You need to log in before you can comment on or make changes to this bug.