Closed Bug 1623176 Opened 4 years ago Closed 4 years ago

Setting a CSP with 'self' or 'none' with createHttpServer() makes xpcshell test hang

Categories

(WebExtensions :: General, defect, P2)

defect

Tracking

(firefox-esr78 fixed, firefox79 fixed)

RESOLVED FIXED
mozilla79
Tracking Status
firefox-esr78 --- fixed
firefox79 --- fixed

People

(Reporter: t-mozbugs, Assigned: robwu)

Details

Attachments

(1 file)

STR:

  1. In an xpcshell-test, using createHttpServer().registerPathHandler(), create a page with a Content-security-policy containing the keyword source 'none' or 'self' (or most likely any other source containing a ', but not a hostname or *).
  2. Then navigate to it using ExtensionTestUtils.loadContentPage().

An example of this is implemented at toolkit/components/extensions/test/xpcshell/test_ext_webRequest_mergecsp.js (see the TODO).

ER:

loadContentPage() loads the page and returns.

AR:

the test gets stuck at the loadContentPage() call, as some dump() statements reveal.

--

This only appears to affect CSPs set by createHttpServer, not policies set by webExtensions.

This was discussed at https://phabricator.services.mozilla.com/D63556

Flags: needinfo?(mixedpuppy)

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: General → DOM: Security

I'm more inclined right now, without investigating, to think this is an issue in our tests.

Component: DOM: Security → General
Product: Core → WebExtensions
Flags: needinfo?(mixedpuppy) → qe-verify-
Flags: needinfo?(mixedpuppy)

Because this bug's Severity has not been changed from the default since it was filed, and it's Priority is -- (Backlog,) indicating it has has not been previously triaged, the bug's Severity is being updated to -- (default, untriaged.)

Because this bug's Severity has not been changed from the default since it was filed, and it's Priority is -- (Backlog,) indicating it has has not been previously triaged, the bug's Severity is being updated to -- (default, untriaged.)

Because this bug's Severity has not been changed from the default since it was filed, and it's Priority is -- (Backlog,) indicating it has has not been previously triaged, the bug's Severity is being updated to -- (default, untriaged.)

Severity: normal → S3

The severity of these bugs was changed, mistakenly, from normal to S3.

Because these bugs have a priority of --, indicating that they have not been previously triaged, these bugs should be changed to Severity of --.

Severity: S3 → --
Severity: -- → S3
Priority: -- → P2

I'll fix the issue (explained in the commit message).

I'll also remove the comment because the expectation here is incorrect:

TODO Bug 1623176: this test hangs on .loadContentPage() when using "img-src
'self'" as the page's CSP, which should result in {true, true, true true}!
  • Server sends: image-src 'self';
  • Extension 1 removes the CSP header
  • Extension 2 sets the CSP header to image-src example.com

The effective result is image-src example.com, so the first image load is expected to be blocked.

Note that the merging logic is incorrect and will be updated in bug 1635781.

Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Flags: needinfo?(mixedpuppy)
Resolution: --- → INVALID

A test used encodeURIComponent on a query string and expected the
resulting URL to be comparable with URLs in a progress listener.
But encodeURIComponent doesn't escape an apostrophe ('), whereas
' is percent-encoded as %27 via nsIURI.

To ensure that it works as expected, use nsIURI::equals to compare
URLs instead of doing string comparisons.

Assignee: nobody → rob
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: INVALID → ---
Status: REOPENED → ASSIGNED
Pushed by rob@robwu.nl:
https://hg.mozilla.org/integration/autoland/rev/851959efb69a
Normalize URI in loadContentPage r=mixedpuppy
Status: ASSIGNED → RESOLVED
Closed: 4 years ago4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla79
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: