regress-5902.js 1.41 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --allow-natives-syntax

var log = [];

function check(predicate, item) {
  if (!predicate) log.push(item);
}

var global = this;

Object.getOwnPropertyNames(global).forEach(function(name) {
  // Only check for global properties with uppercase names.
  if (name[0] != name[0].toUpperCase()) return;

  var obj = global[name];

  // Skip non-receivers.
22
  if (!%IsJSReceiver(obj)) return;
23 24 25 26 27 28 29 30 31 32 33

  // Skip non-natives.
  if (!obj.toString().includes('native')) return;

  // Construct an instance.
  try {
    new obj();
  } catch (e) {
  }

  // Check the object.
34
  check(%HasFastProperties(obj), `${name}`);
35 36 37

  // Check the constructor.
  var constructor = obj.constructor;
38 39
  if (!%IsJSReceiver(constructor)) return;
  check(%HasFastProperties(constructor), `${name}.constructor`);
40 41 42

  // Check the prototype.
  var prototype = obj.prototype;
43 44
  if (!%IsJSReceiver(prototype)) return;
  check(%HasFastProperties(prototype), `${name}.prototype`);
45 46 47

  // Check the prototype.constructor.
  var prototype_constructor = prototype.constructor;
48
  if (!%IsJSReceiver(prototype_constructor)) return;
49
  check(
50
      %HasFastProperties(prototype_constructor),
51 52 53
      `${name}.prototype.constructor`);
});

54 55
// There should be no dictionary mode builtin objects.
assertEquals([], log);