Do not unwrap in element{,s}FromPoint

This commit is contained in:
Keith Yeung 2018-05-07 23:25:09 -07:00
parent acd4e215ab
commit df23f909cd
3 changed files with 15 additions and 4 deletions

View file

@ -3624,7 +3624,7 @@ impl DocumentMethods for Document {
let y = *y as f32; let y = *y as f32;
let point = &Point2D::new(x, y); let point = &Point2D::new(x, y);
let window = window_from_node(self); 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() { if self.browsing_context().is_none() {
return None; return None;
@ -3658,7 +3658,10 @@ impl DocumentMethods for Document {
let y = *y as f32; let y = *y as f32;
let point = &Point2D::new(x, y); let point = &Point2D::new(x, y);
let window = window_from_node(self); 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() { if self.browsing_context().is_none() {
return vec!(); return vec!();

View file

@ -1,4 +1,7 @@
[elementsFromPoint.html] [elementsFromPoint.html]
type: testharness type: testharness
expected: CRASH [SVG element at x,y]
expected: FAIL
[transformed element at x,y]
expected: FAIL

View file

@ -1,5 +1,6 @@
[matchMedia.xht] [matchMedia.xht]
type: testharness type: testharness
expected: TIMEOUT
[window.matchMedia exists] [window.matchMedia exists]
expected: FAIL expected: FAIL
[MediaQueryList.matches for "(max-width: 199px), all and (min-width: 200px)"] [MediaQueryList.matches for "(max-width: 199px), all and (min-width: 200px)"]
@ -11,5 +12,9 @@
[MediaQueryList.matches for "(min-width: 150px)"] [MediaQueryList.matches for "(min-width: 150px)"]
expected: FAIL expected: FAIL
[Resize iframe from 200x100 to 200x50, then to 100x50] [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