| Index: ios/web/web_state/js/resources/common.js
|
| diff --git a/ios/web/web_state/js/resources/common.js b/ios/web/web_state/js/resources/common.js
|
| index 56adb250ff7019be9cc1ec763fcc2b014c187381..81d0df149cdc2ed5a7975d4af07266ea093a312d 100644
|
| --- a/ios/web/web_state/js/resources/common.js
|
| +++ b/ios/web/web_state/js/resources/common.js
|
| @@ -26,6 +26,7 @@ __gCrWeb['common'] = __gCrWeb.common;
|
|
|
| /* Beginning of anonymous object. */
|
| (function() {
|
| +
|
| /**
|
| * JSON safe object to protect against custom implementation of Object.toJSON
|
| * in host pages.
|
| @@ -46,6 +47,31 @@ __gCrWeb['common'] = __gCrWeb.common;
|
| __gCrWeb.common.JSONStringify = JSON.stringify;
|
|
|
| /**
|
| + * Returns a string that is formatted according to the JSON syntax rules.
|
| + * This is equivalent to the built-in JSON.stringify() function, but is
|
| + * less likely to be overridden by the website itself. Prefer the private
|
| + * {@code __gcrWeb.common.JSONStringify} whenever possible instead of using
|
| + * this public function. The |__gCrWeb| object itself does not use it; it uses
|
| + * its private counterpart instead.
|
| + */
|
| + __gCrWeb['stringify'] = function(value) {
|
| + if (value === null)
|
| + return 'null';
|
| + if (value === undefined)
|
| + return 'undefined';
|
| + if (typeof(value.toJSON) == 'function') {
|
| + // Prevents websites from changing stringify's behavior by adding the
|
| + // method toJSON() by temporarily removing it.
|
| + var originalToJSON = value.toJSON;
|
| + value.toJSON = undefined;
|
| + var stringifiedValue = __gCrWeb.common.JSONStringify(value);
|
| + value.toJSON = originalToJSON;
|
| + return stringifiedValue;
|
| + }
|
| + return __gCrWeb.common.JSONStringify(value);
|
| + };
|
| +
|
| + /**
|
| * Prefix used in references to form elements that have no 'id' or 'name'
|
| */
|
| __gCrWeb.common.kNamelessFormIDPrefix = 'gChrome~';
|
| @@ -689,4 +715,5 @@ __gCrWeb['common'] = __gCrWeb.common;
|
| }
|
| return false;
|
| };
|
| +
|
| }()); // End of anonymous object
|
|
|