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
94 lines (78 loc) · 3.1 KB

File metadata and controls

94 lines (78 loc) · 3.1 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
function write(value) {
WScript.Echo(value);
}
function RunTest(testCase, testCount) {
var testFunction = testCase[0];
var testScenario = testCase[1];
testScenario = " (test " + testCount + "): " + testScenario;
write(testScenario);
try {
var result = testFunction();
if (result == true) {
write("PASS");
}
} catch (e) {
var resultString = "FAILED" + testScenario;
write(resultString + " :: " + e.message);
}
}
function RunAllTests(){
for(var i = 0; i < testList.length; ++i){
RunTest(testList[i], i + 1);
}
}
var testList = [
[Test1, "Object getOwnPropertyDescriptor throws TypeError when the first parameter is either null or undefined"],
[Test2, "Freezing an object with deleted properties"],
[Test3, "Object getOwnPropertyDescriptor works fine when the first parameter is a built-in type except null or undefined"],
];
// Utility functions
function Verify(expression, expectedValue, actualValue) {
if (expectedValue != actualValue) {
write("Failed: Expected " + expression + " = " + expectedValue + ", got " + actualValue);
return false;
}
write("Success: Expected " + expression + " = " + expectedValue + ", got " + actualValue);
return true;
}
//Tests
// Object getOwnPropertyDescriptor throws TypeError when parameter is not Object. ES5 spec 15.2.3.3.
function Test1() {
var exception;
exception = null;
try {
eval("Object.getOwnPropertyDescriptor(null, 'foo', {})");
} catch (ex) {
exception = ex;
}
if(!Verify("Object getOwnPropertyDescriptor throws TypeError when 1st parameter is null", true, exception instanceof TypeError)) return false;
exception = null;
try {
eval("Object.getOwnPropertyDescriptor(undefined, 'foo', {})");
} catch (ex) {
exception = ex;
}
if(!Verify("Object getOwnPropertyDescriptor throws TypeError when 1st parameter is undefined", true, exception instanceof TypeError)) return false;
return true;
}
// BLUE:227417: Freezing an object with deleted properties
function Test2()
{
var x = {};
x.c = 1;
delete x.c;
Object.freeze(x);
return true;
}
function Test3()
{
if (!Verify("Object getOwnPropertyDescriptor does not throw when 1st parameter is boolean", undefined, Object.getOwnPropertyDescriptor(true, 'foo'))) return false;
if (!Verify("Object getOwnPropertyDescriptor does not throw when 1st parameter is number", undefined, Object.getOwnPropertyDescriptor(123, 'foo'))) return false;
if (!Verify("Object getOwnPropertyDescriptor works fine when 1st parameter is string", 3, Object.getOwnPropertyDescriptor('foo', 'length').value)) return false;
return true;
}
RunAllTests();
Morty Proxy This is a proxified and sanitized view of the page, visit original site.