Closed Bug 1197507 Opened 7 years ago Closed 7 years ago

Mochitest support for WebExtensions

Categories

(WebExtensions :: Untriaged, defect)

defect
Not set
normal

Tracking

(firefox43 fixed)

RESOLVED FIXED
mozilla43
Tracking Status
firefox43 --- fixed

People

(Reporter: billm, Assigned: billm)

References

Details

Attachments

(5 files, 3 obsolete files)

I wanted to get be able to use xpcshell tests for WebExtensions, but that turned out to be a lot of work. It's probably best to start with Mochitests since these run on all platforms including mobile. These will test code that currently lives in toolkit/. For the stuff in browser/, we'll probably want to use browser-chrome tests. The code here could perhaps be adapted for that.
I don't want to have to use chrome.* APIs in our tests, so I made this alias.
Attachment #8651396 - Flags: review?(gkrizsanits)
I would like to be able to load extensions off HTTP for testing, since all Mochitest files are loaded through HTTP as far as I know. I don't think adding HTTP here should be a problem since it doesn't grant any special privileges to the resource. We won't use this in production code.
Attachment #8651397 - Flags: review?(bobbyholley)
This API is similar to an internal one that Chrome has. It allows extensions to communicate with test harness code. I used an event emitter to take care of the actual communication. The other endpoint is in a later patch.
Attachment #8651398 - Flags: review?(gkrizsanits)
Attached patch simple testsSplinter Review
This patch has some test examples. I'm going to post a more substantial test in bug 1190330.
Attachment #8651400 - Flags: review?(gkrizsanits)
Comment on attachment 8651397 [details] [diff] [review]
allow HTTP resources in moz-extension: substitutions

These URIs claim URI_IS_LOCAL_FILE - isn't that a problem?

We could probably use nsIProtocolHandlerWithDynamicFlags to solve this, but this patch doesn't do that...
Attachment #8651397 - Flags: review?(bobbyholley)
OK. I assume you meant URI_IS_LOCAL_RESOURCE since these handlers don't claim URI_IS_LOCAL_FILE. I hope I didn't go overboard here. It's a bit hard to understand all the things this flag is used for.

If you're worried about EnsureFile, I think we're covered there:
http://mxr.mozilla.org/mozilla-central/source/netwerk/base/nsStandardURL.cpp#1823
Attachment #8651397 - Attachment is obsolete: true
Attachment #8651438 - Flags: review?(bobbyholley)
This makes the default be to not allow the chrome: scheme.
Attachment #8651438 - Attachment is obsolete: true
Attachment #8651438 - Flags: review?(bobbyholley)
Attachment #8651455 - Flags: review?(bobbyholley)
Attachment #8651396 - Flags: review?(gkrizsanits) → review+
Attachment #8651398 - Flags: review?(gkrizsanits) → review+
Comment on attachment 8651399 [details] [diff] [review]
allow mochitests to load WebExtensions via special powers

Review of attachment 8651399 [details] [diff] [review]:
-----------------------------------------------------------------

If loading the extension fails, will the reason for the failure be visible somewhere (console, try log)? I guess it will be but I have seen some swallowed up exceptions over the years, so I was wondering. Another thing is that I'm missing some kind of load/startup failed hook, in case something goes wrong to avoid test hangs. I don't want to hold up landing this patch it's already great as it is, we can do a follow-up for that hook if you agree with it or let me know if there is a good reason why such additional hook is not needed.
Attachment #8651399 - Flags: review?(gkrizsanits) → review+
Comment on attachment 8651400 [details] [diff] [review]
simple tests

Review of attachment 8651400 [details] [diff] [review]:
-----------------------------------------------------------------

::: toolkit/components/extensions/test/mochitest/mochitest.ini
@@ +16,5 @@
> +  file_script_redirect.js
> +  file_script_xhr.js
> +
> +[test_simple_extensions.html]
> +[test_extension_webrequest.html]

this should go to the other patch
Attachment #8651400 - Flags: review?(gkrizsanits) → review+
Comment on attachment 8651455 [details] [diff] [review]
allow HTTP resources in moz-extension: substitutions v3

Review of attachment 8651455 [details] [diff] [review]:
-----------------------------------------------------------------

Per discussion, I think we should find a way to solve this problem in the test infrastructure.
Attachment #8651455 - Flags: review?(bobbyholley) → review-
Attachment #8651455 - Attachment is obsolete: true
Attachment #8652431 - Flags: review?(bobbyholley)
Attachment #8652431 - Flags: review?(bobbyholley) → review+
Oops. The last patch landed with the wrong bug number. 91e5acc46643 is actually bug 1190330.
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.