| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 goog.provide('cvox.ChromeVoxJSON'); | 5 goog.provide('cvox.ChromeVoxJSON'); |
| 6 | 6 |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * @fileoverview A simple wrapper around the JSON APIs. | 9 * @fileoverview A simple wrapper around the JSON APIs. |
| 10 * If it is possible to use the browser's built in native JSON, then | 10 * If it is possible to use the browser's built in native JSON, then |
| 11 * cvox.ChromeVoxJSON is the same as JSON. | 11 * cvox.ChromeVoxJSON is the same as JSON. |
| 12 * If the page has its own version of JSON, cvox.ChromeVoxJSON will use its | 12 * If the page has its own version of JSON, cvox.ChromeVoxJSON will use its |
| 13 * own implementation (rather than the version of JSON on the page | 13 * own implementation (rather than the version of JSON on the page |
| 14 * which may be outdated/broken). | 14 * which may be outdated/broken). |
| 15 */ | 15 */ |
| 16 | 16 |
| 17 if (!cvox.ChromeVoxJSON) { | 17 if (!cvox.ChromeVoxJSON) { |
| 18 /** | 18 /** Placeholder object. */ |
| 19 * @type {Object} | |
| 20 */ | |
| 21 cvox.ChromeVoxJSON = {}; | 19 cvox.ChromeVoxJSON = {}; |
| 22 } | 20 } |
| 23 | 21 |
| 24 if (window.JSON && window.JSON.toString() == '[object JSON]') { | 22 if (window.JSON && window.JSON.toString() == '[object JSON]') { |
| 25 cvox.ChromeVoxJSON = window.JSON; | 23 cvox.ChromeVoxJSON = window.JSON; |
| 26 } else { | 24 } else { |
| 27 /* | 25 /* |
| 28 * JSON implementation renamed to cvox.ChromeVoxJSON. | 26 * JSON implementation renamed to cvox.ChromeVoxJSON. |
| 29 * This only gets called if the page has its own version of JSON. | 27 * This only gets called if the page has its own version of JSON. |
| 30 * | 28 * |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 return typeof reviver === 'function' ? walk({'': j}, '') : j; | 359 return typeof reviver === 'function' ? walk({'': j}, '') : j; |
| 362 } | 360 } |
| 363 | 361 |
| 364 // If the text is not JSON parseable, then a SyntaxError is thrown. | 362 // If the text is not JSON parseable, then a SyntaxError is thrown. |
| 365 | 363 |
| 366 throw new SyntaxError('JSON.parse'); | 364 throw new SyntaxError('JSON.parse'); |
| 367 }; | 365 }; |
| 368 } | 366 } |
| 369 }()); | 367 }()); |
| 370 } | 368 } |
| OLD | NEW |