⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 182872 in webkit


Ignore:
Timestamp:
Apr 15, 2015, 5:15:11 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

String.prototype.startsWith/endsWith/includes have wrong length in r182673
https://bugs.webkit.org/show_bug.cgi?id=143659

Patch by Jordan Harband <ljharb@gmail.com> on 2015-04-15
Reviewed by Benjamin Poulain.

Source/JavaScriptCore:

Fix lengths of String.prototype.{includes,startsWith,endsWith} per spec
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.includes
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.startswith
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.endswith

  • runtime/StringPrototype.cpp:

(JSC::StringPrototype::finishCreation):

LayoutTests:

  • js/script-tests/string-includes.js:
  • js/string-includes-expected.txt:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r182868 r182872  
     12015-04-15  Jordan Harband  <ljharb@gmail.com>
     2
     3        String.prototype.startsWith/endsWith/includes have wrong length in r182673
     4        https://bugs.webkit.org/show_bug.cgi?id=143659
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        * js/script-tests/string-includes.js:
     9        * js/string-includes-expected.txt:
     10
    1112015-04-15  Jordan Harband  <ljharb@gmail.com>
    212
  • trunk/LayoutTests/js/script-tests/string-includes.js

    r181105 r182872  
    22
    33// Test includes
     4shouldBe("String.prototype.includes.length", "1");
    45shouldBe("'foo bar'.includes('bar')", "true");
    56shouldBe("'foo bar'.includes('bar', 4)", "true");
     
    3233
    3334// Test startsWith
     35shouldBe("String.prototype.startsWith.length", "1");
    3436shouldBe("'foo bar'.startsWith('foo')", "true");
    3537shouldBe("'foo bar'.startsWith('foo', 0)", "true");
     
    6163
    6264// Test endsWith
     65shouldBe("String.prototype.endsWith.length", "1");
    6366shouldBe("'foo bar'.endsWith('bar')", "true");
    6467shouldBe("'foo bar'.endsWith('ba', 6)", "true");
  • trunk/LayoutTests/js/string-includes-expected.txt

    r181105 r182872  
    44
    55
     6PASS String.prototype.includes.length is 1
    67PASS 'foo bar'.includes('bar') is true
    78PASS 'foo bar'.includes('bar', 4) is true
     
    3233PASS 'フーバー'.includes('ーバ') is true
    3334PASS 'フーバー'.includes('クー') is false
     35PASS String.prototype.startsWith.length is 1
    3436PASS 'foo bar'.startsWith('foo') is true
    3537PASS 'foo bar'.startsWith('foo', 0) is true
     
    5961PASS 'foo bar'.startsWith('フー') is false
    6062PASS 'foo bar'.startsWith('フー', 1) is false
     63PASS String.prototype.endsWith.length is 1
    6164PASS 'foo bar'.endsWith('bar') is true
    6265PASS 'foo bar'.endsWith('ba', 6) is true
  • trunk/Source/JavaScriptCore/ChangeLog

    r182871 r182872  
     12015-04-15  Jordan Harband  <ljharb@gmail.com>
     2
     3        String.prototype.startsWith/endsWith/includes have wrong length in r182673
     4        https://bugs.webkit.org/show_bug.cgi?id=143659
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        Fix lengths of String.prototype.{includes,startsWith,endsWith} per spec
     9        https://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.includes
     10        https://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.startswith
     11        https://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.endswith
     12
     13        * runtime/StringPrototype.cpp:
     14        (JSC::StringPrototype::finishCreation):
     15
    1162015-04-15  Mark Lam  <mark.lam@apple.com>
    217
  • trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp

    r182205 r182872  
    33 *  Copyright (C) 2004, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
    44 *  Copyright (C) 2009 Torch Mobile, Inc.
     5 *  Copyright (C) 2015 Jordan Harband (ljharb@gmail.com)
    56 *
    67 *  This library is free software; you can redistribute it and/or
     
    140141    JSC_NATIVE_FUNCTION("trimLeft", stringProtoFuncTrimLeft, DontEnum, 0);
    141142    JSC_NATIVE_FUNCTION("trimRight", stringProtoFuncTrimRight, DontEnum, 0);
    142     JSC_NATIVE_FUNCTION("startsWith", stringProtoFuncStartsWith, DontEnum, 0);
    143     JSC_NATIVE_FUNCTION("endsWith", stringProtoFuncEndsWith, DontEnum, 0);
    144     JSC_NATIVE_FUNCTION("includes", stringProtoFuncIncludes, DontEnum, 0);
     143    JSC_NATIVE_FUNCTION("startsWith", stringProtoFuncStartsWith, DontEnum, 1);
     144    JSC_NATIVE_FUNCTION("endsWith", stringProtoFuncEndsWith, DontEnum, 1);
     145    JSC_NATIVE_FUNCTION("includes", stringProtoFuncIncludes, DontEnum, 1);
    145146    JSC_NATIVE_FUNCTION(vm.propertyNames->iteratorSymbol, stringProtoFuncIterator, DontEnum, 0);
    146147
Note: See TracChangeset for help on using the changeset viewer.