Bug 1268957. Fire an error event on the <link> element when a stylesheet load is blocked via content policy. r=ckerschb

This commit is contained in:
Boris Zbarsky 2016-05-27 13:31:20 -04:00
Родитель ac9e0794b8
Коммит 0b4bf8c8ff
15 изменённых файлов: 12 добавлений и 145 удалений

Просмотреть файл

@ -52,6 +52,7 @@
#include "nsINetworkPredictor.h"
#include "mozilla/dom/ShadowRoot.h"
#include "mozilla/dom/URL.h"
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/StyleSheetHandle.h"
#include "mozilla/StyleSheetHandleInlines.h"
@ -2083,7 +2084,17 @@ Loader::LoadStyleLink(nsIContent* aElement,
}
nsresult rv = CheckContentPolicy(principal, aURL, context, false);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
if (aElement) {
// Fire an async error event on it.
RefPtr<AsyncEventDispatcher> loadBlockingAsyncDispatcher =
new LoadBlockingAsyncEventDispatcher(aElement,
NS_LITERAL_STRING("error"),
false, false);
loadBlockingAsyncDispatcher->PostDOMEvent();
}
return rv;
}
StyleSheetState state;
StyleSheetHandle::RefPtr sheet;

Просмотреть файл

@ -1,6 +0,0 @@
[opt-in-blocks.https.html]
type: testharness
expected: TIMEOUT
[opt_in_method: http-csp\n origin: cross-origin-http\n source_scheme: https\n context_nesting: top-level\n redirection: keep-scheme-redirect\n subresource: link-css-tag\n expectation: blocked]
expected: NOTRUN

Просмотреть файл

@ -1,26 +0,0 @@
[opt-in-blocks.https.html]
type: testharness
expected:
if not debug and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and (os == "win") and (version == "5.1.2600") and (processor == "x86") and (bits == 32): TIMEOUT
if not debug and (os == "mac") and (version == "OS X 10.8") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86_64") and (bits == 64): TIMEOUT
if debug and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86_64") and (bits == 64): TIMEOUT
if debug and (os == "mac") and (version == "OS X 10.8") and (processor == "x86_64") and (bits == 64): TIMEOUT
if debug and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): TIMEOUT
if debug and (os == "mac") and (version == "OS X 10.10.2") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and (os == "mac") and (version == "OS X 10.10.2") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and (os == "win") and (version == "6.1.7601") and (processor == "x86") and (bits == 32): TIMEOUT
if not debug and (os == "win") and (version == "5.1.2600") and (processor == "x86") and (bits == 32): TIMEOUT
if not debug and (os == "win") and (version == "6.1.7601") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and (os == "win") and (version == "10.0.10240") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and (os == "win") and (version == "10.0.10240") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and not e10s and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86") and (bits == 32): TIMEOUT
if not debug and e10s and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and not e10s and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86_64") and (bits == 64): TIMEOUT
if debug and e10s and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86_64") and (bits == 64): TIMEOUT
[opt_in_method: http-csp\n origin: cross-origin-http\n source_scheme: https\n context_nesting: top-level\n redirection: no-redirect\n subresource: link-css-tag\n expectation: blocked]
expected: NOTRUN

Просмотреть файл

@ -1,6 +0,0 @@
[opt-in-blocks.https.html]
type: testharness
expected: TIMEOUT
[opt_in_method: http-csp\n origin: cross-origin-http\n source_scheme: https\n context_nesting: top-level\n redirection: swap-scheme-redirect\n subresource: link-css-tag\n expectation: blocked]
expected: NOTRUN

Просмотреть файл

@ -1,6 +0,0 @@
[opt-in-blocks.https.html]
type: testharness
expected: TIMEOUT
[opt_in_method: http-csp\n origin: same-host-http\n source_scheme: https\n context_nesting: top-level\n redirection: keep-scheme-redirect\n subresource: link-css-tag\n expectation: blocked]
expected: NOTRUN

Просмотреть файл

@ -1,26 +0,0 @@
[opt-in-blocks.https.html]
type: testharness
expected:
if not debug and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and (os == "win") and (version == "5.1.2600") and (processor == "x86") and (bits == 32): TIMEOUT
if not debug and (os == "mac") and (version == "OS X 10.8") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86_64") and (bits == 64): TIMEOUT
if debug and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86_64") and (bits == 64): TIMEOUT
if debug and (os == "mac") and (version == "OS X 10.8") and (processor == "x86_64") and (bits == 64): TIMEOUT
if debug and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): TIMEOUT
if debug and (os == "mac") and (version == "OS X 10.10.2") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and (os == "mac") and (version == "OS X 10.10.2") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and (os == "win") and (version == "6.1.7601") and (processor == "x86") and (bits == 32): TIMEOUT
if not debug and (os == "win") and (version == "5.1.2600") and (processor == "x86") and (bits == 32): TIMEOUT
if not debug and (os == "win") and (version == "6.1.7601") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and (os == "win") and (version == "10.0.10240") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and (os == "win") and (version == "10.0.10240") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and not e10s and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86") and (bits == 32): TIMEOUT
if not debug and e10s and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and not e10s and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86_64") and (bits == 64): TIMEOUT
if debug and e10s and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86_64") and (bits == 64): TIMEOUT
[opt_in_method: http-csp\n origin: same-host-http\n source_scheme: https\n context_nesting: top-level\n redirection: no-redirect\n subresource: link-css-tag\n expectation: blocked]
expected: NOTRUN

Просмотреть файл

@ -1,6 +0,0 @@
[opt-in-blocks.https.html]
type: testharness
expected: TIMEOUT
[opt_in_method: http-csp\n origin: same-host-http\n source_scheme: https\n context_nesting: top-level\n redirection: swap-scheme-redirect\n subresource: link-css-tag\n expectation: blocked]
expected: NOTRUN

Просмотреть файл

@ -1,6 +0,0 @@
[opt-in-blocks.https.html]
type: testharness
expected: TIMEOUT
[opt_in_method: meta-csp\n origin: cross-origin-http\n source_scheme: https\n context_nesting: top-level\n redirection: no-redirect\n subresource: link-css-tag\n expectation: blocked]
expected: NOTRUN

Просмотреть файл

@ -1,6 +0,0 @@
[opt-in-blocks.https.html]
type: testharness
expected: TIMEOUT
[opt_in_method: meta-csp\n origin: same-host-http\n source_scheme: https\n context_nesting: top-level\n redirection: no-redirect\n subresource: link-css-tag\n expectation: blocked]
expected: NOTRUN

Просмотреть файл

@ -1,6 +0,0 @@
[no-opt-in-blocks.https.html]
type: testharness
expected: TIMEOUT
[opt_in_method: no-opt-in\n origin: cross-origin-http\n source_scheme: https\n context_nesting: top-level\n redirection: keep-scheme-redirect\n subresource: link-css-tag\n expectation: blocked]
expected: NOTRUN

Просмотреть файл

@ -1,6 +0,0 @@
[no-opt-in-blocks.https.html]
type: testharness
expected: TIMEOUT
[opt_in_method: no-opt-in\n origin: cross-origin-http\n source_scheme: https\n context_nesting: top-level\n redirection: no-redirect\n subresource: link-css-tag\n expectation: blocked]
expected: NOTRUN

Просмотреть файл

@ -1,6 +0,0 @@
[no-opt-in-blocks.https.html]
type: testharness
expected: TIMEOUT
[opt_in_method: no-opt-in\n origin: cross-origin-http\n source_scheme: https\n context_nesting: top-level\n redirection: swap-scheme-redirect\n subresource: link-css-tag\n expectation: blocked]
expected: NOTRUN

Просмотреть файл

@ -1,6 +0,0 @@
[no-opt-in-blocks.https.html]
type: testharness
expected: TIMEOUT
[opt_in_method: no-opt-in\n origin: same-host-http\n source_scheme: https\n context_nesting: top-level\n redirection: keep-scheme-redirect\n subresource: link-css-tag\n expectation: blocked]
expected: NOTRUN

Просмотреть файл

@ -1,26 +0,0 @@
[no-opt-in-blocks.https.html]
type: testharness
expected:
if not debug and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and (os == "win") and (version == "5.1.2600") and (processor == "x86") and (bits == 32): TIMEOUT
if not debug and (os == "mac") and (version == "OS X 10.8") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86_64") and (bits == 64): TIMEOUT
if debug and (os == "mac") and (version == "OS X 10.8") and (processor == "x86_64") and (bits == 64): TIMEOUT
if debug and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): TIMEOUT
if debug and (os == "mac") and (version == "OS X 10.10.2") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and (os == "mac") and (version == "OS X 10.10.2") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and (os == "win") and (version == "6.1.7601") and (processor == "x86") and (bits == 32): TIMEOUT
if not debug and (os == "win") and (version == "5.1.2600") and (processor == "x86") and (bits == 32): TIMEOUT
if not debug and (os == "win") and (version == "6.1.7601") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86_64") and (bits == 64): TIMEOUT
if debug and (os == "win") and (version == "10.0.10240") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and (os == "win") and (version == "10.0.10240") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and not e10s and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86") and (bits == 32): TIMEOUT
if not debug and e10s and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and not e10s and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86_64") and (bits == 64): TIMEOUT
if debug and e10s and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86_64") and (bits == 64): TIMEOUT
[opt_in_method: no-opt-in\n origin: same-host-http\n source_scheme: https\n context_nesting: top-level\n redirection: no-redirect\n subresource: link-css-tag\n expectation: blocked]
expected: NOTRUN

Просмотреть файл

@ -1,6 +0,0 @@
[no-opt-in-blocks.https.html]
type: testharness
expected: TIMEOUT
[opt_in_method: no-opt-in\n origin: same-host-http\n source_scheme: https\n context_nesting: top-level\n redirection: swap-scheme-redirect\n subresource: link-css-tag\n expectation: blocked]
expected: NOTRUN