mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Interact with the originating document for stylesheet loads, rather than the element's current document.
This commit is contained in:
parent
1e927ca88b
commit
318a047ee5
6 changed files with 56 additions and 3 deletions
|
@ -6,6 +6,7 @@ use document_loader::LoadType;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
use dom::bindings::reflector::DomObject;
|
use dom::bindings::reflector::DomObject;
|
||||||
|
use dom::document::Document;
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
|
@ -78,6 +79,8 @@ pub struct StylesheetContext {
|
||||||
metadata: Option<Metadata>,
|
metadata: Option<Metadata>,
|
||||||
/// The response body received to date.
|
/// The response body received to date.
|
||||||
data: Vec<u8>,
|
data: Vec<u8>,
|
||||||
|
/// The node document for elem when the load was initiated.
|
||||||
|
document: Trusted<Document>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PreInvoke for StylesheetContext {}
|
impl PreInvoke for StylesheetContext {}
|
||||||
|
@ -103,7 +106,7 @@ impl FetchResponseListener for StylesheetContext {
|
||||||
|
|
||||||
fn process_response_eof(&mut self, status: Result<(), NetworkError>) {
|
fn process_response_eof(&mut self, status: Result<(), NetworkError>) {
|
||||||
let elem = self.elem.root();
|
let elem = self.elem.root();
|
||||||
let document = document_from_node(&*elem);
|
let document = self.document.root();
|
||||||
let mut successful = false;
|
let mut successful = false;
|
||||||
|
|
||||||
if status.is_ok() {
|
if status.is_ok() {
|
||||||
|
@ -192,15 +195,15 @@ impl<'a> StylesheetLoader<'a> {
|
||||||
impl<'a> StylesheetLoader<'a> {
|
impl<'a> StylesheetLoader<'a> {
|
||||||
pub fn load(&self, source: StylesheetContextSource) {
|
pub fn load(&self, source: StylesheetContextSource) {
|
||||||
let url = source.url();
|
let url = source.url();
|
||||||
|
let document = document_from_node(self.elem);
|
||||||
let context = Arc::new(Mutex::new(StylesheetContext {
|
let context = Arc::new(Mutex::new(StylesheetContext {
|
||||||
elem: Trusted::new(&*self.elem),
|
elem: Trusted::new(&*self.elem),
|
||||||
source: source,
|
source: source,
|
||||||
metadata: None,
|
metadata: None,
|
||||||
data: vec![],
|
data: vec![],
|
||||||
|
document: Trusted::new(&*document),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let document = document_from_node(self.elem);
|
|
||||||
|
|
||||||
let (action_sender, action_receiver) = ipc::channel().unwrap();
|
let (action_sender, action_receiver) = ipc::channel().unwrap();
|
||||||
let listener = NetworkListener {
|
let listener = NetworkListener {
|
||||||
context: context,
|
context: context,
|
||||||
|
|
|
@ -6474,6 +6474,18 @@
|
||||||
"url": "/_mozilla/mozilla/sslfail.html"
|
"url": "/_mozilla/mozilla/sslfail.html"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"mozilla/stylesheet-adopt-panic.html": [
|
||||||
|
{
|
||||||
|
"path": "mozilla/stylesheet-adopt-panic.html",
|
||||||
|
"references": [
|
||||||
|
[
|
||||||
|
"/_mozilla/mozilla/stylesheet-adopt-panic-ref.html",
|
||||||
|
"=="
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"url": "/_mozilla/mozilla/stylesheet-adopt-panic.html"
|
||||||
|
}
|
||||||
|
],
|
||||||
"mozilla/svg/svg.html": [
|
"mozilla/svg/svg.html": [
|
||||||
{
|
{
|
||||||
"path": "mozilla/svg/svg.html",
|
"path": "mozilla/svg/svg.html",
|
||||||
|
@ -21756,6 +21768,18 @@
|
||||||
"url": "/_mozilla/mozilla/sslfail.html"
|
"url": "/_mozilla/mozilla/sslfail.html"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"mozilla/stylesheet-adopt-panic.html": [
|
||||||
|
{
|
||||||
|
"path": "mozilla/stylesheet-adopt-panic.html",
|
||||||
|
"references": [
|
||||||
|
[
|
||||||
|
"/_mozilla/mozilla/stylesheet-adopt-panic-ref.html",
|
||||||
|
"=="
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"url": "/_mozilla/mozilla/stylesheet-adopt-panic.html"
|
||||||
|
}
|
||||||
|
],
|
||||||
"mozilla/svg/svg.html": [
|
"mozilla/svg/svg.html": [
|
||||||
{
|
{
|
||||||
"path": "mozilla/svg/svg.html",
|
"path": "mozilla/svg/svg.html",
|
||||||
|
|
3
tests/wpt/mozilla/tests/mozilla/adopt-panic.css
Normal file
3
tests/wpt/mozilla/tests/mozilla/adopt-panic.css
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
body {
|
||||||
|
background-color: green;
|
||||||
|
}
|
2
tests/wpt/mozilla/tests/mozilla/blank.html
Normal file
2
tests/wpt/mozilla/tests/mozilla/blank.html
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<!doctype html>
|
||||||
|
<title>Blank document</title>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<iframe src="blank.html"></iframe>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: green;
|
||||||
|
}
|
||||||
|
</style>
|
13
tests/wpt/mozilla/tests/mozilla/stylesheet-adopt-panic.html
Normal file
13
tests/wpt/mozilla/tests/mozilla/stylesheet-adopt-panic.html
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Verify that adopting a stylesheet with an import applies its styles and doesn't panic</title>
|
||||||
|
<link rel="match" href="stylesheet-adopt-panic-ref.html">
|
||||||
|
<iframe src="blank.html" onload="foo()"></iframe>
|
||||||
|
<script>
|
||||||
|
function foo() {
|
||||||
|
var i = document.querySelector('iframe');
|
||||||
|
i.contentDocument.documentElement.innerHTML = "<style>@import 'adopt-panic.css';</style>";
|
||||||
|
var e = i.contentDocument.querySelector('style');
|
||||||
|
document.body.appendChild(e);
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue