Timestamp:
Jun 14, 2020, 7:07:08 PM (5 years ago)
Author:
weinig@apple.com
Message:

[WPT] html/webappapis/system-state-and-capabilities/the-navigator-object/navigator-pluginarray.html fails due to lack of caching of Plugin objects
https://bugs.webkit.org/show_bug.cgi?id=213185

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

  • web-platform-tests/html/webappapis/system-state-and-capabilities/the-navigator-object/navigator-pluginarray-expected.txt:

Update results now that this test passes.

Source/WebCore:

Tests:

  • Updates results for web-platform-tests/html/webappapis/system-state-and-capabilities/the-navigator-object/navigator-pluginarray.html which now passes.
  • Splits up http/tests/plugins/plugin-javascript-access.html, adding http/tests/plugins/plugin-javascript-access-allow-all-plugins.html which tests the internals.setShowAllPlugins(true) case. This was required now that the plugin and mimetype arrays are immutable after creation.

Overhaul web exposed plugin APIs:

  • All DOMPlugin and DOMMimeTypes are now created together (along with the DOMPluginArray and DOMMimeTypeArray) on first access of either navigator.plugins or navigator.mimeTypes.
  • DOMPlugins are created and stored in the DOMPluginArray (fixing the initial lack of caching issue)
  • DOMMimeTypes are created and stored in the DOMMimeTypeArray.
  • DOMPlugins hold a strong reference to their associated DOMMimeType. The DOMMimeType has a weak reference back to the DOMPlugin. This means for a single executation context, we only ever create one DOMPlugin / DOMMimeType for each underlying plugin / mimetype.
  • Update GC so that DOMPlugin and DOMMimeType (in addition to DOMPluginArray and DOMMimeTypeArray which were already doing this) use navigator reachability for their lifetime. This is almost correct, except if we ever implement DOMPluginArray.refresh(false) to match the spec, in which case you could end up with some DOMPlugins and DOMMimeTypes that are marked as reachable when they really are not, but only plugins that were removed. This seems so unlikely to matter that implementing a more strict reachability function seems like the wrong way to go.
  • CMakeLists.txt:
  • DerivedSources-input.xcfilelist:
  • DerivedSources.make:
  • WebCore.xcodeproj/project.pbxproj:

Add NavigatorPlugins.idl

  • loader/SubframeLoader.cpp:

(WebCore::findPluginMIMETypeFromURL):
(WebCore::logPluginRequest):
Simplify and cleanup code making use of the new webVisibleMimeTypes() rather than the
clunky getWebVisibleMimesAndPluginIndices().

  • page/Navigator.cpp:
  • page/Navigator.h:

(WebCore::Navigator::initializePluginAndMIMETypeArrays):
(WebCore::Navigator::plugins):
(WebCore::Navigator::mimeTypes):
Fully initialize Navigator.plugins/mimeTypes on first access of either, following
the specified behavior that they should not change after initial access for a script
execution context. This also ensures we always return the same wrappers for these
objects on multiple accesses, something the spec mandates but we failed to do prior.
In addition, we now correctly sort the plugins by name and mimeTypes by type, also as
specified.

  • page/Navigator.idl:
  • page/NavigatorPlugins.idl: Added.

Split NavigatorPlugins out of Navigator.idl as specified. No functional change but
makes things nicer when we match the spec closer.

  • plugins/DOMMimeType.cpp:

(WebCore::DOMMimeType::DOMMimeType):
(WebCore::DOMMimeType::suffixes const):
(WebCore::DOMMimeType::enabledPlugin const):

  • plugins/DOMMimeType.h:

(WebCore::DOMMimeType::create):
(WebCore::DOMMimeType::navigator):

  • plugins/DOMMimeType.idl:
  • plugins/DOMMimeTypeArray.cpp:

(WebCore::DOMMimeTypeArray::DOMMimeTypeArray):
(WebCore::DOMMimeTypeArray::length const):
(WebCore::DOMMimeTypeArray::item):
(WebCore::DOMMimeTypeArray::namedItem):
(WebCore::DOMMimeTypeArray::supportedPropertyNames):
(WebCore::DOMMimeTypeArray::getPluginData const): Deleted.

  • plugins/DOMMimeTypeArray.h:
  • plugins/DOMPlugin.cpp:

(WebCore::DOMPlugin::DOMPlugin):
(WebCore::DOMPlugin::item):
(WebCore::DOMPlugin::namedItem):
(WebCore::DOMPlugin::supportedPropertyNames):

  • plugins/DOMPlugin.h:
  • plugins/DOMPlugin.idl:
  • plugins/DOMPluginArray.cpp:

(WebCore::DOMPluginArray::DOMPluginArray):
(WebCore::DOMPluginArray::length const):
(WebCore::DOMPluginArray::item):
(WebCore::DOMPluginArray::namedItem):
(WebCore::DOMPluginArray::supportedPropertyNames):
(WebCore::DOMPluginArray::pluginData const): Deleted.

  • plugins/DOMPluginArray.h:

Rather than dynamically accessing plugin information through Page
on each interaction with the DOM plugin objects, we now fully initialize
them on creation, allowing for correct wrapper caching and behavior if
plugins are added / removed (e.g. the arrays should not change).

  • plugins/PluginData.cpp:

(WebCore::PluginData::initPlugins):
(WebCore::PluginData::publiclyVisiblePluginsAndAdditionalWebVisiblePlugins const):
(WebCore::PluginData::webVisibleMimeTypes const):
(WebCore::supportsMimeTypeForPlugins):
(WebCore::PluginData::supportsMimeType const):
(WebCore::PluginData::supportsWebVisibleMimeType const):
(WebCore::PluginData::supportsWebVisibleMimeTypeForURL const):
(WebCore::PluginData::pluginFileForWebVisibleMimeType const):
(WebCore::PluginData::publiclyVisiblePlugins const): Deleted.
(WebCore::PluginData::getWebVisibleMimesAndPluginIndices const): Deleted.
(WebCore::PluginData::getMimesAndPluginIndices const): Deleted.
(WebCore::PluginData::getMimesAndPluginIndiciesForPlugins const): Deleted.
(WebCore::PluginData::getPluginInfoForWebVisibleMimeType const): Deleted.

  • plugins/PluginData.h:

Simplify interface by removing out parameter based getWebVisibleMimesAndPluginIndices
(and helpers) and adding more straigtword alternatives. getWebVisibleMimesAndPluginIndices
was useful for the old DOM plugin model, but now that the arrays are initialized all
together, it no longer provides an optimization. Instead, all callers really just want
a either a list of MimeClassInfos or to know if one is supported under a specific scenario,
so we now just expose that.

Source/WebKit:

  • UIProcess/Plugins/PluginInfoStore.h:

Add missing #include that is now needed due to pruning of unnecessary #includes
in WebCore.

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::pluginSupportsExtension):
Update to use new webVisibleMimeTypes() rather than the clunky getWebVisibleMimesAndPluginIndices().

LayoutTests:

  • http/tests/plugins/plugin-javascript-access-allow-all-plugins-expected.txt: Added.
  • http/tests/plugins/plugin-javascript-access-allow-all-plugins.html: Added.
  • http/tests/plugins/plugin-javascript-access-expected.txt:
  • http/tests/plugins/plugin-javascript-access.html:

Split out internals.setShowAllPlugins(true) part of plugin-javascript-access.html to
allow the test to continue working now that navigator.plugins is immutable after
accessing it.

  • platform/mac-wk1/TestExpectations:
  • platform/mac-wk1/imported/w3c/web-platform-tests/html/webappapis/system-state-and-capabilities/the-navigator-object/navigator-pluginarray-expected.txt: Removed.

Remove imported/w3c/web-platform-tests/html/webappapis/system-state-and-capabilities/the-navigator-object/navigator-pluginarray.html
from TestExpectations now that it passes all the time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/page/Navigator.cpp

    r261412 r263017  
    2626#include "Chrome.h"
    2727#include "CookieJar.h"
     28
    2829#include "DOMMimeTypeArray.h"
     30
    2931#include "DOMPluginArray.h"
    3032#include "Document.h"
     
    196198}
    197199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
    198251DOMPluginArray& Navigator::plugins()
    199252{
     
    202255            ResourceLoadObserver::shared().logNavigatorAPIAccessed(*frame->document(), ResourceLoadStatistics::NavigatorAPI::Plugins);
    203256    }
    204     if (!m_plugins)
    205         m_plugins = DOMPluginArray::create(*this);
     257    initializePluginAndMimeTypeArrays();
    206258    return *m_plugins;
    207259}
     
    213265            ResourceLoadObserver::shared().logNavigatorAPIAccessed(*frame->document(), ResourceLoadStatistics::NavigatorAPI::MimeTypes);
    214266    }
    215     if (!m_mimeTypes)
    216         m_mimeTypes = DOMMimeTypeArray::create(*this);
     267    initializePluginAndMimeTypeArrays();
    217268    return *m_mimeTypes;
    218269}
Note: See TracChangeset for help on using the changeset viewer.