cross-compartment.js (1114B)
1 // |reftest| skip-if(!this.hasOwnProperty('Intl')||!Intl.hasOwnProperty("DurationFormat")) 2 3 var g = newGlobal(); 4 5 var locale = "en"; 6 var duration = {years: 123}; 7 8 var durationFormat = new Intl.DurationFormat(locale); 9 var ccwDurationFormat = new g.Intl.DurationFormat(locale); 10 11 // Intl.DurationFormat.prototype.format 12 { 13 var fn = Intl.DurationFormat.prototype.format; 14 15 var expectedValue = fn.call(durationFormat, duration); 16 var actualValue = fn.call(ccwDurationFormat, duration); 17 18 assertEq(actualValue, expectedValue); 19 } 20 21 // Intl.DurationFormat.prototype.formatToParts 22 { 23 var fn = Intl.DurationFormat.prototype.formatToParts; 24 25 var expectedValue = fn.call(durationFormat, duration); 26 var actualValue = fn.call(ccwDurationFormat, duration); 27 28 assertDeepEq(actualValue, expectedValue); 29 } 30 31 // Intl.DurationFormat.prototype.resolvedOptions 32 { 33 var fn = Intl.DurationFormat.prototype.resolvedOptions; 34 35 var expectedValue = fn.call(durationFormat); 36 var actualValue = fn.call(ccwDurationFormat); 37 38 assertDeepEq(actualValue, expectedValue); 39 } 40 41 if (typeof reportCompare === "function") 42 reportCompare(0, 0);