Expose the source map URL on a style sheet

This changes Servo to track the source map URL of a style sheet.  This
parallels a change going in to Gecko:
https://bugzilla.mozilla.org/show_bug.cgi?id=1388855
This commit is contained in:
Tom Tromey 2017-08-11 14:40:20 -06:00
parent fbabcaf614
commit 7224a5617f
7 changed files with 61 additions and 17 deletions

View file

@ -241,6 +241,7 @@ fn test_parse_stylesheet() {
},
})))
], &stylesheet.shared_lock),
source_map_url: RwLock::new(None),
},
media: Arc::new(stylesheet.shared_lock.wrap(MediaList::empty())),
shared_lock: stylesheet.shared_lock.clone(),
@ -350,3 +351,22 @@ fn test_no_report_unrecognized_vendor_properties() {
error.message);
assert!(errors.is_empty());
}
#[test]
fn test_source_map_url() {
let tests = vec![
("", None),
("/*# sourceMappingURL=something */", Some("something".to_string())),
];
for test in tests {
let url = ServoUrl::parse("about::test").unwrap();
let lock = SharedRwLock::new();
let media = Arc::new(lock.wrap(MediaList::empty()));
let stylesheet = Stylesheet::from_str(test.0, url.clone(), Origin::UserAgent, media, lock,
None, &CSSErrorReporterTest, QuirksMode::NoQuirks,
0u64);
let url_opt = stylesheet.contents.source_map_url.read();
assert_eq!(*url_opt, test.1);
}
}