| 1 |
// Copyright 2012 Mozilla Corporation. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
es5id: 12.1.1_1 |
| 6 |
description: > |
| 7 |
Tests that the this-value is ignored in DateTimeFormat, if the this-value |
| 8 |
isn't a DateTimeFormat instance. |
| 9 |
author: Norbert Lindenberg |
| 10 |
includes: [testIntl.js] |
| 11 |
---*/ |
| 12 |
|
| 13 |
testWithIntlConstructors(function (Constructor) { |
| 14 |
if (Constructor === Intl.DateTimeFormat) |
| 15 |
return; |
| 16 |
|
| 17 |
var obj, newObj; |
| 18 |
|
| 19 |
// variant 1: use constructor in a "new" expression |
| 20 |
obj = new Constructor(); |
| 21 |
newObj = Intl.DateTimeFormat.call(obj); |
| 22 |
assert.notSameValue(obj, newObj, "DateTimeFormat object created with \"new\" was not ignored as this-value."); |
| 23 |
|
| 24 |
// variant 2: use constructor as a function |
| 25 |
if (Constructor !== Intl.Collator && |
| 26 |
Constructor !== Intl.NumberFormat && |
| 27 |
Constructor !== Intl.DateTimeFormat) |
| 28 |
{ |
| 29 |
// Newer Intl constructors are not callable as a function. |
| 30 |
return; |
| 31 |
} |
| 32 |
obj = Constructor(); |
| 33 |
newObj = Intl.DateTimeFormat.call(obj); |
| 34 |
assert.notSameValue(obj, newObj, "DateTimeFormat object created with constructor as function was not ignored as this-value."); |
| 35 |
}); |