mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
fix: inspecting prototypes of built-ins with custom inspect implementations should not throw (#11308)
This commit is contained in:
parent
5e092b19fe
commit
5fa58c9216
14 changed files with 325 additions and 123 deletions
|
@ -2,6 +2,7 @@
|
|||
import {
|
||||
assert,
|
||||
assertEquals,
|
||||
assertStringIncludes,
|
||||
assertThrows,
|
||||
deferred,
|
||||
unitTest,
|
||||
|
@ -81,6 +82,32 @@ unitTest(function performanceMeasure() {
|
|||
});
|
||||
});
|
||||
|
||||
unitTest(function performanceCustomInspectFunction(): void {
|
||||
assertStringIncludes(Deno.inspect(performance), "Performance");
|
||||
assertStringIncludes(
|
||||
Deno.inspect(Performance.prototype),
|
||||
"Performance",
|
||||
);
|
||||
});
|
||||
|
||||
unitTest(function performanceMarkCustomInspectFunction(): void {
|
||||
const mark1 = performance.mark("mark1");
|
||||
assertStringIncludes(Deno.inspect(mark1), "PerformanceMark");
|
||||
assertStringIncludes(
|
||||
Deno.inspect(PerformanceMark.prototype),
|
||||
"PerformanceMark",
|
||||
);
|
||||
});
|
||||
|
||||
unitTest(function performanceMeasureCustomInspectFunction(): void {
|
||||
const measure1 = performance.measure("measure1");
|
||||
assertStringIncludes(Deno.inspect(measure1), "PerformanceMeasure");
|
||||
assertStringIncludes(
|
||||
Deno.inspect(PerformanceMeasure.prototype),
|
||||
"PerformanceMeasure",
|
||||
);
|
||||
});
|
||||
|
||||
unitTest(function performanceIllegalConstructor() {
|
||||
assertThrows(() => new Performance(), TypeError, "Illegal constructor");
|
||||
assertEquals(Performance.length, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue