v8/test/mjsunit/web-snapshot/web-snapshot-builtin.js
Marja Hölttä 7b49edbc39 [web snapshot] Test cleanup + remove assertEquals misuse
Some assertEquals:s should've been assertSame.

Drive-by: Coding style fixes
Drive-by: Fix the parameter order of assertEquals, it should be
(expected, found).

Bug: v8:11525
Change-Id: I4e6db32329cbbe455853d19c20abe9d251263505
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3877148
Auto-Submit: Marja Hölttä <marja@chromium.org>
Reviewed-by: Matthias Liedtke <mliedtke@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Commit-Queue: Matthias Liedtke <mliedtke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83024}
2022-09-07 12:00:45 +00:00

40 lines
1.3 KiB
JavaScript

// Copyright 2022 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: --experimental-d8-web-snapshot-api --allow-natives-syntax --verify-heap
'use strict';
d8.file.execute('test/mjsunit/web-snapshot/web-snapshot-helpers.js');
(function TestBuiltin() {
function createObjects() {
globalThis.obj1 = {'a': Error};
globalThis.obj2 = {'b': Error.prototype};
}
const realm = Realm.create();
const {obj1, obj2} = takeAndUseWebSnapshot(
createObjects, ['obj1', 'obj2'], realm);
assertSame(Realm.eval(realm, 'Error'), obj1.a);
assertSame(Realm.eval(realm, 'Error.prototype'), obj2.b);
})();
(function TestInheritFromBuiltin() {
function createObjects() {
function inherit(subclass, superclass) {
function middle() {}
middle.prototype = superclass.prototype;
subclass.prototype = new middle();
subclass.prototype.constructor = subclass;
};
function MyError() {}
inherit(MyError, Error);
globalThis.MyError = MyError;
}
const realm = Realm.create();
const {MyError} = takeAndUseWebSnapshot(createObjects, ['MyError'], realm);
const obj = new MyError();
assertSame(Realm.eval(realm, 'Error.prototype'), obj.__proto__.__proto__);
})();