Changeset 224044 in webkit
- Timestamp:
- Oct 26, 2017 1:22:13 PM (6 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r224043 r224044 1 2017-10-26 Eric Carlson <eric.carlson@apple.com> 2 3 [MediaStream] Clear cached gUM prompt state 4 https://bugs.webkit.org/show_bug.cgi?id=178754 5 <rdar://problem/32742356> 6 7 Unreviewed, fix a flakey test. 8 9 * TestWebKitAPI/Tests/WebKit/GetUserMediaReprompt.mm: 10 (-[GetUserMediaRepromptTestView haveStream:]): New, check several times for expected state. 11 (TestWebKitAPI::TEST): Don't assume stream state changes in the page immediately. 12 1 13 2017-10-26 Andy Estes <aestes@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WebKit/GetUserMediaReprompt.mm
r223988 r224044 59 59 @end 60 60 61 @interface GetUserMediaRepromptTestView : TestWKWebView 62 - (BOOL)haveStream:(BOOL)expected; 63 @end 64 65 @implementation GetUserMediaRepromptTestView 66 - (BOOL)haveStream:(BOOL)expected 67 { 68 int retryCount = 10; 69 while (retryCount--) { 70 auto result = [self stringByEvaluatingJavaScript:@"haveStream()"]; 71 if (result.boolValue == expected) 72 return YES; 73 74 TestWebKitAPI::Util::spinRunLoop(10); 75 } 76 77 return NO; 78 } 79 @end 80 61 81 namespace TestWebKitAPI { 62 82 … … 69 89 preferences._mediaDevicesEnabled = YES; 70 90 preferences._mockCaptureDevicesEnabled = YES; 71 auto webView = [[ TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) configuration:configuration.get() processPoolConfiguration:processPoolConfig.get()];91 auto webView = [[GetUserMediaRepromptTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) configuration:configuration.get() processPoolConfiguration:processPoolConfig.get()]; 72 92 auto delegate = adoptNS([[GetUserMediaRepromptUIDelegate alloc] init]); 73 93 webView.UIDelegate = delegate.get(); … … 77 97 TestWebKitAPI::Util::run(&wasPrompted); 78 98 79 auto result = [webView stringByEvaluatingJavaScript:@"haveStream()"]; 80 EXPECT_TRUE([result boolValue]); 99 EXPECT_TRUE([webView haveStream:YES]); 81 100 82 101 [webView stringByEvaluatingJavaScript:@"stop()"]; 83 result = [webView stringByEvaluatingJavaScript:@"haveStream()"]; 84 EXPECT_FALSE([result boolValue]); 102 EXPECT_TRUE([webView haveStream:NO]); 85 103 86 104 wasPrompted = false; 87 105 [webView stringByEvaluatingJavaScript:@"promptForCapture()"]; 88 result = [webView stringByEvaluatingJavaScript:@"haveStream()"]; 89 EXPECT_TRUE([result boolValue]); 106 EXPECT_TRUE([webView haveStream:YES]); 90 107 EXPECT_FALSE(wasPrompted); 91 108 92 109 preferences._inactiveMediaCaptureSteamRepromptIntervalInMinutes = .5 / 60; 93 110 [webView stringByEvaluatingJavaScript:@"stop()"]; 94 result = [webView stringByEvaluatingJavaScript:@"haveStream()"]; 95 EXPECT_FALSE([result boolValue]); 111 EXPECT_TRUE([webView haveStream:NO]); 96 112 97 113 // Sleep long enough for the reprompt timer to fire and clear cached state. … … 101 117 [webView stringByEvaluatingJavaScript:@"promptForCapture()"]; 102 118 TestWebKitAPI::Util::run(&wasPrompted); 103 result = [webView stringByEvaluatingJavaScript:@"haveStream()"]; 104 EXPECT_TRUE([result boolValue]); 119 EXPECT_TRUE([webView haveStream:YES]); 105 120 } 106 121
Note: See TracChangeset
for help on using the changeset viewer.