Changeset 265160 in webkit


Ignore:
Timestamp:
Jul 31, 2020 3:14:04 PM (4 years ago)
Author:
beidson@apple.com
Message:

Log a warning to the dev console when gamepads are accessed from an insecure context.
https://bugs.webkit.org/show_bug.cgi?id=214995

Reviewed by Tim Horton.

Source/WebCore:

Test: http/tests/misc/gamepads-insecure.html

  • Modules/gamepad/NavigatorGamepad.cpp:

(WebCore::NavigatorGamepad::getGamepads): Insecure contexts should log that getGamepads() will

be going away in a future release. Just do it once, because getGamepads() is called frequently.

LayoutTests:

  • http/tests/misc/gamepads-insecure-expected.txt: Added.
  • http/tests/misc/gamepads-insecure.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r265157 r265160  
     12020-07-31  Brady Eidson  <beidson@apple.com>
     2
     3        Log a warning to the dev console when gamepads are accessed from an insecure context.
     4        https://bugs.webkit.org/show_bug.cgi?id=214995
     5
     6        Reviewed by Tim Horton.
     7
     8        * http/tests/misc/gamepads-insecure-expected.txt: Added.
     9        * http/tests/misc/gamepads-insecure.html: Added.
     10
    1112020-07-31  Aditya Keerthi  <akeerthi@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r265157 r265160  
     12020-07-31  Brady Eidson  <beidson@apple.com>
     2
     3        Log a warning to the dev console when gamepads are accessed from an insecure context.
     4        https://bugs.webkit.org/show_bug.cgi?id=214995
     5
     6        Reviewed by Tim Horton.
     7
     8        Test: http/tests/misc/gamepads-insecure.html
     9
     10        * Modules/gamepad/NavigatorGamepad.cpp:
     11        (WebCore::NavigatorGamepad::getGamepads): Insecure contexts should log that getGamepads() will
     12          be going away in a future release. Just do it once, because getGamepads() is called frequently.
     13
    1142020-07-31  Aditya Keerthi  <akeerthi@apple.com>
    215
  • trunk/Source/WebCore/Modules/gamepad/NavigatorGamepad.cpp

    r248846 r265160  
    2929#if ENABLE(GAMEPAD)
    3030
     31#include "DOMWindow.h"
    3132#include "Gamepad.h"
    3233#include "GamepadManager.h"
     
    7475const Vector<RefPtr<Gamepad>>& NavigatorGamepad::getGamepads(Navigator& navigator)
    7576{
     77    auto* domWindow = navigator.window();
     78    Document* document = domWindow ? domWindow->document() : nullptr;
     79    if (!document) {
     80        static NeverDestroyed<Vector<RefPtr<Gamepad>>> emptyGamepads;
     81        return emptyGamepads;
     82    }
     83
     84    if (!document->isSecureContext()) {
     85        static std::once_flag onceFlag;
     86        std::call_once(onceFlag, [document] {
     87            document->addConsoleMessage(MessageSource::Security, MessageLevel::Warning, "Navigator.getGamepads() will be removed from insecure contexts in a future release"_s);
     88        });
     89
     90    }
     91
    7692    return NavigatorGamepad::from(&navigator)->gamepads();
    7793}
Note: See TracChangeset for help on using the changeset viewer.