Bug 1720353: Implement new navigator.{plugins,mimeTypes,pdfViewerSupported} specs r=peterv

This implements the new HTML spec for these fields, which now serve hard-coded values, depending on whether or not PDFs are supported.  The values were deemed important to maintain web compatibility.  The spec can be found in section 8.9.1.6:

https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewing-support

The web-compat test for this can be found at:

https://wpt.live/html/webappapis/system-state-and-capabilities/the-navigator-object/plugins-and-mimetypes.html

This patch follows the spec for the PDF plugins if "pdfjs.disabled" is false.  It also produces empty plugin arrays if "pdfjs.disabled" is true, as per the spec.  Both cases are tested by the wpt.live page.

Differential Revision: https://phabricator.services.mozilla.com/D133291
This commit is contained in:
David Parks 2022-02-17 01:33:00 +00:00
Родитель 9708c4a152
Коммит af5370612f
16 изменённых файлов: 304 добавлений и 149 удалений

Просмотреть файл

@ -1597,10 +1597,6 @@ pref("toolkit.startup.max_resumed_crashes", 3);
pref("toolkit.winRegisterApplicationRestart", true);
#endif
// Completely disable pdf.js as an option to preview pdfs within firefox.
// Note: if this is not disabled it does not necessarily mean pdf.js is the pdf
// handler just that it is an option.
pref("pdfjs.disabled", false);
// Used by pdf.js to know the first time firefox is run with it installed so it
// can become the default pdf viewer.
pref("pdfjs.firstRun", true);

Просмотреть файл

@ -32,6 +32,7 @@
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/StaticPrefs_pdfjs.h"
#include "mozilla/StaticPrefs_privacy.h"
#include "mozilla/StorageAccess.h"
#include "mozilla/Telemetry.h"
@ -140,7 +141,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Navigator)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Navigator)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMimeTypes)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPlugins)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPermissions)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGeolocation)
@ -172,11 +172,7 @@ void Navigator::Invalidate() {
// Don't clear mWindow here so we know we've got a non-null mWindow
// until we're unlinked.
mMimeTypes = nullptr;
if (mPlugins) {
mPlugins = nullptr;
}
mPlugins = nullptr;
mPermissions = nullptr;
@ -472,15 +468,12 @@ void Navigator::GetProductSub(nsAString& aProductSub) {
}
nsMimeTypeArray* Navigator::GetMimeTypes(ErrorResult& aRv) {
if (!mMimeTypes) {
if (!mWindow) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
mMimeTypes = new nsMimeTypeArray(mWindow);
auto* plugins = GetPlugins(aRv);
if (!plugins) {
return nullptr;
}
return mMimeTypes;
return plugins->MimeTypeArray();
}
nsPluginArray* Navigator::GetPlugins(ErrorResult& aRv) {
@ -489,12 +482,14 @@ nsPluginArray* Navigator::GetPlugins(ErrorResult& aRv) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
mPlugins = new nsPluginArray(mWindow);
mPlugins = MakeRefPtr<nsPluginArray>(mWindow);
}
return mPlugins;
}
bool Navigator::PdfViewerEnabled() { return !StaticPrefs::pdfjs_disabled(); }
Permissions* Navigator::GetPermissions(ErrorResult& aRv) {
if (!mWindow) {
aRv.Throw(NS_ERROR_UNEXPECTED);

Просмотреть файл

@ -125,6 +125,7 @@ class Navigator final : public nsISupports, public nsWrapperCache {
ErrorResult& aRv);
nsMimeTypeArray* GetMimeTypes(ErrorResult& aRv);
nsPluginArray* GetPlugins(ErrorResult& aRv);
bool PdfViewerEnabled();
Permissions* GetPermissions(ErrorResult& aRv);
void GetDoNotTrack(nsAString& aResult);
bool GlobalPrivacyControl();
@ -265,7 +266,6 @@ class Navigator final : public nsISupports, public nsWrapperCache {
return mWindow ? mWindow->GetDocShell() : nullptr;
}
RefPtr<nsMimeTypeArray> mMimeTypes;
RefPtr<nsPluginArray> mPlugins;
RefPtr<Permissions> mPermissions;
RefPtr<Geolocation> mGeolocation;

Просмотреть файл

@ -8,6 +8,9 @@
#include "mozilla/dom/MimeTypeArrayBinding.h"
#include "mozilla/dom/MimeTypeBinding.h"
#include "nsPluginArray.h"
#include "mozilla/StaticPrefs_pdfjs.h"
#include "nsContentUtils.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -19,10 +22,13 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsMimeTypeArray)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsMimeTypeArray, mWindow)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsMimeTypeArray, mWindow, mMimeTypes[0],
mMimeTypes[1])
nsMimeTypeArray::nsMimeTypeArray(nsPIDOMWindowInner* aWindow)
: mWindow(aWindow) {}
nsMimeTypeArray::nsMimeTypeArray(
nsPIDOMWindowInner* aWindow,
const mozilla::Array<RefPtr<nsMimeType>, 2>& aMimeTypes)
: mWindow(aWindow), mMimeTypes(aMimeTypes) {}
nsMimeTypeArray::~nsMimeTypeArray() = default;
@ -36,7 +42,62 @@ nsPIDOMWindowInner* nsMimeTypeArray::GetParentObject() const {
return mWindow;
}
nsMimeType* nsMimeTypeArray::IndexedGetter(uint32_t aIndex, bool& aFound) {
if (!ForceNoPlugins() && aIndex < ArrayLength(mMimeTypes)) {
aFound = true;
return mMimeTypes[aIndex];
}
aFound = false;
return nullptr;
}
nsMimeType* nsMimeTypeArray::NamedGetter(const nsAString& aName, bool& aFound) {
if (ForceNoPlugins()) {
aFound = false;
return nullptr;
}
for (const auto& mimeType : mMimeTypes) {
if (mimeType->Name().Equals(aName)) {
aFound = true;
return mimeType;
}
}
aFound = false;
return nullptr;
}
void nsMimeTypeArray::GetSupportedNames(nsTArray<nsString>& retval) {
if (ForceNoPlugins()) {
return;
}
for (auto& mimeType : mMimeTypes) {
retval.AppendElement(mimeType->Name());
}
}
/* static */
bool nsMimeTypeArray::ForceNoPlugins() {
return StaticPrefs::pdfjs_disabled() ||
nsContentUtils::ShouldResistFingerprinting();
}
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsMimeType, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsMimeType, Release)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsMimeType)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsMimeType, mPluginElement)
nsMimeType::nsMimeType(nsPluginElement* aPluginElement, const nsAString& aName)
: mPluginElement(aPluginElement), mName(aName) {
MOZ_ASSERT(aPluginElement);
}
nsMimeType::~nsMimeType() = default;
JSObject* nsMimeType::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return MimeType_Binding::Wrap(aCx, this, aGivenProto);
}

Просмотреть файл

@ -17,11 +17,15 @@ class nsMimeType;
class nsPluginElement;
/**
* Array class backing HTML's navigator.mimeTypes. This array is always empty.
* Array class backing HTML's navigator.mimeTypes. This always holds
* references to the hard-coded set of PDF MIME types defined by HTML but it
* only consults them if "pdfjs.disabled" is false. There is never more
* than one of these per DOM window.
*/
class nsMimeTypeArray final : public nsISupports, public nsWrapperCache {
public:
explicit nsMimeTypeArray(nsPIDOMWindowInner* aWindow);
nsMimeTypeArray(nsPIDOMWindowInner* aWindow,
const mozilla::Array<RefPtr<nsMimeType>, 2>& aMimeTypes);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsMimeTypeArray)
@ -31,69 +35,80 @@ class nsMimeTypeArray final : public nsISupports, public nsWrapperCache {
JS::Handle<JSObject*> aGivenProto) override;
// MimeTypeArray WebIDL methods
nsMimeType* Item(uint32_t index) { return nullptr; }
uint32_t Length() { return ForceNoPlugins() ? 0 : ArrayLength(mMimeTypes); }
nsMimeType* NamedItem(const nsAString& name) { return nullptr; }
nsMimeType* IndexedGetter(uint32_t index, bool& found) { return nullptr; }
nsMimeType* NamedGetter(const nsAString& name, bool& found) {
return nullptr;
nsMimeType* Item(uint32_t aIndex) {
bool unused;
return IndexedGetter(aIndex, unused);
}
uint32_t Length() { return 0; }
nsMimeType* NamedItem(const nsAString& aName) {
bool unused;
return NamedGetter(aName, unused);
}
void GetSupportedNames(nsTArray<nsString>& retval) {}
nsMimeType* IndexedGetter(uint32_t index, bool& found);
nsMimeType* NamedGetter(const nsAString& name, bool& found);
void GetSupportedNames(nsTArray<nsString>& retval);
protected:
virtual ~nsMimeTypeArray();
static bool ForceNoPlugins();
nsCOMPtr<nsPIDOMWindowInner> mWindow;
mozilla::Array<RefPtr<nsMimeType>, 2> mMimeTypes;
};
/**
* Mime type class backing entries in HTML's navigator.mimeTypes array.
* Currently, these cannot be constructed.
* Mime type class backing entries in HTML's navigator.mimeTypes array. There
* is a fixed set of these, as defined by HTML.
*/
class nsMimeType final : public nsWrapperCache {
public:
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsMimeType)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsMimeType)
// Never constructed.
nsMimeType() = delete;
nsMimeType(nsPluginElement* aPluginElement, const nsAString& aName);
nsPIDOMWindowInner* GetParentObject() const {
MOZ_ASSERT_UNREACHABLE("nsMimeType can not exist");
return nullptr;
}
nsPluginElement* GetParentObject() const { return mPluginElement; }
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override {
MOZ_ASSERT_UNREACHABLE("nsMimeType can not exist");
return nullptr;
}
JS::Handle<JSObject*> aGivenProto) override;
// MimeType WebIDL methods
void GetDescription(nsString& retval) const {
MOZ_ASSERT_UNREACHABLE("nsMimeType can not exist");
void GetDescription(mozilla::dom::DOMString& retval) const {
retval.SetKnownLiveString(kMimeDescription);
}
nsPluginElement* GetEnabledPlugin() const {
MOZ_ASSERT_UNREACHABLE("nsMimeType can not exist");
return nullptr;
already_AddRefed<nsPluginElement> EnabledPlugin() const {
return do_AddRef(mPluginElement);
}
void GetSuffixes(nsString& retval) const {
MOZ_ASSERT_UNREACHABLE("nsMimeType can not exist");
void GetSuffixes(mozilla::dom::DOMString& retval) const {
retval.SetKnownLiveString(kMimeSuffix);
}
void GetType(nsString& retval) const {
MOZ_ASSERT_UNREACHABLE("nsMimeType can not exist");
}
void GetType(nsString& retval) const { retval = mName; }
const nsString& Name() const { return mName; }
protected:
virtual ~nsMimeType() = default;
virtual ~nsMimeType();
static constexpr nsLiteralString kMimeDescription =
u"Portable Document Format"_ns;
static constexpr nsLiteralString kMimeSuffix = u"pdf"_ns;
// Note that this creates an explicit reference cycle:
//
// nsMimeType -> nsPluginElement -> nsPluginArray ->
// nsMimeTypeArray -> nsMimeType
//
// We rely on the cycle collector to break this cycle.
RefPtr<nsPluginElement> mPluginElement;
nsString mName;
};
#endif /* nsMimeTypeArray_h___ */

Просмотреть файл

@ -8,13 +8,44 @@
#include "mozilla/dom/PluginArrayBinding.h"
#include "mozilla/dom/PluginBinding.h"
#include "mozilla/StaticPrefs_pdfjs.h"
#include "nsMimeTypeArray.h"
#include "nsPIDOMWindow.h"
#include "nsContentUtils.h"
using namespace mozilla;
using namespace mozilla::dom;
nsPluginArray::nsPluginArray(nsPIDOMWindowInner* aWindow) : mWindow(aWindow) {}
// These plugin and mime types are hard-coded by the HTML spec.
// The "main" plugin name is used with the only plugin that is
// referenced by MIME types (via nsMimeType::GetEnabledPlugin).
// The "extra" of the plugin names are associated with MIME types that
// reference the main plugin.
// This is all defined in the HTML spec, section 8.9.1.6
// "PDF Viewing Support".
static const nsLiteralString kMainPluginName = u"PDF Viewer"_ns;
static const nsLiteralString kExtraPluginNames[] = {
u"Chrome PDF Viewer"_ns, u"Chromium PDF Viewer"_ns,
u"Microsoft Edge PDF Viewer"_ns, u"WebKit built-in PDF"_ns};
static const nsLiteralString kMimeTypeNames[] = {u"application/pdf"_ns,
u"text/pdf"_ns};
nsPluginArray::nsPluginArray(nsPIDOMWindowInner* aWindow) : mWindow(aWindow) {
// Create the hard-coded PDF plugin types that share MIME type arrays.
mPlugins[0] = MakeRefPtr<nsPluginElement>(this, aWindow, kMainPluginName);
mozilla::Array<RefPtr<nsMimeType>, 2> mimeTypes;
for (uint32_t i = 0; i < ArrayLength(kMimeTypeNames); ++i) {
mimeTypes[i] = MakeRefPtr<nsMimeType>(mPlugins[0], kMimeTypeNames[i]);
}
mMimeTypeArray = MakeRefPtr<nsMimeTypeArray>(aWindow, mimeTypes);
for (uint32_t i = 0; i < ArrayLength(kExtraPluginNames); ++i) {
mPlugins[i + 1] =
MakeRefPtr<nsPluginElement>(this, aWindow, kExtraPluginNames[i]);
}
}
nsPluginArray::~nsPluginArray() = default;
@ -28,6 +59,50 @@ JSObject* nsPluginArray::WrapObject(JSContext* aCx,
return PluginArray_Binding::Wrap(aCx, this, aGivenProto);
}
nsPluginElement* nsPluginArray::IndexedGetter(uint32_t aIndex, bool& aFound) {
if (!ForceNoPlugins() && aIndex < ArrayLength(mPlugins)) {
aFound = true;
return mPlugins[aIndex];
}
aFound = false;
return nullptr;
}
nsPluginElement* nsPluginArray::NamedGetter(const nsAString& aName,
bool& aFound) {
if (ForceNoPlugins()) {
aFound = false;
return nullptr;
}
for (const auto& plugin : mPlugins) {
if (plugin->Name().Equals(aName)) {
aFound = true;
return plugin;
}
}
aFound = false;
return nullptr;
}
void nsPluginArray::GetSupportedNames(nsTArray<nsString>& aRetval) {
if (ForceNoPlugins()) {
return;
}
for (auto& plugin : mPlugins) {
aRetval.AppendElement(plugin->Name());
}
}
/* static */
bool nsPluginArray::ForceNoPlugins() {
return StaticPrefs::pdfjs_disabled() ||
nsContentUtils::ShouldResistFingerprinting();
}
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsPluginArray)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsPluginArray)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsPluginArray)
@ -36,10 +111,39 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsPluginArray)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_WEAK(nsPluginArray, mWindow)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_WEAK(nsPluginArray, mPlugins[0],
mPlugins[1], mPlugins[2],
mPlugins[3], mPlugins[4],
mMimeTypeArray, mWindow)
// nsPluginElement implementation.
nsPluginElement::nsPluginElement(nsPluginArray* aPluginArray,
nsPIDOMWindowInner* aWindow,
const nsAString& aName)
: mPluginArray(aPluginArray), mWindow(aWindow), mName(aName) {}
nsPluginArray* nsPluginElement::GetParentObject() const { return mPluginArray; }
JSObject* nsPluginElement::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return Plugin_Binding::Wrap(aCx, this, aGivenProto);
}
nsMimeType* nsPluginElement::IndexedGetter(uint32_t aIndex, bool& aFound) {
return MimeTypeArray()->IndexedGetter(aIndex, aFound);
}
nsMimeType* nsPluginElement::NamedGetter(const nsAString& aName, bool& aFound) {
return MimeTypeArray()->NamedGetter(aName, aFound);
}
void nsPluginElement::GetSupportedNames(nsTArray<nsString>& retval) {
return MimeTypeArray()->GetSupportedNames(retval);
}
uint32_t nsPluginElement::Length() { return MimeTypeArray()->Length(); }
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsPluginElement)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsPluginElement)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsPluginElement)
@ -47,4 +151,4 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsPluginElement)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsPluginElement)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsPluginElement, mWindow, mPluginArray)

Просмотреть файл

@ -15,14 +15,14 @@
class nsPIDOMWindowInner;
class nsPluginElement;
class nsMimeTypeArray;
class nsMimeType;
namespace mozilla::dom {
enum class CallerType : uint32_t;
} // namespace mozilla::dom
/**
* Array class backing HTML's navigator.plugins. This array is always empty.
* Array class backing HTML's navigator.plugins. This always holds references
* to the hard-coded set of PDF plugins defined by HTML but it only consults
* them if "pdfjs.disabled" is false. There is never more than one of these
* per DOM window.
*/
class nsPluginArray final : public nsSupportsWeakReference,
public nsWrapperCache {
@ -35,108 +35,99 @@ class nsPluginArray final : public nsSupportsWeakReference,
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
nsMimeTypeArray* MimeTypeArray() { return mMimeTypeArray; }
// PluginArray WebIDL methods
void Refresh(bool aReloadDocuments) {}
uint32_t Length() { return ForceNoPlugins() ? 0 : ArrayLength(mPlugins); }
nsPluginElement* Item(uint32_t aIndex, mozilla::dom::CallerType aCallerType) {
return nullptr;
nsPluginElement* Item(uint32_t aIndex) {
bool unused;
return IndexedGetter(aIndex, unused);
}
nsPluginElement* NamedItem(const nsAString& aName,
mozilla::dom::CallerType aCallerType) {
return nullptr;
nsPluginElement* NamedItem(const nsAString& aName) {
bool unused;
return NamedGetter(aName, unused);
}
uint32_t Length(mozilla::dom::CallerType aCallerType) { return 0; }
nsPluginElement* IndexedGetter(uint32_t aIndex, bool& aFound);
nsPluginElement* IndexedGetter(uint32_t aIndex, bool& aFound,
mozilla::dom::CallerType aCallerType) {
return nullptr;
}
nsPluginElement* NamedGetter(const nsAString& aName, bool& aFound);
nsPluginElement* NamedGetter(const nsAString& aName, bool& aFound,
mozilla::dom::CallerType aCallerType) {
return nullptr;
}
void GetSupportedNames(nsTArray<nsString>& aRetval);
void GetSupportedNames(nsTArray<nsString>& aRetval,
mozilla::dom::CallerType aCallerType) {}
void Refresh() {}
private:
virtual ~nsPluginArray();
static bool ForceNoPlugins();
RefPtr<nsMimeTypeArray> mMimeTypeArray;
nsCOMPtr<nsPIDOMWindowInner> mWindow;
mozilla::Array<RefPtr<nsPluginElement>, 5> mPlugins;
};
/**
* Plugin class backing entries in HTML's navigator.plugins array.
* Currently, these cannot be constructed.
* Plugin class backing entries in HTML's navigator.plugins array. There is
* a fixed set of these, as defined by HTML.
*/
class nsPluginElement final : public nsISupports, public nsWrapperCache {
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsPluginElement)
nsPluginElement() = delete;
explicit nsPluginElement(nsPluginArray* aPluginArray,
nsPIDOMWindowInner* aWindow, const nsAString& aName);
nsPIDOMWindowInner* GetParentObject() const {
MOZ_ASSERT_UNREACHABLE("nsMimeType can not exist");
return nullptr;
}
nsPluginArray* GetParentObject() const;
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override {
MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist");
return nullptr;
}
JS::Handle<JSObject*> aGivenProto) override;
// Plugin WebIDL methods
void GetDescription(nsString& retval) const {
MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist");
}
void GetDescription(nsString& retval) const { retval = kDescription; }
void GetFilename(nsString& retval) const {
MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist");
}
void GetFilename(nsString& retval) const { retval = kFilename; }
void GetVersion(nsString& retval) const {
MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist");
}
void GetName(nsString& retval) const {
MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist");
}
void GetName(nsString& retval) const { retval = mName; }
const nsString& Name() const { return mName; }
nsMimeType* Item(uint32_t index) {
MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist");
return nullptr;
bool unused;
return IndexedGetter(index, unused);
}
nsMimeType* NamedItem(const nsAString& name) {
MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist");
return nullptr;
}
uint32_t Length() {
MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist");
return 0;
bool unused;
return NamedGetter(name, unused);
}
nsMimeType* IndexedGetter(uint32_t index, bool& found) {
MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist");
return nullptr;
}
uint32_t Length();
nsMimeType* NamedGetter(const nsAString& name, bool& found) {
MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist");
return nullptr;
}
nsMimeType* IndexedGetter(uint32_t index, bool& found);
void GetSupportedNames(nsTArray<nsString>& retval) {
MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist");
}
nsMimeType* NamedGetter(const nsAString& name, bool& found);
void GetSupportedNames(nsTArray<nsString>& retval);
protected:
virtual ~nsPluginElement() = default;
nsMimeTypeArray* MimeTypeArray() { return mPluginArray->MimeTypeArray(); }
static constexpr nsLiteralString kDescription =
u"Portable Document Format"_ns;
static constexpr nsLiteralString kFilename = u"internal-pdf-viewer"_ns;
// Note that this creates an explicit reference cycle:
//
// nsPluginElement -> nsPluginArray -> nsPluginElement
//
// We rely on the cycle collector to break this cycle.
RefPtr<nsPluginArray> mPluginArray;
nsCOMPtr<nsPIDOMWindowInner> mWindow;
nsString mName;
};
#endif /* nsPluginArray_h___ */

Просмотреть файл

@ -6,8 +6,8 @@
[Exposed=Window]
interface MimeType {
readonly attribute DOMString description;
readonly attribute Plugin? enabledPlugin;
readonly attribute DOMString suffixes;
readonly attribute DOMString type;
readonly attribute DOMString description;
readonly attribute DOMString suffixes;
readonly attribute Plugin enabledPlugin;
};

Просмотреть файл

@ -8,7 +8,6 @@
Exposed=Window]
interface MimeTypeArray {
readonly attribute unsigned long length;
getter MimeType? item(unsigned long index);
getter MimeType? namedItem(DOMString name);
};

Просмотреть файл

@ -105,13 +105,12 @@ partial interface Navigator {
readonly attribute Permissions permissions;
};
// Things that definitely need to be in the spec and and are not for some
// reason. See https://www.w3.org/Bugs/Public/show_bug.cgi?id=22406
partial interface Navigator {
[Throws]
[Throws, SameObject]
readonly attribute MimeTypeArray mimeTypes;
[Throws]
[Throws, SameObject]
readonly attribute PluginArray plugins;
readonly attribute boolean pdfViewerEnabled;
};
// http://www.w3.org/TR/tracking-dnt/ sort of

Просмотреть файл

@ -9,7 +9,6 @@
interface Plugin {
readonly attribute DOMString description;
readonly attribute DOMString filename;
readonly attribute DOMString version;
readonly attribute DOMString name;
readonly attribute unsigned long length;

Просмотреть файл

@ -7,13 +7,8 @@
[LegacyUnenumerableNamedProperties,
Exposed=Window]
interface PluginArray {
[NeedsCallerType]
void refresh();
readonly attribute unsigned long length;
[NeedsCallerType]
getter Plugin? item(unsigned long index);
[NeedsCallerType]
getter Plugin? namedItem(DOMString name);
void refresh(optional boolean reloadDocuments = false);
};

Просмотреть файл

@ -10837,6 +10837,15 @@
value: 5000
mirror: always
#---------------------------------------------------------------------------
# Prefs starting with "pdfjs."
#---------------------------------------------------------------------------
- name: pdfjs.disabled
type: bool
value: false
mirror: always
#---------------------------------------------------------------------------
# Prefs starting with "permissions."
#---------------------------------------------------------------------------

Просмотреть файл

@ -64,6 +64,7 @@ pref_groups = [
"network",
"nglayout",
"page_load",
"pdfjs",
"permissions",
"plain_text",
"plugin",

Просмотреть файл

@ -424,12 +424,6 @@ prefs: [dom.security.featurePolicy.experimental.enabled:true, dom.security.featu
[OffscreenCanvasRenderingContext2D interface: operation roundRect(unrestricted double, unrestricted double, unrestricted double, unrestricted double, sequence<(unrestricted double or DOMPointInit)>)]
expected: FAIL
[Navigator interface: attribute pdfViewerEnabled]
expected: FAIL
[Navigator interface: window.navigator must inherit property "pdfViewerEnabled" with the proper type]
expected: FAIL
[SVGElement interface: attribute oncontextlost]
expected: FAIL

Просмотреть файл

@ -1,3 +0,0 @@
[plugins-and-mimetypes.html]
[navigator.pdfViewerEnabled exists]
expected: FAIL