REGRESSION(r182879): Images and video can no longer be downloaded
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Apr 2015 18:38:29 +0000 (18:38 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Apr 2015 18:38:29 +0000 (18:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144267
<rdar://problem/20702844>

Reviewed by Simon Fraser.

Source/WebKit/mac:

* WebView/WebActionMenuController.mm:
(-[WebActionMenuController _createActionMenuItemForTag:]): Check for
"!WebCore::protocolIs(..., "file")" for image and media downloads.

Source/WebKit2:

* UIProcess/mac/WKActionMenuController.mm:
(-[WKActionMenuController _createActionMenuItemForTag:]): Check for
"!WebCore::protocolIs(..., "file")" for image and media downloads.

Tools:

Revise tests to check for proper download menu state.
1. Downloading a loal image should be disabled.
2. Downloading a local media file should be disabled.
3. Downloading non-downloadable media should be disabled.

* TestWebKitAPI/Tests/WebKit2ObjC/ActionMenus.mm:
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183403 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebActionMenuController.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/WKActionMenuController.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2ObjC/ActionMenus.mm

index 06ff7ff..8b47935 100644 (file)
@@ -1,3 +1,15 @@
+2015-04-27  Brent Fulgham  <bfulgham@apple.com>
+
+        REGRESSION(r182879): Images and video can no longer be downloaded
+        https://bugs.webkit.org/show_bug.cgi?id=144267
+        <rdar://problem/20702844>
+
+        Reviewed by Simon Fraser.
+
+        * WebView/WebActionMenuController.mm:
+        (-[WebActionMenuController _createActionMenuItemForTag:]): Check for
+        "!WebCore::protocolIs(..., "file")" for image and media downloads.
+
 2015-04-26  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         [ES6] Implement ES6 template literals
index 7a3eb81..36cdcb2 100644 (file)
@@ -691,7 +691,7 @@ static NSString *pathToPhotoOnDisk(NSString *suggestedFilename)
         selector = @selector(_saveImageToDownloads:);
         title = WEB_UI_STRING_KEY("Save to Downloads", "Save to Downloads (image action menu item)", "image action menu item");
         image = [NSImage imageNamed:@"NSActionMenuSaveToDownloads"];
-        enabled = WebCore::protocolIs(_hitTestResult.absoluteImageURL(), "file");
+        enabled = !WebCore::protocolIs(_hitTestResult.absoluteImageURL(), "file");
         break;
 
     case WebActionMenuItemTagCopyVideoURL:
@@ -704,7 +704,7 @@ static NSString *pathToPhotoOnDisk(NSString *suggestedFilename)
         selector = @selector(_saveVideoToDownloads:);
         title = WEB_UI_STRING_KEY("Save to Downloads", "Save to Downloads (video action menu item)", "video action menu item");
         image = [NSImage imageNamed:@"NSActionMenuSaveToDownloads"];
-        enabled = WebCore::protocolIs(_hitTestResult.absoluteMediaURL(), "file");
+        enabled = !WebCore::protocolIs(_hitTestResult.absoluteMediaURL(), "file") && _hitTestResult.isDownloadableMedia();
         break;
 
     default:
index e2912b0..b5ed9f5 100644 (file)
@@ -1,3 +1,15 @@
+2015-04-27  Brent Fulgham  <bfulgham@apple.com>
+
+        REGRESSION(r182879): Images and video can no longer be downloaded
+        https://bugs.webkit.org/show_bug.cgi?id=144267
+        <rdar://problem/20702844>
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/mac/WKActionMenuController.mm:
+        (-[WKActionMenuController _createActionMenuItemForTag:]): Check for
+        "!WebCore::protocolIs(..., "file")" for image and media downloads.
+
 2015-04-27  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         [EFL] TestWebKitAPI's forwarding header generator should depend on WebKit2's generator
index 71f6870..a93ab36 100644 (file)
@@ -590,7 +590,7 @@ static NSString *pathToPhotoOnDisk(NSString *suggestedFilename)
         selector = @selector(_saveImageToDownloads:);
         title = WEB_UI_STRING_KEY("Save to Downloads", "Save to Downloads (image action menu item)", "image action menu item");
         image = [NSImage imageNamed:@"NSActionMenuSaveToDownloads"];
-        enabled = WebCore::protocolIs(hitTestResult->absoluteImageURL(), "file");
+        enabled = !WebCore::protocolIs(hitTestResult->absoluteImageURL(), "file");
         break;
 
     case kWKContextActionItemTagCopyText:
@@ -621,7 +621,7 @@ static NSString *pathToPhotoOnDisk(NSString *suggestedFilename)
         selector = @selector(_saveVideoToDownloads:);
         title = WEB_UI_STRING_KEY("Save to Downloads", "Save to Downloads (video action menu item)", "video action menu item");
         image = [NSImage imageNamed:@"NSActionMenuSaveToDownloads"];
-        enabled = WebCore::protocolIs(hitTestResult->absoluteMediaURL(), "file");
+        enabled = !WebCore::protocolIs(hitTestResult->absoluteMediaURL(), "file") && hitTestResult->isDownloadableMedia();
         break;
 
     default:
index 9596eab..d6902ff 100644 (file)
@@ -1,3 +1,19 @@
+2015-04-27  Brent Fulgham  <bfulgham@apple.com>
+
+        REGRESSION(r182879): Images and video can no longer be downloaded
+        https://bugs.webkit.org/show_bug.cgi?id=144267
+        <rdar://problem/20702844>
+
+        Reviewed by Simon Fraser.
+
+        Revise tests to check for proper download menu state.
+        1. Downloading a loal image should be disabled.
+        2. Downloading a local media file should be disabled.
+        3. Downloading non-downloadable media should be disabled.
+
+        * TestWebKitAPI/Tests/WebKit2ObjC/ActionMenus.mm:
+        (TestWebKitAPI::TEST):
+
 2015-04-27  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         Merge run-launcher into run-minibrowser
index 5712114..4f52c5e 100644 (file)
@@ -665,14 +665,11 @@ TEST(WebKit2, ActionMenusTest)
         EXPECT_EQ(174, image.size.height);
     }];
 
-    // Download an image.
+    // Download a local image (should be disabled)
     activeDownloadContext.shouldCheckForImage = true;
     [wkView runMenuSequenceAtPoint:windowPointForTarget(TargetType::Image) preDidCloseMenuHandler:^() {
         EXPECT_EQ(kWKActionMenuImage, [wkView _actionMenuResult].type);
-
-        didFinishDownload = false;
-        performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 2, kWKContextActionItemTagSaveImageToDownloads);
-        Util::run(&didFinishDownload);
+        ensureMenuItemAtIndexOfTypeIsDisabled([wkView _actionMenu], 2, kWKContextActionItemTagSaveImageToDownloads);
     }];
     activeDownloadContext.shouldCheckForImage = false;
 
@@ -689,6 +686,9 @@ TEST(WebKit2, ActionMenusTest)
         performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 0, kWKContextActionItemTagCopyVideoURL);
         NSString *videoURL = watchPasteboardForString();
         EXPECT_WK_STREQ(@"test.mp4", [videoURL lastPathComponent]);
+
+        // Since this video is a local file, it should be disabled.
+        ensureMenuItemAtIndexOfTypeIsDisabled([wkView _actionMenu], 2, kWKContextActionItemTagSaveVideoToDownloads);
     }];
 
     // Copying a video URL for a non-downloadable video should result in copying the page URL instead.