open-features-non-integer-screenx.html (2973B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>HTML: window.open `features`: non-integer values for legacy feature `screenx`</title> 4 <meta name=timeout content=long> 5 <link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name"> 6 7 <!-- user agents are not required to support open features other than `noopener` 8 and on some platforms position and size features don't make sense --> 9 <meta name="flags" content="may" /> 10 11 <script src="/resources/testharness.js"></script> 12 <script src="/resources/testharnessreport.js"></script> 13 <script src="/common/PrefixedPostMessage.js"></script> 14 <script> 15 var featuresPrefix = `width=401,height=204,top=0,`; 16 var windowURL = 'resources/message-opener.html'; 17 18 // https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-integers 19 20 setup (() => { 21 // Before running tests, open a window using features that mimic 22 // what would happen if the feature tested here were set to 0 23 // for comparison later. 24 var featureString = `${featuresPrefix}left=0`; 25 var prefixedMessage = new PrefixedMessageTest(); 26 prefixedMessage.onMessage((data, e) => { 27 e.source.close(); 28 runWindowTests(data); 29 }); 30 var win = window.open(prefixedMessage.url(windowURL), '', featureString); 31 }); 32 33 function runWindowTests (baselineDimensions) { 34 // When code point in first position is not an ASCII digit, "+" or "-", 35 // that's an error and the value becomes 0 36 [ 'screenx=/104', 37 'screenx=_104', 38 'screenx=L104' 39 ].forEach(feature => { 40 async_test(t => { 41 var prefixedMessage = new PrefixedMessageTest(); 42 var featureString = `${featuresPrefix}${feature}`; 43 prefixedMessage.onMessage(t.step_func_done((data, e) => { 44 e.source.close(); 45 assert_equals(data.left, baselineDimensions.left, `"${feature} begins with an invalid character and should be ignored"`); 46 })); 47 var win = window.open(prefixedMessage.url(windowURL) + '&expected_screenX=' + baselineDimensions.left, '', featureString); 48 }, `features "${feature}" should NOT set "screenx=104"`); 49 }); 50 51 // Codepoints that are valid ASCII digits should be collected 52 // Non-ASCII digits and subsequent code points are ignored 53 [ 'screenx=105.5', 54 'screenx=105.32', 55 'screenx=105LLl', 56 'screenx=105^4', 57 'screenx=105*3', 58 'screenx=105/5', 59 'screenx=105 ', 60 'screenx=105e1', 61 'screenx=105e-1' 62 ].forEach(feature => { 63 async_test(t => { 64 var prefixedMessage = new PrefixedMessageTest(); 65 var featureString = `${featuresPrefix}${feature}`; 66 prefixedMessage.onMessage(t.step_func_done((data, e) => { 67 e.source.close(); 68 assert_equals(data.left, 105, `"${featureString} value after first non-digit will be ignored"`); 69 })); 70 var win = window.open(prefixedMessage.url(windowURL) + '&expected_screenX=105', '', featureString); 71 }, `features "${feature}" should set "screenx=105"`); 72 }); 73 } 74 75 </script>