resizeTo-negative.html (1426B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com"> 4 <link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-window-resizeto"> 5 <link rel="help" href="https://github.com/servo/servo/pull/39204"> 6 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/common/rendering-utils.js"></script> 10 <script> 11 "use strict"; 12 promise_test(async t => { 13 const w = window.open("/css/reference/blank.html", "", "width=600,height=450"); 14 assert_not_equals(w, null, "Popup isn't null"); 15 t.add_cleanup(() => w.close()); 16 17 // Try as early as possible, when probably we only have about:blank. 18 w.resizeTo(-1, -1); 19 20 // Try again after load, some browser might ignore the former one. 21 if (w.location.href === "about:blank" || w.document.readyState !== "complete") { 22 await new Promise(resolve => w.addEventListener("load", resolve, {once: true})); 23 w.resizeTo(-1, -1); 24 } 25 26 // Wait a bit, so that the resize can finish. Note that listening for a "resize" 27 // event would result in a timeout if no resize occurred. 28 await waitForAtLeastOneFrame(); 29 await waitForAtLeastOneFrame(); 30 31 assert_greater_than(w.outerWidth, 0, "Popup width is positive"); 32 assert_greater_than(w.outerHeight, 0, "Popup height is positive"); 33 }, "resizeTo(-1, -1) might shrink window size, but it stays positive"); 34 </script>