File: open-features-non-integer-screenx.html

package info (click to toggle)
firefox-esr 68.10.0esr-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,143,932 kB
  • sloc: cpp: 5,227,879; javascript: 4,315,531; ansic: 2,467,042; python: 794,975; java: 349,993; asm: 232,034; xml: 228,320; sh: 82,008; lisp: 41,202; makefile: 22,347; perl: 15,555; objc: 5,277; cs: 4,725; yacc: 1,778; ada: 1,681; pascal: 1,673; lex: 1,417; exp: 527; php: 436; ruby: 225; awk: 162; sed: 53; csh: 44
file content (75 lines) | stat: -rw-r--r-- 2,892 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML: window.open `features`: non-integer values for legacy feature `screenx`</title>
<meta name=timeout content=long>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">

<!-- user agents are not required to support open features other than `noopener`
     and on some platforms position and size features don't make sense -->
<meta name="flags" content="may" />

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/PrefixedPostMessage.js"></script>
<script>
var featuresPrefix = `width=401,height=204,top=0,`;
var windowURL = 'resources/message-opener.html';

// https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-integers

setup (() => {
  // Before running tests, open a window using features that mimic
  // what would happen if the feature tested here were set to 0
  // for comparison later.
  var featureString = `${featuresPrefix}left=0`;
  var prefixedMessage = new PrefixedMessageTest();
  prefixedMessage.onMessage((data, e) => {
    e.source.close();
    runWindowTests(data);
  });
  var win = window.open(prefixedMessage.url(windowURL), '', featureString);
});

function runWindowTests (baselineDimensions) {
  // When code point in first position is not an ASCII digit, "+" or "-",
  // that's an error and the value becomes 0
  [ 'screenx=/104',
    'screenx=_104',
    'screenx=L104'
  ].forEach(feature => {
    async_test(t => {
      var prefixedMessage = new PrefixedMessageTest();
      var featureString = `${featuresPrefix}${feature}`;
      prefixedMessage.onMessage(t.step_func_done((data, e) => {
        e.source.close();
        assert_equals(data.left, baselineDimensions.left, `"${feature} begins with an invalid character and should be ignored"`);
      }));
      var win = window.open(prefixedMessage.url(windowURL), '', featureString);
    }, `features "${feature}" should NOT set "left=104"`);
  });

  // Codepoints that are valid ASCII digits should be collected
  // Non-ASCII digits and subsequent code points are ignored
  [ 'screenx=105.5',
    'screenx=105.32',
    'screenx=105LLl',
    'screenx=105^4',
    'screenx=105*3',
    'screenx=105/5',
    'screenx=105  ',
    'screenx=105e1',
    'screenx=105e-1'
  ].forEach(feature => {
    async_test(t => {
      var prefixedMessage = new PrefixedMessageTest();
      var featureString = `${featuresPrefix}${feature}`;
      prefixedMessage.onMessage(t.step_func_done((data, e) => {
        e.source.close();
        assert_equals(data.left, 105, `"${featureString} value after first non-digit will be ignored"`);
      }));
      var win = window.open(prefixedMessage.url(windowURL), '', featureString);
    }, `features "${feature}" should set "left=105"`);
  });
}

</script>