1bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// Copyright 2013 the V8 project authors. All rights reserved.
2bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// Redistribution and use in source and binary forms, with or without
3bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// modification, are permitted provided that the following conditions are
4bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// met:
5bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//
6bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//     * Redistributions of source code must retain the above copyright
7bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//       notice, this list of conditions and the following disclaimer.
8bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//     * Redistributions in binary form must reproduce the above
9bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//       copyright notice, this list of conditions and the following
10bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//       disclaimer in the documentation and/or other materials provided
11bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//       with the distribution.
12bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//     * Neither the name of Google Inc. nor the names of its
13bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//       contributors may be used to endorse or promote products derived
14bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//       from this software without specific prior written permission.
15bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org//
16bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org
28bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// Internal object we got from native code should not be writable,
29bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// configurable or enumerable. One can still change its public properties, but
30bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// we don't use them to do actual work.
31bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org
32bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.orgvar collator = new Intl.Collator([]);
33bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org
34bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// Direct write should fail.
35bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.orgcollator.collator = {'zzz':'some random object'};
36bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org
37bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.orgassertFalse(collator.collator.hasOwnProperty('zzz'));
38bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org
39bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// Try redefining the property.
40bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.orgvar didThrow = false;
41bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.orgtry {
42bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org  Object.defineProperty(collator, 'collator', {value: undefined});
43bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org} catch(e) {
44bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org  didThrow = true;
45bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org}
46bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.orgassertTrue(didThrow);
47bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org
48bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.org// Try deleting the property.
49bee51999422c0eeaae85ed99b5c0bd4126510ff1danno@chromium.orgassertFalse(delete collator.collator);
50