diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 932a9ec7f2d..e210476a5df 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -1389,7 +1389,17 @@ impl WindowMethods for Window { // https://drafts.csswg.org/cssom-view/#dom-window-resizeto fn ResizeTo(&self, width: i32, height: i32) { // Step 1 - //TODO determine if this operation is allowed + let window_proxy = match self.window_proxy.get() { + Some(proxy) => proxy, + None => return, + }; + + // If target is not an auxiliary browsing context that was created by a script + // (as opposed to by an action of the user), then return. + if !window_proxy.is_auxiliary() { + return; + } + let dpr = self.device_pixel_ratio(); let size = Size2D::new(width, height).to_f32() * dpr; self.send_to_embedder(EmbedderMsg::ResizeTo(self.webview_id(), size.to_i32())); diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index e1817a3dacc..d3a939eab57 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -52,6 +52,13 @@ null, {} ] + ], + "window_resizeTo_not_permitted-crash.html": [ + "7b6a67ff81436a91048bdb627f303f7fab2762f7", + [ + null, + {} + ] ] } }, @@ -14330,7 +14337,7 @@ ] ], "window_resizeTo.html": [ - "87d60498e80bcd01b5790feb3f9e104410cb6e1b", + "3f6c5a610d52b64bf4457d478b929e95d79e9ab8", [ null, {} diff --git a/tests/wpt/mozilla/tests/mozilla/window_resizeTo.html b/tests/wpt/mozilla/tests/mozilla/window_resizeTo.html index 87d60498e80..3f6c5a610d5 100644 --- a/tests/wpt/mozilla/tests/mozilla/window_resizeTo.html +++ b/tests/wpt/mozilla/tests/mozilla/window_resizeTo.html @@ -1,16 +1,21 @@ -Verify that the resize event is fired when the window is resized (particularly in headless mode) +Verify that the resize event is fired when the window is resized (in popup) diff --git a/tests/wpt/mozilla/tests/mozilla/window_resizeTo_not_permitted-crash.html b/tests/wpt/mozilla/tests/mozilla/window_resizeTo_not_permitted-crash.html new file mode 100644 index 00000000000..7b6a67ff814 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/window_resizeTo_not_permitted-crash.html @@ -0,0 +1,6 @@ + + +Test that calling resizeTo() on normal window does not crash +