blob: 6ca6f94cef78429da53ddea7c7032b7109239c72 (
plain)
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
|
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.2.3.6-4-622
description: ES5 Attributes - all attributes in Date.now are correct
includes: [runTestCase.js]
---*/
function testcase() {
var desc = Object.getOwnPropertyDescriptor(Date, "now");
var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true);
var temp = Date.now;
try {
Date.now = "2010";
var isWritable = (Date.now === "2010");
var isEnumerable = false;
for (var prop in Date) {
if (prop === "now") {
isEnumerable = true;
}
}
delete Date.now;
var isConfigurable = !Date.hasOwnProperty("now");
return propertyAreCorrect && isWritable && !isEnumerable && isConfigurable;
} finally {
Object.defineProperty(Date, "now", {
value: temp,
writable: true,
enumerable: false,
configurable: true
});
}
}
runTestCase(testcase);
|