Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
62 lines (51 loc) · 1.88 KB

File metadata and controls

62 lines (51 loc) · 1.88 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
//
// Test throw an object with Error or Error.prototype in its prototype chain
//
function Dump(output) {
if (this.WScript) {
WScript.Echo(output);
} else {
alert(output);
}
}
function testErrorStack(throwObject, msg) {
Dump(msg);
try {
throw throwObject;
} catch (e) {
Dump(TrimStackTracePath(e.stack));
}
Dump("");
}
function testErrorPrototype(proto, msg) {
function E(msg) {
this.message = msg;
}
E.prototype = proto;
testErrorStack(new E(msg), msg);
}
function testErrorPrototypeChain(proto, msg) {
function P(){}
P.prototype = proto;
testErrorPrototype(proto, "Prototype is " + msg);
testErrorPrototype(new P(), "Prototype has " + msg);
}
function runtest() {
testErrorPrototypeChain(new Error(), "new Error()");
testErrorPrototypeChain(Error.prototype, "Error.prototype");
testErrorPrototypeChain(new RangeError(), "new RangeError()");
testErrorPrototypeChain(RangeError.prototype, "RangeError.prototype");
testErrorPrototypeChain(123, "123");
testErrorPrototypeChain(new String(), "new String()");
testErrorStack(Error.prototype, "throw Error.prototype");
testErrorStack(RangeError.prototype, "throw RangeError.prototype");
testErrorStack(TypeError.prototype, "throw TypeError.prototype");
}
if (this.WScript && this.WScript.LoadScriptFile) {
this.WScript.LoadScriptFile("../UnitTestFramework/TrimStackTracePath.js");
}
runtest();
Morty Proxy This is a proxified and sanitized view of the page, visit original site.