Index: third_party/WebKit/LayoutTests/fast/dom/location-toprimitive.html |
diff --git a/third_party/WebKit/LayoutTests/fast/dom/location-toprimitive.html b/third_party/WebKit/LayoutTests/fast/dom/location-toprimitive.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a4f1c9826fab0f0d564d861855dc36de99b1cbbc |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/fast/dom/location-toprimitive.html |
@@ -0,0 +1,32 @@ |
+<!DOCTYPE html> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
+<script> |
+test(function() { |
+ // The property descriptor of location[Symbol.toPrimitive] must be |
+ // {configurable: false, enumerable: false, writable: false, |
+ // value: undefined}. |
+ assert_own_property(location, Symbol.toPrimitive, |
+ "location does not have Symbol.toPrimitive property."); |
+ var pd = Object.getOwnPropertyDescriptor(location, Symbol.toPrimitive); |
+ assert_false(pd.configurable, |
+ "location's Symbol.toPrimitive is configurable."); |
+ assert_false(pd.enumerable, "location's Symbol.toPrimitive is enumerable."); |
+ assert_false(pd.writable, "location's Symbol.toPrimitive is writable."); |
+ assert_true('value' in pd, |
+ "location's Symbol.toPrimitive is not a data property."); |
+ assert_equals(pd.value, undefined, |
+ "The value of location's Symbol.toPrimitive is not undefined."); |
+ |
+ // location's Symbol.toPrimitive supersedes Object.prototype's one. |
+ // https://crbug.com/680409 |
+ Object.prototype[Symbol.toPrimitive] = function() { return "hacked"; }; |
+ assert_equals(String({}), "hacked", |
+ "Object.prototype doesn't have a hacked Symbol.toPrimitive " + |
+ "property."); |
+ assert_not_equals(String(location), "hacked", |
+ "location's Symbol.toPrimitive gets hacked."); |
+}, "Location objects must have Symbol.toPrimitive property defined."); |
+ |
+done(); |
+</script> |