Changeset 247901 in webkit


Ignore:
Timestamp:
Jul 29, 2019 2:07:26 AM (5 years ago)
Author:
Carlos Garcia Campos
Message:

Multiple context menu actions broken for YouTube videos
https://bugs.webkit.org/show_bug.cgi?id=199999

Reviewed by Eric Carlson.

Source/WebCore:

Do not include CopyMediaLinkItem and OpenMediaInNewWindowItem to the context menu when media URL is not
downloadable or the request can't be handled.

  • page/ContextMenuController.cpp:

(WebCore::ContextMenuController::populate):

Tools:

Add a test case to check copy link address, open in new window and download options are not included in the
context menu for non-downloadable media.

  • TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp:

(writeNextChunk):
(serverCallback):
(testContextMenuLiveStream):
(beforeAll):
(afterAll):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247900 r247901  
     12019-07-29  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Multiple context menu actions broken for YouTube videos
     4        https://bugs.webkit.org/show_bug.cgi?id=199999
     5
     6        Reviewed by Eric Carlson.
     7
     8        Do not include CopyMediaLinkItem and OpenMediaInNewWindowItem to the context menu when media URL is not
     9        downloadable or the request can't be handled.
     10
     11        * page/ContextMenuController.cpp:
     12        (WebCore::ContextMenuController::populate):
     13
    1142019-07-28  Commit Queue  <commit-queue@webkit.org>
    215
  • trunk/Source/WebCore/page/ContextMenuController.cpp

    r247416 r247901  
    887887            appendItem(ToggleVideoEnhancedFullscreen, m_contextMenu.get());
    888888#endif
    889             appendItem(*separatorItem(), m_contextMenu.get());
    890             appendItem(CopyMediaLinkItem, m_contextMenu.get());
    891             appendItem(OpenMediaInNewWindowItem, m_contextMenu.get());
    892             if (m_context.hitTestResult().isDownloadableMedia() && loader.client().canHandleRequest(ResourceRequest(mediaURL)))
     889            if (m_context.hitTestResult().isDownloadableMedia() && loader.client().canHandleRequest(ResourceRequest(mediaURL))) {
     890                appendItem(*separatorItem(), m_contextMenu.get());
     891                appendItem(CopyMediaLinkItem, m_contextMenu.get());
     892                appendItem(OpenMediaInNewWindowItem, m_contextMenu.get());
    893893                appendItem(DownloadMediaItem, m_contextMenu.get());
     894            }
    894895        }
    895896
  • trunk/Tools/ChangeLog

    r247898 r247901  
     12019-07-29  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Multiple context menu actions broken for YouTube videos
     4        https://bugs.webkit.org/show_bug.cgi?id=199999
     5
     6        Reviewed by Eric Carlson.
     7
     8        Add a test case to check copy link address, open in new window and download options are not included in the
     9        context menu for non-downloadable media.
     10
     11        * TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp:
     12        (writeNextChunk):
     13        (serverCallback):
     14        (testContextMenuLiveStream):
     15        (beforeAll):
     16        (afterAll):
     17
    1182019-07-28  Tim Horton  <timothy_horton@apple.com>
    219
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp

    r246790 r247901  
    1919
    2020#include "config.h"
     21
     22#include "WebKitTestServer.h"
    2123#include "WebViewTest.h"
    2224#include <wtf/Vector.h>
    2325#include <wtf/glib/GRefPtr.h>
     26
     27static WebKitTestServer* kServer;
    2428
    2529class ContextMenuTest: public WebViewTest {
     
    296300        Video,
    297301        Audio,
     302        VideoLive,
    298303        Editable,
    299304        Selection
     
    391396            iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_AUDIO_TO_DISK, Visible | Enabled);
    392397            break;
     398        case VideoLive:
     399            g_assert_false(webkit_hit_test_result_context_is_link(hitTestResult));
     400            g_assert_false(webkit_hit_test_result_context_is_image(hitTestResult));
     401            g_assert_true(webkit_hit_test_result_context_is_media(hitTestResult));
     402            g_assert_false(webkit_hit_test_result_context_is_editable(hitTestResult));
     403            g_assert_false(webkit_hit_test_result_context_is_selection(hitTestResult));
     404            iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PLAY, Visible | Enabled);
     405            iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_MEDIA_MUTE, Visible | Enabled);
     406            iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_CONTROLS, Visible | Enabled);
     407            iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_LOOP, Visible | Enabled);
     408            iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_ENTER_VIDEO_FULLSCREEN, Visible | Enabled);
     409            break;
    393410        case Editable:
    394411            g_assert_false(webkit_hit_test_result_context_is_link(hitTestResult));
     
    10691086}
    10701087
     1088static void writeNextChunk(SoupMessage* message)
     1089{
     1090    GUniquePtr<char> filePath(g_build_filename(Test::getResourcesDir().data(), "silence.webm", nullptr));
     1091    char* contents;
     1092    gsize contentsLength;
     1093    if (!g_file_get_contents(filePath.get(), &contents, &contentsLength, nullptr)) {
     1094        soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
     1095        soup_message_body_complete(message->response_body);
     1096        return;
     1097    }
     1098
     1099    soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, contents, contentsLength);
     1100    soup_message_body_complete(message->response_body);
     1101}
     1102
     1103static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
     1104{
     1105    if (message->method != SOUP_METHOD_GET) {
     1106        soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
     1107        return;
     1108    }
     1109
     1110    soup_message_set_status(message, SOUP_STATUS_OK);
     1111
     1112    if (g_str_equal(path, "/live-stream")) {
     1113        static const char* html =
     1114            "<html><body>"
     1115            " <video style='position:absolute; left:1; top:1' width='300' height='300'>"
     1116            "  <source src='/live-stream.webm' type='video/webm' />"
     1117            " </video>"
     1118            "</body></html>";
     1119        soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, html, strlen(html));
     1120    } else if (g_str_equal(path, "/live-stream.webm")) {
     1121        soup_message_headers_set_encoding(message->response_headers, SOUP_ENCODING_CHUNKED);
     1122        g_signal_connect(message, "wrote_headers", G_CALLBACK(writeNextChunk), nullptr);
     1123        g_signal_connect(message, "wrote_chunk", G_CALLBACK(writeNextChunk), nullptr);
     1124        return;
     1125    }
     1126
     1127    soup_message_body_complete(message->response_body);
     1128}
     1129
     1130static void testContextMenuLiveStream(ContextMenuDefaultTest* test, gconstpointer)
     1131{
     1132    test->showInWindowAndWaitUntilMapped();
     1133
     1134    test->loadURI(kServer->getURIForPath("/live-stream").data());
     1135    test->waitUntilLoadFinished();
     1136
     1137    test->m_expectedMenuType = ContextMenuDefaultTest::VideoLive;
     1138    test->showContextMenuAtPositionAndWaitUntilFinished(1, 1);
     1139}
     1140
    10711141void beforeAll()
    10721142{
     1143    kServer = new WebKitTestServer();
     1144    kServer->run(serverCallback);
     1145
    10731146    ContextMenuDefaultTest::add("WebKitWebView", "default-menu", testContextMenuDefaultMenu);
    10741147    ContextMenuDefaultTest::add("WebKitWebView", "context-menu-key", testContextMenuKey);
    10751148    ContextMenuDefaultTest::add("WebKitWebView", "popup-event-signal", testPopupEventSignal);
     1149    ContextMenuDefaultTest::add("WebKitWebView", "live-stream", testContextMenuLiveStream);
    10761150    ContextMenuCustomTest::add("WebKitWebView", "populate-menu", testContextMenuPopulateMenu);
    10771151    ContextMenuCustomFullTest::add("WebKitWebView", "custom-menu", testContextMenuCustomMenu);
     
    10851159void afterAll()
    10861160{
    1087 }
     1161    delete kServer;
     1162}
Note: See TracChangeset for help on using the changeset viewer.