tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

open-features-non-integer-screeny.html (2970B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>HTML: window.open `features`: non-integer values for legacy feature `screeny`</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 = `height=401,width=402,left=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}top=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  [ 'screeny=/404',
     37    'screeny=_404',
     38    'screeny=L404'
     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.top, baselineDimensions.top, `"${feature} begins with an invalid character and should be ignored"`);
     46      }));
     47      var win = window.open(prefixedMessage.url(windowURL) + '&expected_screenY=' + baselineDimensions.top, '', featureString);
     48    }, `features "${feature}" should NOT set "screeny=404"`);
     49  });
     50 
     51  // Codepoints that are valid ASCII digits should be collected
     52  // Non-ASCII digits and subsequent code points are ignored
     53  [ 'screeny=405.5',
     54    'screeny=405.32',
     55    'screeny=405LLl',
     56    'screeny=405^4',
     57    'screeny=405*3',
     58    'screeny=405/5',
     59    'screeny=405  ',
     60    'screeny=405e1',
     61    'screeny=405e-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.top, 405, `"${featureString} value after first non-digit will be ignored"`);
     69      }));
     70      var win = window.open(prefixedMessage.url(windowURL) + '&expected_screenY=405', '', featureString);
     71    }, `features "${feature}" should set "screeny=405"`);
     72  });
     73 
     74 }
     75 
     76 </script>