WebKit Bugzilla
Attachment 340287 Details for
Bug 185599
: [iOS] Add a test to ensure that setTimeout() does not fire more than expected when using UIWebView
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Unit test
bug-185599-20180513204138.patch (text/plain), 11.93 KB, created by
Daniel Bates
on 2018-05-13 20:41:39 PDT
(
hide
)
Description:
Unit test
Filename:
MIME Type:
Creator:
Daniel Bates
Created:
2018-05-13 20:41:39 PDT
Size:
11.93 KB
patch
obsolete
>Subversion Revision: 231704 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index c2ddfb514f161776d0cfb8e7f9bf59e9df7aa0b0..9b223133b607f8e911a15415ac55b42b495d0aab 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,19 @@ >+2018-05-13 Daniel Bates <dabates@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 NOBODY (OOPS!). >+ >+ * 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-11 Brady Eidson <beidson@apple.com> > > Make sure history navigations reuse the existing process when necessary. >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index ce7eab298214dbefc6ac844e31b247e804c6f05f..2c5b20a6fd1c34741b7d910d7364e96d7fdccf58 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -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 */, >- 2DB0232E1E4E871800707123 /* InteractionDeadlockAfterCrash.mm */, > 79C5D430209D768300F1E7CA /* InjectedBundleNodeHandleIsTextField.mm */, >+ 2DB0232E1E4E871800707123 /* InteractionDeadlockAfterCrash.mm */, > 5C69BDD41F82A7EB000F4F4B /* JavaScriptDuringNavigation.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 */, >diff --git a/Tools/TestWebKitAPI/Tests/ios/SetTimeoutFunction.mm b/Tools/TestWebKitAPI/Tests/ios/SetTimeoutFunction.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..4d5ce8a1a5daa0c1afae8a816df83b4544b9c463 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/ios/SetTimeoutFunction.mm >@@ -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 = [[NSBundle 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) >diff --git a/Tools/TestWebKitAPI/ios/set-timeout-function.html b/Tools/TestWebKitAPI/ios/set-timeout-function.html >new file mode 100644 >index 0000000000000000000000000000000000000000..a5ff9ee1ab0ff9599f754292f8c2f972cf548cb3 >--- /dev/null >+++ b/Tools/TestWebKitAPI/ios/set-timeout-function.html >@@ -0,0 +1,16 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script> >+var i = 0; >+setTimeout(function() { i++; }, 0); >+setTimeout(function() { i++; }, 100); >+setTimeout(function() { >+ i++; >+ window.location.href = "?fired-" + i; >+}, 200); >+</script> >+</head> >+<body> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
simon.fraser
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185599
: 340287