mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #15083 - potocpav:issue-14497, r=KiChjang
Fix #14497: WeakMediaQueryListVec assumes its contents are still alive <!-- Please describe your changes on the following line: --> First time contributor here. Noticed this issue is easily solved, so I did it. I am very unsure about how things work here: Is a test needed? What should it look like? Should the "unwrap" be avoided (making bigger changes to the code)? --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #14497 (github issue number if applicable). - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15083) <!-- Reviewable:end -->
This commit is contained in:
commit
29d4f7d467
3 changed files with 21 additions and 2 deletions
|
@ -138,7 +138,7 @@ impl WeakMediaQueryListVec {
|
|||
/// Evaluate media query lists and report changes
|
||||
/// https://drafts.csswg.org/cssom-view/#evaluate-media-queries-and-report-changes
|
||||
pub fn evaluate_and_report_changes(&self) {
|
||||
for mql in self.cell.borrow().iter() {
|
||||
self.cell.borrow_mut().update(|mql| {
|
||||
let mql = mql.root().unwrap();
|
||||
if let MediaQueryListMatchState::Changed(_) = mql.evaluate_changes() {
|
||||
let event = MediaQueryListEvent::new(&mql.global(),
|
||||
|
@ -148,7 +148,7 @@ impl WeakMediaQueryListVec {
|
|||
mql.Matches());
|
||||
event.upcast::<Event>().fire(mql.upcast::<EventTarget>());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8594,6 +8594,12 @@
|
|||
"url": "/_mozilla/mozilla/localeCompare.html"
|
||||
}
|
||||
],
|
||||
"mozilla/media_query_list_gc.html": [
|
||||
{
|
||||
"path": "mozilla/media_query_list_gc.html",
|
||||
"url": "/_mozilla/mozilla/media_query_list_gc.html"
|
||||
}
|
||||
],
|
||||
"mozilla/mime_sniffing_font_context.html": [
|
||||
{
|
||||
"path": "mozilla/mime_sniffing_font_context.html",
|
||||
|
|
13
tests/wpt/mozilla/tests/mozilla/media_query_list_gc.html
Normal file
13
tests/wpt/mozilla/tests/mozilla/media_query_list_gc.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>Should not crash on the resize</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
test(function() {
|
||||
var mql = matchMedia("(min-width: 1000px)");
|
||||
mql = null;
|
||||
gc();
|
||||
window.resizeBy(1,1);
|
||||
})
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue