Changeset 131280 in webkit
- Timestamp:
- Oct 14, 2012 4:50:30 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r131253 r131280 1 2012-10-14 Jon Lee <jonlee@apple.com> 2 3 Allow notification origin permission request when no js callback is provided 4 https://bugs.webkit.org/show_bug.cgi?id=63615 5 <rdar://problem/11059590> 6 7 Reviewed by Sam Weinig. 8 9 * http/tests/notifications/legacy/request-expected.txt: 10 * http/tests/notifications/legacy/request-no-callback-expected.txt: Added. 11 * http/tests/notifications/legacy/request-no-callback.html: Calls webkitNotifications.requestPermission() 12 with no callback, with default and denied permission. For WebKit2, if the permission is not default, it 13 will short circuit instead of creating a pending request. 14 * http/tests/notifications/legacy/request.html: The test mistakenly uses the standard API instead of 15 the legacy API. The results don't change, but we make sure that we call 16 webkitNotifications.requestPermission() with a callback to test full coverage of the legacy API. We also 17 expand the test to cover both default and denied permissions. 18 * http/tests/notifications/request-expected.txt: 19 * http/tests/notifications/request.html: Expand test to cover both default and denied permissions. 20 1 21 2012-10-12 Adam Barth <abarth@webkit.org> 2 22 -
trunk/LayoutTests/http/tests/notifications/legacy/request-expected.txt
r127299 r131280 4 4 5 5 6 Requesting permission with default permission 6 7 PASS window.webkitNotifications.checkPermission() is 1 7 8 PASS window.webkitNotifications.checkPermission() is 0 9 Requesting permission with non-default permission 10 PASS window.webkitNotifications.checkPermission() is 2 8 11 PASS successfullyParsed is true 9 12 -
trunk/LayoutTests/http/tests/notifications/legacy/request.html
r127299 r131280 5 5 <div id="console"></div> 6 6 <script> 7 if (window.testRunner)8 testRunner.waitUntilDone();9 10 7 description("This test checks that a request for permission is made."); 11 8 9 function step1() { 10 debug("Requesting permission with default permission"); 11 shouldBe("window.webkitNotifications.checkPermission()", "1"); 12 webkitNotifications.requestPermission(function() { 13 shouldBe("window.webkitNotifications.checkPermission()", "0"); 14 setTimeout(step2, 0); 15 }); 16 } 17 18 function step2() { 19 testRunner.denyWebNotificationPermission(testURL); 20 debug("Requesting permission with non-default permission"); 21 webkitNotifications.requestPermission(function() { 22 shouldBe("window.webkitNotifications.checkPermission()", "2"); 23 testCompleted(); 24 }); 25 } 26 12 27 if (window.testRunner) { 13 shouldBe("window.webkitNotifications.checkPermission()", "1"); 14 Notification.requestPermission(function() { 15 shouldBe("window.webkitNotifications.checkPermission()", "0"); 16 testCompleted(); 17 }); 28 testRunner.waitUntilDone(); 29 step1(); 18 30 } 19 31 -
trunk/LayoutTests/http/tests/notifications/request-expected.txt
r127299 r131280 4 4 5 5 6 Requesting permission with default permission 6 7 PASS Notification.permission is "default" 7 PASS permission is granted .8 PASS permission is granted 8 9 PASS Notification.permission is "granted" 10 Requesting permission with non-default permission 11 PASS permission is denied 12 PASS Notification.permission is "denied" 9 13 PASS successfullyParsed is true 10 14 -
trunk/LayoutTests/http/tests/notifications/request.html
r127299 r131280 5 5 <div id="console"></div> 6 6 <script> 7 if (window.testRunner)8 testRunner.waitUntilDone();9 10 7 description("This test checks that a request for permission is made."); 11 8 9 function step1() { 10 debug("Requesting permission with default permission"); 11 shouldBeEqualToString("Notification.permission", "default"); 12 Notification.requestPermission(function(permission) { 13 if (permission == 'granted') 14 testPassed("permission is granted"); 15 else 16 testFailed("permission should be granted, but is " + permission); 17 shouldBeEqualToString("Notification.permission", "granted"); 18 setTimeout(step2, 0); 19 }); 20 } 21 22 function step2() { 23 debug("Requesting permission with non-default permission"); 24 testRunner.denyWebNotificationPermission(testURL); 25 Notification.requestPermission(function(permission) { 26 if (permission == 'denied') 27 testPassed("permission is denied"); 28 else 29 testFailed("permission should be denied, but is " + permission); 30 shouldBeEqualToString("Notification.permission", "denied"); 31 testCompleted(); 32 }); 33 } 34 12 35 if (window.testRunner) { 13 shouldBeEqualToString("Notification.permission", "default"); 14 Notification.requestPermission(function(permission) { 15 if (permission == 'granted') 16 testPassed("permission is granted."); 17 else 18 testFailed("permission should be granted, but is " + permission + "."); 19 shouldBeEqualToString("Notification.permission", "granted"); 20 testCompleted(); 21 }); 36 testRunner.waitUntilDone(); 37 step1(); 22 38 } 23 39 -
trunk/Source/WebCore/ChangeLog
r131279 r131280 1 2012-10-14 Jon Lee <jonlee@apple.com> 2 3 Allow notification origin permission request when no js callback is provided 4 https://bugs.webkit.org/show_bug.cgi?id=63615 5 <rdar://problem/11059590> 6 7 Reviewed by Sam Weinig. 8 9 Instead of throwing a type error when no callback is provided, we pass a null callback. 10 11 Test: http/tests/notifications/legacy/request-no-callback.html 12 13 * bindings/js/JSDesktopNotificationsCustom.cpp: 14 (WebCore::JSNotificationCenter::requestPermission): 15 1 16 2012-10-12 Anders Carlsson <andersca@apple.com> 2 17 -
trunk/Source/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp
r125745 r131280 59 59 return throwSyntaxError(exec); 60 60 61 if (!exec->argument(0).isObject()) 62 return throwTypeError(exec); 63 64 impl()->requestPermission(JSVoidCallback::create(exec->argument(0).getObject(), toJSDOMGlobalObject(static_cast<Document*>(context), exec))); 61 // If a callback function is provided as first argument, convert to a VoidCallback. 62 RefPtr<JSVoidCallback> callback; 63 if (exec->argument(0).isObject()) { 64 callback = JSVoidCallback::create(exec->argument(0).getObject(), toJSDOMGlobalObject(static_cast<Document*>(context), exec)); 65 if (exec->hadException()) 66 return jsUndefined(); 67 } 68 impl()->requestPermission(callback.release()); 65 69 return jsUndefined(); 66 70 } -
trunk/Source/WebKit/mac/ChangeLog
r131275 r131280 1 2012-10-14 Jon Lee <jonlee@apple.com> 2 3 Allow notification origin permission request when no js callback is provided 4 https://bugs.webkit.org/show_bug.cgi?id=63615 5 <rdar://problem/11059590> 6 7 Reviewed by Sam Weinig. 8 9 Introduce a boolean to determine whether the request was using the legacy or standard API. This way, 10 we do not fall through to calling the standard API's callback if the legacy API's callback is null. 11 12 * WebCoreSupport/WebNotificationClient.mm: 13 (WebCore): 14 (-[WebNotificationPolicyListener initWithVoidCallback:]): 15 (-[WebNotificationPolicyListener allow]): 16 (-[WebNotificationPolicyListener deny]): 17 1 18 2012-10-14 Sam Weinig <sam@webkit.org> 2 19 -
trunk/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.mm
r130612 r131280 55 55 #if ENABLE(LEGACY_NOTIFICATIONS) 56 56 RefPtr<VoidCallback> _voidCallback; 57 bool _isLegacyRequest; 57 58 #endif 58 59 } … … 253 254 return nil; 254 255 255 ASSERT(callback);256 _isLegacyRequest = true; 256 257 _voidCallback = callback; 257 258 return self; … … 262 263 { 263 264 #if ENABLE(LEGACY_NOTIFICATIONS) 264 if (_voidCallback) { 265 _voidCallback->handleEvent(); 265 if (_isLegacyRequest) { 266 if (_voidCallback) 267 _voidCallback->handleEvent(); 266 268 return; 267 269 } … … 275 277 { 276 278 #if ENABLE(LEGACY_NOTIFICATIONS) 277 if (_voidCallback) { 278 _voidCallback->handleEvent(); 279 if (_isLegacyRequest) { 280 if (_voidCallback) 281 _voidCallback->handleEvent(); 279 282 return; 280 283 } -
trunk/Source/WebKit2/ChangeLog
r131279 r131280 1 2012-10-14 Jon Lee <jonlee@apple.com> 2 3 Allow notification origin permission request when no js callback is provided 4 https://bugs.webkit.org/show_bug.cgi?id=63615 5 <rdar://problem/11059590> 6 7 Reviewed by Sam Weinig. 8 9 Null checks already exist for both standard and legacy API callbacks, so no changes are needed here 10 like there are in WebKit 1. The checks existed because the callbacks are held in a hash map used to keep 11 track of pending requests. 12 13 Also, add a check for a null callback when short circuiting. 14 15 * WebProcess/Notifications/NotificationPermissionRequestManager.cpp: 16 (WebKit::NotificationPermissionRequestManager::startRequest): 17 1 18 2012-10-14 Anders Carlsson <andersca@apple.com> 2 19 -
trunk/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp
r127299 r131280 85 85 NotificationClient::Permission permission = permissionLevel(origin); 86 86 if (permission != NotificationClient::PermissionNotAllowed) { 87 callback->handleEvent(); 87 if (callback) 88 callback->handleEvent(); 88 89 return; 89 90 } -
trunk/Tools/ChangeLog
r131259 r131280 1 2012-10-14 Jon Lee <jonlee@apple.com> 2 3 Allow notification origin permission request when no js callback is provided 4 https://bugs.webkit.org/show_bug.cgi?id=63615 5 <rdar://problem/11059590> 6 7 Reviewed by Sam Weinig. 8 9 Teach DRT to look at the existing entries in the permission hash map when permission is requested. 10 11 * DumpRenderTree/mac/MockWebNotificationProvider.h: Expose policyForOrigin. 12 * DumpRenderTree/mac/MockWebNotificationProvider.mm: 13 (-[MockWebNotificationProvider setWebNotificationOrigin:permission:]): 14 * DumpRenderTree/mac/UIDelegate.mm: 15 (-[UIDelegate webView:decidePolicyForNotificationRequestFromOrigin:listener:]): Look at whether a 16 policy for the origin already exists. If so, accept or deny the request as appropriate. Otherwise, 17 accept by default. 18 1 19 2012-10-13 Zan Dobersek <zandobersek@gmail.com> 2 20 -
trunk/Tools/DumpRenderTree/mac/MockWebNotificationProvider.h
r127042 r131280 49 49 50 50 - (void)simulateWebNotificationClick:(uint64_t)notificationID; 51 - (void)setWebNotificationOrigin:(NSString*)origin permission:(BOOL)allowed; 51 - (void)setWebNotificationOrigin:(NSString *)origin permission:(BOOL)allowed; 52 - (WebNotificationPermission)policyForOrigin:(WebSecurityOrigin *)origin; 52 53 - (void)removeAllWebNotificationPermissions; 53 54 -
trunk/Tools/DumpRenderTree/mac/MockWebNotificationProvider.mm
r130612 r131280 130 130 } 131 131 132 - (void)setWebNotificationOrigin:(NSString *)origin permission:(BOOL)allowed132 - (void)setWebNotificationOrigin:(NSString *)origin permission:(BOOL)allowed 133 133 { 134 134 [_permissions.get() setObject:[NSNumber numberWithBool:allowed] forKey:origin]; -
trunk/Tools/DumpRenderTree/mac/UIDelegate.mm
r129595 r131280 294 294 - (void)webView:(WebView *)webView decidePolicyForNotificationRequestFromOrigin:(WebSecurityOrigin *)origin listener:(id<WebAllowDenyPolicyListener>)listener 295 295 { 296 [(MockWebNotificationProvider *)[webView _notificationProvider] setWebNotificationOrigin:[origin stringValue] permission:YES]; 297 [listener allow]; 296 MockWebNotificationProvider *provider = (MockWebNotificationProvider *)[webView _notificationProvider]; 297 switch ([provider policyForOrigin:origin]) { 298 case WebNotificationPermissionAllowed: 299 [listener allow]; 300 break; 301 case WebNotificationPermissionDenied: 302 [listener deny]; 303 break; 304 case WebNotificationPermissionNotAllowed: 305 [provider setWebNotificationOrigin:[origin stringValue] permission:YES]; 306 [listener allow]; 307 break; 308 } 298 309 } 299 310
Note: See TracChangeset
for help on using the changeset viewer.