summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/js/builtins/Object.prototype.preventExtensions.html
blob: 36ac328d2e5273367d9449cff64015d578c35546 (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
<!doctype html>
<!--
Distributed under both the W3C Test Suite License [1] and the W3C
3-clause BSD License [2]. To contribute to a W3C Test Suite, see the
policies and contribution forms [3].

[1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license
[2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license
[3] http://www.w3.org/2004/10/27-testcases
-->
<html>
<head>
<meta charset="utf-8">
<title>Object.preventExtensions</title>
<link rel="author" title="Masaya Iseki" href="mailto:iseki.m.aa@gmail.com">
<link rel="help" href="https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.preventextensions">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
test(function() {
  [{}, []].forEach(function(that){
    assert_true(Object.isExtensible(that));
    that.prop = 'exist';

    Object.preventExtensions(that);
    assert_false(Object.isExtensible(that));
    assert_false(Object.isFrozen(that));
    assert_false(Object.isSealed(that));

    that.extension = 'This property should not be added';
    assert_equals(undefined, that.extension, 'Confirm to prevent adding property.');

    that.prop = 'changed';
    assert_equals('changed', that.prop,
          'Confirm to be able to change a property value.');

    delete that.prop;
    assert_equals(undefined, that.prop, 'Confirm to be able to delete a property.');
  });
});

test(function() {
  ['foo', 42, null, undefined].forEach(function(that) {
    assert_throws(new TypeError(),
        function() { Object.preventExtensions(that) });
  });
});
</script>

</body>
</html>