summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/history/the-location-interface/location-prototype-no-toString-valueOf.html
blob: 56316320af59dd1531c661fb854643736cf3ef6e (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
55
<!DOCTYPE html>
<meta charset="utf-8">
<title>Location.prototype objects don't have own "toString" and "valueOf" properties</title>

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<script>
"use strict";

test(t => {
  assert_not_own_property(Location.prototype, "toString");
  t.add_cleanup(() => { delete Location.prototype.toString; });

  let val;
  Object.defineProperty(Location.prototype, "toString", {
    get: () => val,
    set: newVal => { val = newVal; },
    enumerable: false,
    configurable: true,
  });

  Location.prototype.toString = 2;
  assert_equals(Location.prototype.toString, 2);
}, "'toString' accessor property is defined");

test(t => {
  assert_not_own_property(Location.prototype, "toString");
  t.add_cleanup(() => { delete Location.prototype.toString; });

  Location.prototype.toString = 4;
  assert_equals(Location.prototype.toString, 4);
}, "'toString' data property is created via [[Set]]");

test(t => {
  assert_not_own_property(Location.prototype, "valueOf");
  t.add_cleanup(() => { delete Location.prototype.valueOf; });

  Object.defineProperty(Location.prototype, "valueOf", {
    get: () => 6,
    enumerable: true,
    configurable: true,
  });

  assert_equals(Location.prototype.valueOf, 6);
}, "'valueOf' accessor property is defined");

test(t => {
  assert_not_own_property(Location.prototype, "valueOf");
  t.add_cleanup(() => { delete Location.prototype.valueOf; });

  Location.prototype.valueOf = 8;
  assert_equals(Object.getOwnPropertyDescriptor(Location.prototype, "valueOf").value, 8);
}, "'valueOf' data property is created via [[Set]]");
</script>