Diff
Modified: trunk/Source/WebCore/ChangeLog (197224 => 197225)
--- trunk/Source/WebCore/ChangeLog 2016-02-27 01:47:37 UTC (rev 197224)
+++ trunk/Source/WebCore/ChangeLog 2016-02-27 02:03:18 UTC (rev 197225)
@@ -1,3 +1,14 @@
+2016-02-26 Chris Dumez <[email protected]>
+
+ Add API test coverage for parseHTMLInteger / parseHTMLNonNegativeInteger
+ https://bugs.webkit.org/show_bug.cgi?id=154714
+
+ Reviewed by Darin Adler.
+
+ Export a couple more symbols for API testing.
+
+ * html/parser/HTMLParserIdioms.h:
+
2016-02-26 Beth Dakin <[email protected]>
32-bit!!!
Modified: trunk/Source/WebCore/html/parser/HTMLParserIdioms.h (197224 => 197225)
--- trunk/Source/WebCore/html/parser/HTMLParserIdioms.h 2016-02-27 01:47:37 UTC (rev 197224)
+++ trunk/Source/WebCore/html/parser/HTMLParserIdioms.h 2016-02-27 02:03:18 UTC (rev 197225)
@@ -57,10 +57,10 @@
double parseToDoubleForNumberType(const String&, double fallbackValue);
// http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-integers
-bool parseHTMLInteger(const String&, int&);
+WEBCORE_EXPORT bool parseHTMLInteger(const String&, int&);
// http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-non-negative-integers
-bool parseHTMLNonNegativeInteger(const String&, unsigned int&);
+WEBCORE_EXPORT bool parseHTMLNonNegativeInteger(const String&, unsigned&);
// https://html.spec.whatwg.org/multipage/infrastructure.html#cors-settings-attribute
String parseCORSSettingsAttribute(const AtomicString&);
Modified: trunk/Tools/ChangeLog (197224 => 197225)
--- trunk/Tools/ChangeLog 2016-02-27 01:47:37 UTC (rev 197224)
+++ trunk/Tools/ChangeLog 2016-02-27 02:03:18 UTC (rev 197225)
@@ -1,3 +1,27 @@
+2016-02-26 Chris Dumez <[email protected]>
+
+ Add API test coverage for parseHTMLInteger / parseHTMLNonNegativeInteger
+ https://bugs.webkit.org/show_bug.cgi?id=154714
+
+ Reviewed by Darin Adler.
+
+ Add API test coverage for parseHTMLInteger / parseHTMLNonNegativeInteger as per:
+ - https://html.spec.whatwg.org/multipage/infrastructure.html#signed-integers
+ - https://html.spec.whatwg.org/multipage/infrastructure.html#non-negative-integers
+
+ * TestWebKitAPI/PlatformEfl.cmake:
+ * TestWebKitAPI/PlatformGTK.cmake:
+ * TestWebKitAPI/PlatformWin.cmake:
+ * TestWebKitAPI/TestWebKitAPI.vcxproj/TestWebKitAPI.vcxproj:
+ * TestWebKitAPI/TestWebKitAPI.vcxproj/TestWebKitAPI.vcxproj.filters:
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebCore/HTMLParserIdioms.cpp: Added.
+ (TestWebKitAPI::testParseHTMLInteger):
+ (TestWebKitAPI::parseHTMLIntegerFails):
+ (TestWebKitAPI::TEST):
+ (TestWebKitAPI::testParseHTMLNonNegativeInteger):
+ (TestWebKitAPI::parseHTMLNonNegativeIntegerFails):
+
2016-02-26 Commit Queue <[email protected]>
Unreviewed, rolling out r197158.
Modified: trunk/Tools/TestWebKitAPI/PlatformEfl.cmake (197224 => 197225)
--- trunk/Tools/TestWebKitAPI/PlatformEfl.cmake 2016-02-27 01:47:37 UTC (rev 197224)
+++ trunk/Tools/TestWebKitAPI/PlatformEfl.cmake 2016-02-27 02:03:18 UTC (rev 197225)
@@ -58,6 +58,7 @@
set(test_webcore_BINARIES
CSSParser
+ HTMLParserIdioms
LayoutUnit
URL
)
Modified: trunk/Tools/TestWebKitAPI/PlatformGTK.cmake (197224 => 197225)
--- trunk/Tools/TestWebKitAPI/PlatformGTK.cmake 2016-02-27 01:47:37 UTC (rev 197224)
+++ trunk/Tools/TestWebKitAPI/PlatformGTK.cmake 2016-02-27 02:03:18 UTC (rev 197225)
@@ -145,6 +145,7 @@
${test_main_SOURCES}
${TestWebCoreGtk_SOURCES}
${TESTWEBKITAPI_DIR}/TestsController.cpp
+ ${TESTWEBKITAPI_DIR}/Tests/WebCore/HTMLParserIdioms.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/LayoutUnit.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/URL.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBuffer.cpp
Modified: trunk/Tools/TestWebKitAPI/PlatformWin.cmake (197224 => 197225)
--- trunk/Tools/TestWebKitAPI/PlatformWin.cmake 2016-02-27 01:47:37 UTC (rev 197224)
+++ trunk/Tools/TestWebKitAPI/PlatformWin.cmake 2016-02-27 02:03:18 UTC (rev 197225)
@@ -40,6 +40,7 @@
${TESTWEBKITAPI_DIR}/TestsController.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/CalculationValue.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/CSSParser.cpp
+ ${TESTWEBKITAPI_DIR}/Tests/WebCore/HTMLParserIdioms.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/LayoutUnit.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/ParsedContentRange.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/TimeRanges.cpp
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.vcxproj/TestWebKitAPI.vcxproj (197224 => 197225)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.vcxproj/TestWebKitAPI.vcxproj 2016-02-27 01:47:37 UTC (rev 197224)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.vcxproj/TestWebKitAPI.vcxproj 2016-02-27 02:03:18 UTC (rev 197225)
@@ -294,6 +294,7 @@
<ClCompile Include="..\TestsController.cpp" />
<ClCompile Include="..\Tests\WebCore\CalculationValue.cpp" />
<ClCompile Include="..\Tests\WebCore\CSSParser.cpp" />
+ <ClCompile Include="..\Tests\WebCore\HTMLParserIdioms.cpp" />
<ClCompile Include="..\Tests\WebCore\LayoutUnit.cpp" />
<ClCompile Include="..\Tests\WebCore\ParsedContentRange.cpp" />
<ClCompile Include="..\Tests\WebCore\TimeRanges.cpp" />
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.vcxproj/TestWebKitAPI.vcxproj.filters (197224 => 197225)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.vcxproj/TestWebKitAPI.vcxproj.filters 2016-02-27 01:47:37 UTC (rev 197224)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.vcxproj/TestWebKitAPI.vcxproj.filters 2016-02-27 02:03:18 UTC (rev 197225)
@@ -51,6 +51,9 @@
<ClCompile Include="..\Tests\WebCore\win\BitmapImage.cpp">
<Filter>Tests\WebCore</Filter>
</ClCompile>
+ <ClCompile Include="..\Tests\WebCore\HTMLParserIdioms.cpp">
+ <Filter>Tests\WebCore</Filter>
+ </ClCompile>
<ClCompile Include="..\Tests\WebCore\LayoutUnit.cpp">
<Filter>Tests\WebCore</Filter>
</ClCompile>
@@ -181,4 +184,4 @@
<None Include="TestWebKitAPIPostBuild.cmd" />
<None Include="TestWebKitAPIPreBuild.cmd" />
</ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (197224 => 197225)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-02-27 01:47:37 UTC (rev 197224)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-02-27 02:03:18 UTC (rev 197225)
@@ -266,6 +266,7 @@
7CCE7F4F1A411BA400447C4C /* RetainPtrHashing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0991C50143C7D68007998F2 /* RetainPtrHashing.cpp */; };
7CEFA9661AC0B9E200B910FD /* _WKUserContentExtensionStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CEFA9641AC0B9E200B910FD /* _WKUserContentExtensionStore.mm */; };
7CFBCAE51743238F00B2BFCF /* WillLoad_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */; };
+ 83B88A341C80056D00BB2418 /* HTMLParserIdioms.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B88A331C80056D00BB2418 /* HTMLParserIdioms.cpp */; };
83CF1C301C4F1B8B00688447 /* StringUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83CF1C2C1C4F19AE00688447 /* StringUtilities.mm */; };
930AD402150698D00067970F /* lots-of-text.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 930AD401150698B30067970F /* lots-of-text.html */; };
9361002914DC95A70061379D /* lots-of-iframes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9361002814DC957B0061379D /* lots-of-iframes.html */; };
@@ -647,6 +648,7 @@
7CFBCADD1743234F00B2BFCF /* WillLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillLoad.cpp; sourceTree = "<group>"; };
7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillLoad_Bundle.cpp; sourceTree = "<group>"; };
81B50192140F232300D9EB58 /* StringBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringBuilder.cpp; sourceTree = "<group>"; };
+ 83B88A331C80056D00BB2418 /* HTMLParserIdioms.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLParserIdioms.cpp; sourceTree = "<group>"; };
83CF1C2C1C4F19AE00688447 /* StringUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StringUtilities.mm; sourceTree = "<group>"; };
86BD19971A2DB05B006DCF0A /* RefCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RefCounter.cpp; sourceTree = "<group>"; };
8A2C750D16CED9550024F352 /* ResizeWindowAfterCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResizeWindowAfterCrash.cpp; sourceTree = "<group>"; };
@@ -1012,6 +1014,7 @@
260BA57A1B1D2EE2004FA07C /* DFAHelpers.h */,
26F6E1EF1ADC749B00DE696B /* DFAMinimizer.cpp */,
41973B5A1AF2286A006C7B36 /* FileSystem.cpp */,
+ 83B88A331C80056D00BB2418 /* HTMLParserIdioms.cpp */,
14464012167A8305000BD218 /* LayoutUnit.cpp */,
CD225C071C45A69200140761 /* ParsedContentRange.cpp */,
41973B5C1AF22875006C7B36 /* SharedBuffer.cpp */,
@@ -1881,6 +1884,7 @@
2E7765CF16C4D81100BA2BB1 /* mainMac.mm in Sources */,
41973B5B1AF2286A006C7B36 /* FileSystem.cpp in Sources */,
CD89D03A1C4EDB2A00040A04 /* WebCoreNSURLSession.mm in Sources */,
+ 83B88A341C80056D00BB2418 /* HTMLParserIdioms.cpp in Sources */,
A1C4FB6E1BACCE50003742D0 /* QuickLook.mm in Sources */,
7A5623111AD5AF3E0096B920 /* MenuTypesForMouseEvents.cpp in Sources */,
1AAD19F71C7CE20300831E47 /* Coding.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebCore/HTMLParserIdioms.cpp (0 => 197225)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/HTMLParserIdioms.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/HTMLParserIdioms.cpp 2016-02-27 02:03:18 UTC (rev 197225)
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "Test.h"
+#include <WebCore/HTMLParserIdioms.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+static int testParseHTMLInteger(const String& input)
+{
+ int result = 0;
+ bool success = parseHTMLInteger(input, result);
+ EXPECT_TRUE(success);
+ return result;
+}
+
+static bool parseHTMLIntegerFails(const String& input)
+{
+ int result = 0;
+ return !parseHTMLInteger(input, result);
+}
+
+TEST(WebCoreHTMLParserIdioms, parseHTMLInteger)
+{
+ EXPECT_EQ(0, testParseHTMLInteger("0"));
+ EXPECT_EQ(0, testParseHTMLInteger("-0"));
+ EXPECT_EQ(0, testParseHTMLInteger("+0"));
+ EXPECT_EQ(123, testParseHTMLInteger("123"));
+ EXPECT_EQ(123, testParseHTMLInteger("+123"));
+ EXPECT_EQ(-123, testParseHTMLInteger("-123"));
+ EXPECT_EQ(123, testParseHTMLInteger(" 123"));
+ EXPECT_EQ(123, testParseHTMLInteger("123 "));
+ EXPECT_EQ(123, testParseHTMLInteger(" 123 "));
+ EXPECT_EQ(123, testParseHTMLInteger("123abc"));
+ EXPECT_EQ(-123, testParseHTMLInteger("-123abc"));
+ EXPECT_EQ(123, testParseHTMLInteger(" +123"));
+ EXPECT_EQ(-123, testParseHTMLInteger(" -123"));
+ EXPECT_EQ(12, testParseHTMLInteger(" 12 3"));
+ EXPECT_EQ(1, testParseHTMLInteger("1.0"));
+ EXPECT_EQ(1, testParseHTMLInteger("1."));
+ EXPECT_EQ(1, testParseHTMLInteger("1e1"));
+
+ // All HTML whitespaces.
+ EXPECT_EQ(123, testParseHTMLInteger(" \t\r\n\f123"));
+
+ // Boundaries.
+ EXPECT_EQ(-2147483648, testParseHTMLInteger("-2147483648"));
+ EXPECT_EQ(2147483647, testParseHTMLInteger("2147483647"));
+
+ // Failure cases.
+ EXPECT_TRUE(parseHTMLIntegerFails("-2147483649"));
+ EXPECT_TRUE(parseHTMLIntegerFails("2147483648"));
+ EXPECT_TRUE(parseHTMLIntegerFails("111111111111111111"));
+ EXPECT_TRUE(parseHTMLIntegerFails(""));
+ EXPECT_TRUE(parseHTMLIntegerFails(" "));
+ EXPECT_TRUE(parseHTMLIntegerFails(" "));
+ EXPECT_TRUE(parseHTMLIntegerFails("+"));
+ EXPECT_TRUE(parseHTMLIntegerFails("+ 123"));
+ EXPECT_TRUE(parseHTMLIntegerFails("-"));
+ EXPECT_TRUE(parseHTMLIntegerFails("- 123"));
+ EXPECT_TRUE(parseHTMLIntegerFails("a"));
+ EXPECT_TRUE(parseHTMLIntegerFails("-a"));
+ EXPECT_TRUE(parseHTMLIntegerFails("+-123"));
+ EXPECT_TRUE(parseHTMLIntegerFails("-+123"));
+ EXPECT_TRUE(parseHTMLIntegerFails("++123"));
+ EXPECT_TRUE(parseHTMLIntegerFails("--123"));
+ EXPECT_TRUE(parseHTMLIntegerFails("\v123")); // '\v' is an ASCII space but not an HTML whitespace.
+ EXPECT_TRUE(parseHTMLIntegerFails("a123"));
+ EXPECT_TRUE(parseHTMLIntegerFails("+a123"));
+ EXPECT_TRUE(parseHTMLIntegerFails("-a123"));
+ EXPECT_TRUE(parseHTMLIntegerFails(".1"));
+ EXPECT_TRUE(parseHTMLIntegerFails("infinity"));
+}
+
+static unsigned testParseHTMLNonNegativeInteger(const String& input)
+{
+ unsigned result = 0;
+ bool success = parseHTMLNonNegativeInteger(input, result);
+ EXPECT_TRUE(success);
+ return result;
+}
+
+static bool parseHTMLNonNegativeIntegerFails(const String& input)
+{
+ unsigned result = 0;
+ return !parseHTMLNonNegativeInteger(input, result);
+}
+
+TEST(WebCoreHTMLParserIdioms, parseHTMLNonNegativeInteger)
+{
+ EXPECT_EQ(123u, testParseHTMLNonNegativeInteger("123"));
+ EXPECT_EQ(123u, testParseHTMLNonNegativeInteger("+123"));
+ EXPECT_EQ(123u, testParseHTMLNonNegativeInteger(" 123"));
+ EXPECT_EQ(123u, testParseHTMLNonNegativeInteger("123 "));
+ EXPECT_EQ(123u, testParseHTMLNonNegativeInteger(" 123 "));
+ EXPECT_EQ(123u, testParseHTMLNonNegativeInteger("123abc"));
+ EXPECT_EQ(123u, testParseHTMLNonNegativeInteger(" +123"));
+ EXPECT_EQ(12u, testParseHTMLNonNegativeInteger(" 12 3"));
+ EXPECT_EQ(1u, testParseHTMLNonNegativeInteger("1.0"));
+ EXPECT_EQ(1u, testParseHTMLNonNegativeInteger("1."));
+ EXPECT_EQ(1u, testParseHTMLNonNegativeInteger("1e1"));
+
+ // All HTML whitespaces.
+ EXPECT_EQ(123u, testParseHTMLNonNegativeInteger(" \t\r\n\f123"));
+
+ // Boundaries.
+ EXPECT_EQ(0u, testParseHTMLNonNegativeInteger("+0"));
+ EXPECT_EQ(0u, testParseHTMLNonNegativeInteger("0"));
+ // FIXME: This should pass.
+ // EXPECT_EQ(0u, testParseHTMLNonNegativeInteger("-0"));
+ EXPECT_EQ(4294967295u, testParseHTMLNonNegativeInteger("4294967295"));
+
+ // Failure cases.
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("-1"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("4294967296"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("111111111111111111"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails(" -123"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("-123"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("-123abc"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails(""));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails(" "));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails(" "));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("+"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("+ 123"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("-"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("- 123"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("a"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("-a"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("+-123"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("-+123"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("++123"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("--123"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("\v123")); // '\v' is an ASCII space but not an HTML whitespace.
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("a123"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("+a123"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("-a123"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails(".1"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("infinity"));
+}
+
+} // namespace TestWebKitAPI