tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

invalid-JSON-text.js (932B)


      1 // Copyright (C) 2023 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-json.rawjson
      6 description: >
      7  Inputs not convertible to string, or convertible to invalid JSON string
      8 info: |
      9  JSON.rawJSON ( text )
     10 
     11  1. Let jsonString be ? ToString(text).
     12  ...
     13  3. Parse StringToCodePoints(jsonString) as a JSON text as specified in
     14     ECMA-404. Throw a SyntaxError exception if it is not a valid JSON text as
     15     defined in that specification, or if its outermost value is an object or
     16     array as defined in that specification.
     17 
     18 features: [json-parse-with-source]
     19 ---*/
     20 
     21 assert.throws(TypeError, () => {
     22  JSON.rawJSON(Symbol('123'));
     23 });
     24 
     25 assert.throws(SyntaxError, () => {
     26  JSON.rawJSON(undefined);
     27 });
     28 
     29 assert.throws(SyntaxError, () => {
     30  JSON.rawJSON({});
     31 });
     32 
     33 assert.throws(SyntaxError, () => {
     34  JSON.rawJSON([]);
     35 });
     36 
     37 reportCompare(0, 0);