summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/non-parsable-url-getter-setter.window.js
blob: 587f9b9c46359b46740f1a9c22c40b8530d1b5b7 (plain)
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
[
  {
    "property": "origin",
    "set": null
  },
  {
    "property": "protocol",
    "get": ":",
    "set": "https"
  },
  {
    "property": "username"
  },
  {
    "property": "password"
  },
  {
    "property": "host"
  },
  {
    "property": "hostname"
  },
  {
    "property": "port",
    "set": "8000"
  },
  {
    "property": "pathname"
  },
  {
    "property": "search"
  },
  {
    "property": "hash"
  }
].forEach(({ property, get = "", set = "string" }) => {
  ["a", "area"].forEach(name => {
    test(() => {
      const link = document.createElement(name);
      link.href = "http://test:test/"; // non-parsable URL
      assert_equals(link[property], get);
    }, `<${name} href="http://test:test/">.${property} getter`);

    if (set !== null) {
      test(() => {
        const link = document.createElement(name);
        link.href = "http://test:test/"; // non-parsable URL
        link[property] = set;
        assert_equals(link[property], get);
        assert_equals(link.href, "http://test:test/");
      }, `<${name} href="http://test:test/">.${property} setter`);
    }
  });
});