• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2015 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Flags: --strong-mode
6
7function getGlobal() {
8  return this;
9}
10
11function polluteGlobal() {
12  bar = 0;
13}
14
15(function() {
16  "use strict";
17
18  let builtins = [
19    Array,
20    Object,
21    Function,
22    getGlobal()
23  ];
24
25  for (let builtin of builtins) {
26    assertThrows(function(){"use strong"; builtin.foo}, TypeError);
27    assertThrows(function(){"use strong"; builtin[0]}, TypeError);
28    assertThrows(function(){"use strong"; builtin[10000]}, TypeError);
29    builtin.foo = 1;
30    assertDoesNotThrow(function(){"use strong"; builtin.foo});
31    assertThrows(function(){"use strong"; builtin.bar});
32    assertThrows(function(){"use strong"; builtin[0]}, TypeError);
33    assertThrows(function(){"use strong"; builtin[10000]}, TypeError);
34    builtin[0] = 1;
35    assertDoesNotThrow(function(){"use strong"; builtin.foo});
36    assertThrows(function(){"use strong"; builtin.bar});
37    assertDoesNotThrow(function(){"use strong"; builtin[0]});
38    assertThrows(function(){"use strong"; builtin[10000]}, TypeError);
39  }
40  polluteGlobal();
41  assertDoesNotThrow(function(){"use strong"; getGlobal().bar});
42})();
43