Skip to content

Commit

Permalink
Do not unwrap in element{,s}FromPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KiChjang committed May 8, 2018
1 parent acd4e21 commit df23f90
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
7 changes: 5 additions & 2 deletions components/script/dom/document.rs
Expand Up @@ -3624,7 +3624,7 @@ impl DocumentMethods for Document {
let y = *y as f32;
let point = &Point2D::new(x, y);
let window = window_from_node(self);
let viewport = window.window_size().unwrap().initial_viewport;
let viewport = window.window_size()?.initial_viewport;

if self.browsing_context().is_none() {
return None;
Expand Down Expand Up @@ -3658,7 +3658,10 @@ impl DocumentMethods for Document {
let y = *y as f32;
let point = &Point2D::new(x, y);
let window = window_from_node(self);
let viewport = window.window_size().unwrap().initial_viewport;
let viewport = match window.window_size() {
Some(size) => size.initial_viewport,
None => return vec![]
};

if self.browsing_context().is_none() {
return vec!();
Expand Down
5 changes: 4 additions & 1 deletion tests/wpt/metadata/css/cssom-view/elementsFromPoint.html.ini
@@ -1,4 +1,7 @@
[elementsFromPoint.html]
type: testharness
expected: CRASH
[SVG element at x,y]
expected: FAIL
[transformed element at x,y]
expected: FAIL

7 changes: 6 additions & 1 deletion tests/wpt/metadata/css/cssom-view/matchMedia.xht.ini
@@ -1,5 +1,6 @@
[matchMedia.xht]
type: testharness
expected: TIMEOUT
[window.matchMedia exists]
expected: FAIL
[MediaQueryList.matches for "(max-width: 199px), all and (min-width: 200px)"]
Expand All @@ -11,5 +12,9 @@
[MediaQueryList.matches for "(min-width: 150px)"]
expected: FAIL
[Resize iframe from 200x100 to 200x50, then to 100x50]
expected: FAIL
expected: NOTRUN
[Listeners are called in the order which they have been added]
expected: NOTRUN
[Listener added twice is only called once.]
expected: NOTRUN

0 comments on commit df23f90

Please sign in to comment.