Changeset 192874 in webkit


Ignore:
Timestamp:
Dec 1, 2015 1:06:25 AM (8 years ago)
Author:
youenn.fablet@crf.canon.fr
Message:

[Streams API] streams should not directly use Number and related methods
https://bugs.webkit.org/show_bug.cgi?id=151499

Reviewed by Darin Adler.

Source/JavaScriptCore:

  • runtime/CommonIdentifiers.h: Adding isNaN as private symbol.
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init): Adding @isNaN function.

Source/WebCore:

Covered by updated test.

Using @Number, @isFinite and @isNaN in place of Number, Number.isFinite and Number.isNaN.

  • Modules/streams/ReadableStreamInternals.js:

(enqueueInReadableStream):

  • Modules/streams/StreamInternals.js:

(validateAndNormalizeQueuingStrategy):
(enqueueValueWithSize):

LayoutTests:

Added a non-regression test.

  • streams/streams-promises-expected.txt:
  • streams/streams-promises.html:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r192865 r192874  
     12015-12-01  Youenn Fablet  <youenn.fablet@crf.canon.fr>
     2
     3        [Streams API] streams should not directly use Number and related methods
     4        https://bugs.webkit.org/show_bug.cgi?id=151499
     5
     6        Reviewed by Darin Adler.
     7
     8        Added a non-regression test.
     9
     10        * streams/streams-promises-expected.txt:
     11        * streams/streams-promises.html:
     12
    1132015-12-01  Youenn Fablet  <youenn.fablet@crf.canon.fr>
    214
  • trunk/LayoutTests/streams/streams-promises-expected.txt

    r192207 r192874  
    77PASS Streams and promises: replace catch method in Promise prototype
    88PASS Streams and promises: replace then method in promise object
     9PASS Streams should not directly use Number and related methods
    910
  • trunk/LayoutTests/streams/streams-promises.html

    r192865 r192874  
    9090    new WritableStream({ start: function() { return createMangledPromise(); } })
    9191}, 'Streams and promises: replace then method in promise object');
     92
     93test(function() {
     94    const NumberBackup = Number;
     95    const NumberIsNaNBackup = Number.isNaN;
     96    const NumberIsFiniteBackup = Number.isFinite;
     97
     98    try {
     99        Number.isNaN = function() { assert_unreached("streams should not use this Number.isNaN method"); };
     100        Number.isFinite = function() { assert_unreached("streams should not use this Number.isFinite method"); };
     101        Number = null;
     102
     103        new ReadableStream({
     104            start: function(controller) {
     105                controller.enqueue("small potato");
     106            }
     107        }, {
     108            size: function(chunk) { return 2; },
     109            highWaterMark: 1
     110        });
     111
     112    } finally {
     113        Number = NumberBackup;
     114        Number.isNaN = NumberIsNaNBackup;
     115        Number.isFinite = NumberIsFiniteBackup;
     116    }
     117}, 'Streams should not directly use Number and related methods');
    92118</script>
  • trunk/Source/JavaScriptCore/ChangeLog

    r192873 r192874  
     12015-12-01  Youenn Fablet  <youenn.fablet@crf.canon.fr>
     2
     3        [Streams API] streams should not directly use Number and related methods
     4        https://bugs.webkit.org/show_bug.cgi?id=151499
     5
     6        Reviewed by Darin Adler.
     7
     8        * runtime/CommonIdentifiers.h: Adding isNaN as private symbol.
     9        * runtime/JSGlobalObject.cpp:
     10        (JSC::JSGlobalObject::init): Adding @isNaN function.
     11
    1122015-12-01  Csaba Osztrogonác  <ossy@webkit.org>
    213
  • trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h

    r192155 r192874  
    298298    macro(floor) \
    299299    macro(isFinite) \
     300    macro(isNaN) \
    300301    macro(getPrototypeOf) \
    301302    macro(getOwnPropertyNames) \
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r192855 r192874  
    501501    JSFunction* privateFuncFloor = JSFunction::create(vm, this, 0, String(), mathProtoFuncFloor, FloorIntrinsic);
    502502    JSFunction* privateFuncIsFinite = JSFunction::create(vm, this, 0, String(), globalFuncIsFinite);
     503    JSFunction* privateFuncIsNaN = JSFunction::create(vm, this, 0, String(), globalFuncIsNaN);
    503504
    504505    JSFunction* privateFuncGetTemplateObject = JSFunction::create(vm, this, 0, String(), getTemplateObject);
     
    528529        GlobalPropertyInfo(vm.propertyNames->floorPrivateName, privateFuncFloor, DontEnum | DontDelete | ReadOnly),
    529530        GlobalPropertyInfo(vm.propertyNames->isFinitePrivateName, privateFuncIsFinite, DontEnum | DontDelete | ReadOnly),
     531        GlobalPropertyInfo(vm.propertyNames->isNaNPrivateName, privateFuncIsNaN, DontEnum | DontDelete | ReadOnly),
    530532        GlobalPropertyInfo(vm.propertyNames->arrayIterationKindKeyPrivateName, jsNumber(ArrayIterateKey), DontEnum | DontDelete | ReadOnly),
    531533        GlobalPropertyInfo(vm.propertyNames->arrayIterationKindValuePrivateName, jsNumber(ArrayIterateValue), DontEnum | DontDelete | ReadOnly),
  • trunk/Source/WebCore/ChangeLog

    r192872 r192874  
     12015-12-01  Youenn Fablet  <youenn.fablet@crf.canon.fr>
     2
     3        [Streams API] streams should not directly use Number and related methods
     4        https://bugs.webkit.org/show_bug.cgi?id=151499
     5
     6        Reviewed by Darin Adler.
     7
     8        Covered by updated test.
     9
     10        Using @Number, @isFinite and @isNaN in place of Number, Number.isFinite and Number.isNaN.
     11
     12        * Modules/streams/ReadableStreamInternals.js:
     13        (enqueueInReadableStream):
     14        * Modules/streams/StreamInternals.js:
     15        (validateAndNormalizeQueuingStrategy):
     16        (enqueueValueWithSize):
     17
    1182015-12-01  Carlos Garcia Campos  <cgarcia@igalia.com>
    219
  • trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js

    r192865 r192874  
    323323        let size = 1;
    324324        if (stream.@strategy.size) {
    325             size = Number(stream.@strategy.size(chunk));
    326             if (Number.isNaN(size) || size === +Infinity || size < 0)
     325            size = @Number(stream.@strategy.size(chunk));
     326            if (!@isFinite(size) || size < 0)
    327327                throw new @RangeError("Chunk size is not valid");
    328328        }
  • trunk/Source/WebCore/Modules/streams/StreamInternals.js

    r192246 r192874  
    7979
    8080    normalizedStrategy.size = size;
    81     normalizedStrategy.highWaterMark = Number(highWaterMark);
     81    normalizedStrategy.highWaterMark = @Number(highWaterMark);
    8282
    83     if (Number.isNaN(normalizedStrategy.highWaterMark))
     83    if (@isNaN(normalizedStrategy.highWaterMark))
    8484        throw new @TypeError("highWaterMark parameter is not a number");
    8585    if (normalizedStrategy.highWaterMark < 0)
     
    109109    "use strict";
    110110
    111     size = Number(size);
    112     if (Number.isNaN(size) || !Number.isFinite(size) || size < 0)
     111    size = @Number(size);
     112    if (!@isFinite(size) || size < 0)
    113113        throw new @RangeError("size has an incorrect value");
    114114    queue.content.push({ value: value, size: size });
Note: See TracChangeset for help on using the changeset viewer.