Title: [231776] trunk/Tools
Revision
231776
Author
dba...@webkit.org
Date
2018-05-14 16:19:29 -0700 (Mon, 14 May 2018)

Log Message

[iOS] Add a test to ensure that setTimeout() does not fire more than expected when using UIWebView
https://bugs.webkit.org/show_bug.cgi?id=185599
<rdar://problem/22493890>

Reviewed by Simon Fraser.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/ios/SetTimeoutFunction.mm: Added.
(-[SetTimeoutFunctionWebViewDelegate webViewDidFinishLoad:]):
(-[SetTimeoutFunctionWebViewDelegate webView:didFailLoadWithError:]):
(-[SetTimeoutFunctionWebViewDelegate webView:shouldStartLoadWithRequest:navigationType:]):
(TestWebKitAPI::TEST):
* TestWebKitAPI/ios/set-timeout-function.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (231775 => 231776)


--- trunk/Tools/ChangeLog	2018-05-14 23:18:17 UTC (rev 231775)
+++ trunk/Tools/ChangeLog	2018-05-14 23:19:29 UTC (rev 231776)
@@ -1,3 +1,19 @@
+2018-05-14  Daniel Bates  <daba...@apple.com>
+
+        [iOS] Add a test to ensure that setTimeout() does not fire more than expected when using UIWebView
+        https://bugs.webkit.org/show_bug.cgi?id=185599
+        <rdar://problem/22493890>
+
+        Reviewed by Simon Fraser.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/ios/SetTimeoutFunction.mm: Added.
+        (-[SetTimeoutFunctionWebViewDelegate webViewDidFinishLoad:]):
+        (-[SetTimeoutFunctionWebViewDelegate webView:didFailLoadWithError:]):
+        (-[SetTimeoutFunctionWebViewDelegate webView:shouldStartLoadWithRequest:navigationType:]):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/ios/set-timeout-function.html: Added.
+
 2018-05-14  Valerie R Young  <vale...@bocoup.com>
 
         test262/Runner.pm: small bugs in CLI and error codes

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (231775 => 231776)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-05-14 23:18:17 UTC (rev 231775)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-05-14 23:19:29 UTC (rev 231776)
@@ -726,6 +726,8 @@
 		CE3524F91B1441C40028A7C5 /* TextFieldDidBeginAndEndEditing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE3524F11B142B8D0028A7C5 /* TextFieldDidBeginAndEndEditing.cpp */; };
 		CE3524FA1B1443890028A7C5 /* input-focus-blur.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CE3524F51B142BBB0028A7C5 /* input-focus-blur.html */; };
 		CE4D5DE71F6743BA0072CFC6 /* StringWithDirection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE4D5DE51F6743BA0072CFC6 /* StringWithDirection.cpp */; };
+		CE6E81A020A6935F00E2C80F /* SetTimeoutFunction.mm in Sources */ = {isa = PBXBuildFile; fileRef = CE6E819F20A6935F00E2C80F /* SetTimeoutFunction.mm */; };
+		CE6E81A420A933D500E2C80F /* set-timeout-function.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CE6E81A320A933B800E2C80F /* set-timeout-function.html */; };
 		CEA6CF2819CCF69D0064F5A7 /* open-and-close-window.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */; };
 		CEA7F57D2089624B0078EF6E /* DidResignInputElementStrongPasswordAppearance.mm in Sources */ = {isa = PBXBuildFile; fileRef = CEA7F57B20895F5B0078EF6E /* DidResignInputElementStrongPasswordAppearance.mm */; };
 		CEBABD491B71687C0051210A /* should-open-external-schemes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CEBABD481B71687C0051210A /* should-open-external-schemes.html */; };
@@ -1082,6 +1084,7 @@
 				0F5651F91FCE513500310FBC /* scroll-to-anchor.html in Copy Resources */,
 				F4D65DA81F5E4704009D8C27 /* selected-text-image-link-and-editable.html in Copy Resources */,
 				7A66BDB81EAF18D500CCC924 /* set-long-title.html in Copy Resources */,
+				CE6E81A420A933D500E2C80F /* set-timeout-function.html in Copy Resources */,
 				52B8CF9815868D9100281053 /* SetDocumentURI.html in Copy Resources */,
 				CEBABD491B71687C0051210A /* should-open-external-schemes.html in Copy Resources */,
 				C9B4AD2A1ECA6EBE00F5FEA0 /* silence-long.m4a in Copy Resources */,
@@ -1877,6 +1880,8 @@
 		CE3524F51B142BBB0028A7C5 /* input-focus-blur.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "input-focus-blur.html"; sourceTree = "<group>"; };
 		CE4D5DE51F6743BA0072CFC6 /* StringWithDirection.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StringWithDirection.cpp; sourceTree = "<group>"; };
 		CE50D8C81C8665CE0072EA5A /* OptionSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionSet.cpp; sourceTree = "<group>"; };
+		CE6E819F20A6935F00E2C80F /* SetTimeoutFunction.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SetTimeoutFunction.mm; sourceTree = "<group>"; };
+		CE6E81A320A933B800E2C80F /* set-timeout-function.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = "set-timeout-function.html"; path = "ios/set-timeout-function.html"; sourceTree = SOURCE_ROOT; };
 		CEA6CF2219CCF5BD0064F5A7 /* OpenAndCloseWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OpenAndCloseWindow.mm; sourceTree = "<group>"; };
 		CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "open-and-close-window.html"; sourceTree = "<group>"; };
 		CEA7F57B20895F5B0078EF6E /* DidResignInputElementStrongPasswordAppearance.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DidResignInputElementStrongPasswordAppearance.mm; sourceTree = "<group>"; };
@@ -2192,8 +2197,8 @@
 				51B1EE8D1C80F5880064FB98 /* IndexedDBPersistence.mm */,
 				57599E201F07191700A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.mm */,
 				5198A23F1EA7E595008910B7 /* InitialWarmedProcessUsed.mm */,
+				79C5D430209D768300F1E7CA /* InjectedBundleNodeHandleIsTextField.mm */,
 				2DB0232E1E4E871800707123 /* InteractionDeadlockAfterCrash.mm */,
-				79C5D430209D768300F1E7CA /* InjectedBundleNodeHandleIsTextField.mm */,
 				5C69BDD41F82A7EB000F4F4B /* _javascript_DuringNavigation.mm */,
 				C25CCA051E51380B0026CB8A /* LineBreaking.mm */,
 				37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */,
@@ -2380,6 +2385,7 @@
 				574F55CE204D3763002948C6 /* LocalAuthenticator.mm */,
 				7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */,
 				F4C8797E2059D8D3009CD00B /* ScrollViewInsetTests.mm */,
+				CE6E819F20A6935F00E2C80F /* SetTimeoutFunction.mm */,
 				4433A395208044130091ED57 /* SynchronousTimeoutTests.mm */,
 				F45033F4206BEC95009351CE /* TextAutosizingBoost.mm */,
 				F46849BD1EEF58E400B937FE /* UIPasteboardTests.mm */,
@@ -2583,6 +2589,7 @@
 			isa = PBXGroup;
 			children = (
 				A1C4FB721BACD1B7003742D0 /* pages.pages */,
+				CE6E81A320A933B800E2C80F /* set-timeout-function.html */,
 			);
 			name = Resources;
 			sourceTree = "<group>";
@@ -3720,6 +3727,7 @@
 				51EB12941FDF052500A5A1BD /* ServiceWorkerBasic.mm in Sources */,
 				7CCE7ECB1A411A7E00447C4C /* SetAndUpdateCacheModel.mm in Sources */,
 				7CCE7ECC1A411A7E00447C4C /* SetDocumentURI.mm in Sources */,
+				CE6E81A020A6935F00E2C80F /* SetTimeoutFunction.mm in Sources */,
 				7C83E0521D0A641800FEBCF3 /* SharedBuffer.cpp in Sources */,
 				A17991881E1C994E00A505ED /* SharedBuffer.mm in Sources */,
 				A179918B1E1CA24100A505ED /* SharedBufferTest.cpp in Sources */,
@@ -3865,11 +3873,11 @@
 				A13EBBB01B87436F00097110 /* BundleParametersPlugIn.mm in Sources */,
 				37A709AF1E3EA97E00CA5969 /* BundleRangeHandlePlugIn.mm in Sources */,
 				1C2B81831C891F0900A5529F /* CancelFontSubresourcePlugIn.mm in Sources */,
-				79C5D431209D768300F1E7CA /* InjectedBundleNodeHandleIsTextField.mm in Sources */,
 				5CB18BA81F5645E300EE23C4 /* ClickAutoFillButton.mm in Sources */,
 				A14FC58B1B89927100D107EB /* ContentFilteringPlugIn.mm in Sources */,
 				CEA7F57D2089624B0078EF6E /* DidResignInputElementStrongPasswordAppearance.mm in Sources */,
 				5CB5B3C21FFC55CF00C27BB0 /* FrameHandleSerialization.mm in Sources */,
+				79C5D431209D768300F1E7CA /* InjectedBundleNodeHandleIsTextField.mm in Sources */,
 				A13EBBAB1B87434600097110 /* PlatformUtilitiesCocoa.mm in Sources */,
 				1A4F81CF1BDFFD53004E672E /* RemoteObjectRegistryPlugIn.mm in Sources */,
 				A12DDC021E837C2400CF6CAE /* RenderedImageWithOptionsPlugIn.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/ios/SetTimeoutFunction.mm (0 => 231776)


--- trunk/Tools/TestWebKitAPI/Tests/ios/SetTimeoutFunction.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/SetTimeoutFunction.mm	2018-05-14 23:19:29 UTC (rev 231776)
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#import "config.h"
+
+#if PLATFORM(IOS)
+
+#import "PlatformUtilities.h"
+#import <UIKit/UIKit.h>
+#import <wtf/RetainPtr.h>
+
+static bool loadComplete;
+static bool loadFailed;
+static bool testComplete;
+static RetainPtr<NSString> numberOfSetTimeoutCallbacks;
+
+@interface SetTimeoutFunctionWebViewDelegate : NSObject <UIWebViewDelegate>
+@end
+
+@implementation SetTimeoutFunctionWebViewDelegate
+
+- (void)webViewDidFinishLoad:(UIWebView *)webView
+{
+    loadComplete = true;
+}
+
+- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
+{
+    loadComplete = true;
+    loadFailed = true;
+}
+
+- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
+{
+    NSString *prefix = @"fired-";
+    NSString *queryString = request.URL.query;
+    if ([queryString hasPrefix:prefix]) {
+        numberOfSetTimeoutCallbacks = [queryString substringFromIndex:prefix.length];
+        testComplete = true;
+        return NO;
+    }
+    return YES;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKitLegacy, SetTimeoutFunction)
+{
+    RetainPtr<UIWindow> uiWindow = adoptNS([[UIWindow alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+    RetainPtr<UIWebView> uiWebView = adoptNS([[UIWebView alloc] initWithFrame:[uiWindow frame]]);
+    [uiWindow addSubview:uiWebView.get()];
+
+    RetainPtr<SetTimeoutFunctionWebViewDelegate> uiDelegate = adoptNS([[SetTimeoutFunctionWebViewDelegate alloc] init]);
+    uiWebView.get().delegate = uiDelegate.get();
+
+    RetainPtr<NSURL> url = "" mainBundle] URLForResource:@"set-timeout-function" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+    [uiWebView loadRequest:[NSURLRequest requestWithURL:url.get()]];
+    Util::run(&loadComplete);
+    EXPECT_TRUE(loadComplete);
+    EXPECT_FALSE(loadFailed);
+
+    Util::run(&testComplete);
+    EXPECT_WK_STREQ("3", numberOfSetTimeoutCallbacks.get());
+}
+
+}
+
+#endif // PLATFORM(IOS)

Added: trunk/Tools/TestWebKitAPI/ios/set-timeout-function.html (0 => 231776)


--- trunk/Tools/TestWebKitAPI/ios/set-timeout-function.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/ios/set-timeout-function.html	2018-05-14 23:19:29 UTC (rev 231776)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+var i = 0;
+setTimeout(function() { i++; }, 0);
+setTimeout(function() { i++; }, 10);
+setTimeout(function() {
+    i++;
+    window.location.href = "" + i;
+}, 20);
+</script>
+</head>
+<body>
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to