Changeset 260404 in webkit


Ignore:
Timestamp:
Apr 20, 2020 3:32:59 PM (4 years ago)
Author:
ysuzuki@apple.com
Message:

Add more structure-cloning tests for BigInt
https://bugs.webkit.org/show_bug.cgi?id=210765

Reviewed by Mark Lam.

Source/WebCore:

This patch adds safe-guard for future JSC primitive extension for structure-cloning.
We throw DataCloneError if we see unknown primitive value, which can happen if JSC
extends primitive value.

  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneSerializer::dumpImmediate):
(WebCore::CloneSerializer::dumpIfTerminal):

LayoutTests:

Add more tests for BigInt outside of WPT (they are already tested in WPT, but this adds more tests).

  • fast/dom/Window/window-postmessage-clone-expected.txt:
  • fast/dom/Window/window-postmessage-clone.html:
  • platform/gtk/fast/dom/Window/window-postmessage-clone-expected.txt:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r260403 r260404  
     12020-04-20  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        Add more structure-cloning tests for BigInt
     4        https://bugs.webkit.org/show_bug.cgi?id=210765
     5
     6        Reviewed by Mark Lam.
     7
     8        Add more tests for BigInt outside of WPT (they are already tested in WPT, but this adds more tests).
     9
     10        * fast/dom/Window/window-postmessage-clone-expected.txt:
     11        * fast/dom/Window/window-postmessage-clone.html:
     12        * platform/gtk/fast/dom/Window/window-postmessage-clone-expected.txt:
     13
    1142020-04-20  Simon Fraser  <simon.fraser@apple.com>
    215
  • trunk/LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt

    r219663 r260404  
    1414PASS: eventData is true of type boolean
    1515PASS: eventData is 1 of type string
     16PASS: eventData is 0 of type bigint
     17PASS: eventData is -20 of type bigint
     18PASS: eventData is 4294967295 of type bigint
     19PASS: eventData is -4294967295 of type bigint
     20PASS: eventData is 2147483647 of type bigint
     21PASS: eventData is 2147483648 of type bigint
     22PASS: eventData is -2147483648 of type bigint
     23PASS: eventData is -2147483649 of type bigint
     24PASS: eventData is 68719476735 of type bigint
     25PASS: eventData is -68719476735 of type bigint
     26PASS: eventData is 1000000000000000000000000000000000 of type bigint
     27PASS: eventData is -1000000000000000000000000000000000 of type bigint
     28PASS: eventData is 1461501637330902918203684832716283019655932542975 of type bigint
     29PASS: eventData is -1461501637330902918203684832716283019655932542975 of type bigint
     30PASS: eventData is 4722366482869645213695 of type bigint
     31PASS: eventData is -4722366482869645213695 of type bigint
    1632PASS: eventData is [object Object] of type object
    1733PASS: eventData is [object Object] of type object
     
    3450PASS: eventData is gnirts of type object
    3551PASS: eventData is 42 of type object
     52PASS: eventData is 0 of type object
     53PASS: eventData is -20 of type object
     54PASS: eventData is 4294967295 of type object
     55PASS: eventData is -4294967295 of type object
     56PASS: eventData is 2147483647 of type object
     57PASS: eventData is 2147483648 of type object
     58PASS: eventData is -2147483648 of type object
     59PASS: eventData is -2147483649 of type object
     60PASS: eventData is 68719476735 of type object
     61PASS: eventData is -68719476735 of type object
     62PASS: eventData is 1000000000000000000000000000000000 of type object
     63PASS: eventData is -1000000000000000000000000000000000 of type object
     64PASS: eventData is 1461501637330902918203684832716283019655932542975 of type object
     65PASS: eventData is -1461501637330902918203684832716283019655932542975 of type object
     66PASS: eventData is 4722366482869645213695 of type object
     67PASS: eventData is -4722366482869645213695 of type object
    3668PASS: eventData is === to eventData.self
    3769PASS: eventData is === to eventData[0]
     
    116148PASS: Number object properties not serialized
    117149PASS: Boolean object properties not serialized
     150PASS: BigInt object properties not serialized
     151PASS: BigInt (BigInt32) object properties not serialized
    118152PASS: Date values correct (0)
    119153PASS: Date values correct (1)
  • trunk/LayoutTests/fast/dom/Window/window-postmessage-clone.html

    r217466 r260404  
    1414tryPostMessage('true');
    1515tryPostMessage('"1"');
     16tryPostMessage('0n');
     17tryPostMessage('-20n');
     18tryPostMessage('4294967295n');
     19tryPostMessage('-4294967295n');
     20tryPostMessage('2147483647n');
     21tryPostMessage('2147483648n');
     22tryPostMessage('-2147483648n');
     23tryPostMessage('-2147483649n');
     24tryPostMessage('68719476735n');
     25tryPostMessage('-68719476735n');
     26tryPostMessage('1000000000000000000000000000000000n');
     27tryPostMessage('-1000000000000000000000000000000000n');
     28tryPostMessage('1461501637330902918203684832716283019655932542975n');
     29tryPostMessage('-1461501637330902918203684832716283019655932542975n');
     30tryPostMessage('4722366482869645213695n');
     31tryPostMessage('-4722366482869645213695n');
    1632tryPostMessage('({})');
    1733tryPostMessage('({a:1})');
     
    3652tryPostMessage('new String("gnirts")');
    3753tryPostMessage('new Number(42.0)');
     54tryPostMessage('Object(0n)');
     55tryPostMessage('Object(-20n)');
     56tryPostMessage('Object(4294967295n)');
     57tryPostMessage('Object(-4294967295n)');
     58tryPostMessage('Object(2147483647n)');
     59tryPostMessage('Object(2147483648n)');
     60tryPostMessage('Object(-2147483648n)');
     61tryPostMessage('Object(-2147483649n)');
     62tryPostMessage('Object(68719476735n)');
     63tryPostMessage('Object(-68719476735n)');
     64tryPostMessage('Object(1000000000000000000000000000000000n)');
     65tryPostMessage('Object(-1000000000000000000000000000000000n)');
     66tryPostMessage('Object(1461501637330902918203684832716283019655932542975n)');
     67tryPostMessage('Object(-1461501637330902918203684832716283019655932542975n)');
     68tryPostMessage('Object(4722366482869645213695n)');
     69tryPostMessage('Object(-4722366482869645213695n)');
    3870cyclicObject={};
    3971cyclicObject.self = cyclicObject;
     
    288320    });
    289321
    290 // Properties added to String, Boolean and Number objects should not be serialized.
     322// Properties added to String, Boolean, Number, and BigInt objects should not be serialized.
    291323tryPostMessage(thunk(
    292324        'var s = new String("gnirts"); ' +
    293325        'var n = new Number(42.0); ' +
    294326        'var b = new Boolean(true); ' +
    295         's.foo = 1; n.foo = 2; b.foo = 3; ' +
    296         'return [s, n, b];'
     327        'var i = Object(100000000000000000000n); ' +
     328        'var i32 = Object(10n); ' +
     329        's.foo = 1; n.foo = 2; b.foo = 3; i.foo = 4; i32.foo = 5; ' +
     330        'return [s, n, b, i, i32];'
    297331    ), false, "evalThunk", function(v) {
    298332        doPassFail(v[0].foo == undefined, "String object properties not serialized");
    299333        doPassFail(v[1].foo == undefined, "Number object properties not serialized");
    300334        doPassFail(v[2].foo == undefined, "Boolean object properties not serialized");
     335        doPassFail(v[3].foo == undefined, "BigInt object properties not serialized");
     336        doPassFail(v[4].foo == undefined, "BigInt (BigInt32) object properties not serialized");
    301337    });
    302338
  • trunk/LayoutTests/platform/gtk/fast/dom/Window/window-postmessage-clone-expected.txt

    r155037 r260404  
    1010PASS: eventData is true of type boolean
    1111PASS: eventData is 1 of type string
     12PASS: eventData is 0 of type bigint
     13PASS: eventData is -20 of type bigint
     14PASS: eventData is 4294967295 of type bigint
     15PASS: eventData is -4294967295 of type bigint
     16PASS: eventData is 2147483647 of type bigint
     17PASS: eventData is 2147483648 of type bigint
     18PASS: eventData is -2147483648 of type bigint
     19PASS: eventData is -2147483649 of type bigint
     20PASS: eventData is 68719476735 of type bigint
     21PASS: eventData is -68719476735 of type bigint
     22PASS: eventData is 1000000000000000000000000000000000 of type bigint
     23PASS: eventData is -1000000000000000000000000000000000 of type bigint
     24PASS: eventData is 1461501637330902918203684832716283019655932542975 of type bigint
     25PASS: eventData is -1461501637330902918203684832716283019655932542975 of type bigint
     26PASS: eventData is 4722366482869645213695 of type bigint
     27PASS: eventData is -4722366482869645213695 of type bigint
    1228PASS: eventData is [object Object] of type object
    1329PASS: eventData is [object Object] of type object
     
    3046PASS: eventData is gnirts of type object
    3147PASS: eventData is 42 of type object
     48PASS: eventData is 0 of type object
     49PASS: eventData is -20 of type object
     50PASS: eventData is 4294967295 of type object
     51PASS: eventData is -4294967295 of type object
     52PASS: eventData is 2147483647 of type object
     53PASS: eventData is 2147483648 of type object
     54PASS: eventData is -2147483648 of type object
     55PASS: eventData is -2147483649 of type object
     56PASS: eventData is 68719476735 of type object
     57PASS: eventData is -68719476735 of type object
     58PASS: eventData is 1000000000000000000000000000000000 of type object
     59PASS: eventData is -1000000000000000000000000000000000 of type object
     60PASS: eventData is 1461501637330902918203684832716283019655932542975 of type object
     61PASS: eventData is -1461501637330902918203684832716283019655932542975 of type object
     62PASS: eventData is 4722366482869645213695 of type object
     63PASS: eventData is -4722366482869645213695 of type object
    3264PASS: eventData is === to eventData.self
    3365PASS: eventData is === to eventData[0]
     
    116148PASS: Number object properties not serialized
    117149PASS: Boolean object properties not serialized
     150PASS: BigInt object properties not serialized
     151PASS: BigInt (BigInt32) object properties not serialized
    118152PASS: Date values correct (0)
    119153PASS: Date values correct (1)
  • trunk/Source/WebCore/ChangeLog

    r260403 r260404  
     12020-04-20  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        Add more structure-cloning tests for BigInt
     4        https://bugs.webkit.org/show_bug.cgi?id=210765
     5
     6        Reviewed by Mark Lam.
     7
     8        This patch adds safe-guard for future JSC primitive extension for structure-cloning.
     9        We throw DataCloneError if we see unknown primitive value, which can happen if JSC
     10        extends primitive value.
     11
     12        * bindings/js/SerializedScriptValue.cpp:
     13        (WebCore::CloneSerializer::dumpImmediate):
     14        (WebCore::CloneSerializer::dumpIfTerminal):
     15
    1162020-04-20  Simon Fraser  <simon.fraser@apple.com>
    217
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp

    r260358 r260404  
    754754    }
    755755
    756     void dumpImmediate(JSValue value)
     756    void dumpImmediate(JSValue value, SerializationReturnCode& code)
    757757    {
    758758        if (value.isNull()) {
     
    794794        }
    795795#endif
     796
     797        // Make any new primitive extension safe by throwing an error.
     798        code = SerializationReturnCode::DataCloneError;
    796799    }
    797800
     
    10621065    {
    10631066        if (!value.isCell()) {
    1064             dumpImmediate(value);
     1067            dumpImmediate(value, code);
    10651068            return true;
    10661069        }
Note: See TracChangeset for help on using the changeset viewer.