Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit 1a0bcbf

Browse files
ExE-Bossbenjamn
authored andcommitted
runtime: test that Symbol.toStringTag not set when already defined
@ExE-Boss I (@benjamn) modified your runtime changes from #399 in favor of
1 parent 6ed7bc2 commit 1a0bcbf

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

Diff for: test/non-writable-tostringtag-property.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright (c) 2014-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
var hasOwn = Object.prototype.hasOwnProperty;
9+
var getProto = Object.getPrototypeOf;
10+
var NativeIteratorPrototype =
11+
typeof Symbol === "function" &&
12+
typeof Symbol.iterator === "symbol" &&
13+
typeof [][Symbol.iterator] === "function" &&
14+
getProto &&
15+
getProto(getProto([][Symbol.iterator]()));
16+
17+
// https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype-@@tostringtag
18+
Object.defineProperty(NativeIteratorPrototype, Symbol.toStringTag, {
19+
configurable: true,
20+
value: "Iterator",
21+
});
22+
23+
describe("Symbol.toStringTag safety (#399, #400)", function () {
24+
it("regenerator-runtime doesn't fail to initialize when native iterator prototype has a non-writable @@toStringTag property", function() {
25+
require("./runtime.js");
26+
});
27+
});

Diff for: test/run.js

+8
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ if (semver.gte(process.version, "4.0.0")) {
133133
]);
134134
}
135135

136+
if (semver.gte(process.version, "4.0.0")) {
137+
enqueue("mocha", [
138+
"--harmony",
139+
"--reporter", "spec",
140+
"./test/non-writable-tostringtag-property.js",
141+
]);
142+
}
143+
136144
enqueue(convert, [
137145
"./test/tests.es6.js",
138146
"./test/tests.es5.js"

0 commit comments

Comments
 (0)