diff --git a/test/language/templates/tagged/template-object-frozen-non-strict.js b/test/language/templates/tagged/template-object-frozen-non-strict.js new file mode 100644 index 0000000000..3b489f2938 --- /dev/null +++ b/test/language/templates/tagged/template-object-frozen-non-strict.js @@ -0,0 +1,31 @@ +// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 12.3.7 +description: > + The first argument to a tagged template should be frozen and define a `raw` + property that is also frozen. +flags: [noStrict] +---*/ + +var templateObject = null; +var threwError = false; +(function(parameter) { + templateObject = parameter; +})``; + +assert(templateObject !== null); +templateObject.test262Prop = true; + +assert.sameValue( + templateObject.test262Prop, undefined, 'The template object is frozen' +); + +templateObject.raw.test262Prop = true; + +assert.sameValue( + templateObject.raw.test262Prop, undefined, 'The "raw" object is frozen' +); +assert( + templateObject.raw !== undefined , 'Template object defines a `raw` property' +); diff --git a/test/language/templates/tagged/template-object-frozen-strict.js b/test/language/templates/tagged/template-object-frozen-strict.js new file mode 100644 index 0000000000..2f5cb7b309 --- /dev/null +++ b/test/language/templates/tagged/template-object-frozen-strict.js @@ -0,0 +1,29 @@ +// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 12.3.7 +description: > + The first argument to a tagged template should be frozen and define a `raw` + property that is also frozen. +flags: [onlyStrict] +---*/ + +var templateObject = null; +var threwError = false; +(function(parameter) { + templateObject = parameter; +})``; + +assert(templateObject !== null); + +assert.throws(TypeError, function() { + templateObject.test262Prop = true; +}); + +assert( + templateObject.raw !== undefined , 'Template object defines a `raw` property' +); + +assert.throws(TypeError, function() { + templateObject.raw.test262Prop = true; +}); diff --git a/test/language/templates/tagged/template-object.js b/test/language/templates/tagged/template-object.js index bf1bd30a58..15f5b092d2 100644 --- a/test/language/templates/tagged/template-object.js +++ b/test/language/templates/tagged/template-object.js @@ -13,10 +13,6 @@ var templateObject; templateObject = parameter; })`${1}`; -templateObject.test262Prop = true; -assert.sameValue( - templateObject.test262Prop, undefined, 'The template object is frozen' -); assert(Array.isArray(templateObject.raw), 'The template object is an array'); assert(templateObject.hasOwnProperty('raw')); @@ -24,10 +20,6 @@ verifyNotEnumerable(templateObject, 'raw'); verifyNotWritable(templateObject, 'raw') verifyNotConfigurable(templateObject, 'raw'); -templateObject.raw.test262Prop = true; -assert.sameValue( - templateObject.raw.test262Prop, undefined, 'The "raw" object is frozen' -); assert(Array.isArray(templateObject), 'The "raw" object is an array'); verifyEnumerable(templateObject, '0');