зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1338287 - Make nsIDocument::DocumentFlashClassification accessible from privileged JS r=bz
MozReview-Commit-ID: 1II2puZMub5 --HG-- extra : rebase_source : 2b806b4f1d4e51b72799d79126c402113d5b072e
This commit is contained in:
Родитель
2f91e94e57
Коммит
c1a68c2b4c
|
@ -13048,7 +13048,7 @@ ArrayContainsTable(const nsTArray<nsCString>& aTableArray,
|
|||
* For more information, see
|
||||
* toolkit/components/url-classifier/flash-block-lists.rst
|
||||
*/
|
||||
nsIDocument::FlashClassification
|
||||
FlashClassification
|
||||
nsDocument::PrincipalFlashClassification(bool aIsTopLevel)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -13137,7 +13137,7 @@ nsDocument::PrincipalFlashClassification(bool aIsTopLevel)
|
|||
return FlashClassification::Unknown;
|
||||
}
|
||||
|
||||
nsIDocument::FlashClassification
|
||||
FlashClassification
|
||||
nsDocument::ComputeFlashClassification()
|
||||
{
|
||||
nsCOMPtr<nsIDocShellTreeItem> current = this->GetDocShell();
|
||||
|
@ -13186,7 +13186,7 @@ nsDocument::ComputeFlashClassification()
|
|||
*
|
||||
* This function will NOT return FlashClassification::Unclassified
|
||||
*/
|
||||
nsIDocument::FlashClassification
|
||||
FlashClassification
|
||||
nsDocument::DocumentFlashClassification()
|
||||
{
|
||||
if (mFlashClassification == FlashClassification::Unclassified) {
|
||||
|
|
|
@ -1305,7 +1305,7 @@ protected:
|
|||
|
||||
void UpdateScreenOrientation();
|
||||
|
||||
virtual FlashClassification DocumentFlashClassification() override;
|
||||
virtual mozilla::dom::FlashClassification DocumentFlashClassification() override;
|
||||
|
||||
#define NS_DOCUMENT_NOTIFY_OBSERVERS(func_, params_) \
|
||||
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mObservers, nsIDocumentObserver, \
|
||||
|
@ -1329,11 +1329,11 @@ protected:
|
|||
|
||||
// Retrieves the classification of the Flash plugins in the document based on
|
||||
// the classification lists.
|
||||
FlashClassification PrincipalFlashClassification(bool aIsTopLevel);
|
||||
mozilla::dom::FlashClassification PrincipalFlashClassification(bool aIsTopLevel);
|
||||
|
||||
// Attempts to determine the Flash classification of this page based on the
|
||||
// the classification lists and the classification of parent documents.
|
||||
FlashClassification ComputeFlashClassification();
|
||||
mozilla::dom::FlashClassification ComputeFlashClassification();
|
||||
|
||||
nsTArray<nsIObserver*> mCharSetObservers;
|
||||
|
||||
|
@ -1379,7 +1379,7 @@ protected:
|
|||
// non-null when this document is in fullscreen mode.
|
||||
nsWeakPtr mFullscreenRoot;
|
||||
|
||||
FlashClassification mFlashClassification;
|
||||
mozilla::dom::FlashClassification mFlashClassification;
|
||||
private:
|
||||
static bool CustomElementConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp);
|
||||
|
||||
|
|
|
@ -2893,14 +2893,7 @@ public:
|
|||
|
||||
// For more information on Flash classification, see
|
||||
// toolkit/components/url-classifier/flash-block-lists.rst
|
||||
enum class FlashClassification {
|
||||
Unclassified, // Denotes a classification that has not yet been computed.
|
||||
// Allows for lazy classification.
|
||||
Unknown, // Site is not on the whitelist or blacklist
|
||||
Allowed, // Site is on the Flash whitelist
|
||||
Denied // Site is on the Flash blacklist
|
||||
};
|
||||
virtual FlashClassification DocumentFlashClassification() = 0;
|
||||
virtual mozilla::dom::FlashClassification DocumentFlashClassification() = 0;
|
||||
|
||||
protected:
|
||||
bool GetUseCounter(mozilla::UseCounter aUseCounter)
|
||||
|
|
|
@ -3336,11 +3336,11 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp
|
|||
NS_ENSURE_TRUE(topDoc, false);
|
||||
|
||||
// Check the flash blocking status for this page (this applies to Flash only)
|
||||
nsIDocument::FlashClassification documentClassification = nsIDocument::FlashClassification::Allowed;
|
||||
FlashClassification documentClassification = FlashClassification::Allowed;
|
||||
if (IsFlashMIME(mContentType)) {
|
||||
documentClassification = ownerDoc->DocumentFlashClassification();
|
||||
}
|
||||
if (documentClassification == nsIDocument::FlashClassification::Denied) {
|
||||
if (documentClassification == FlashClassification::Denied) {
|
||||
aReason = eFallbackSuppressed;
|
||||
return false;
|
||||
}
|
||||
|
@ -3413,7 +3413,7 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp
|
|||
|
||||
switch (enabledState) {
|
||||
case nsIPluginTag::STATE_ENABLED:
|
||||
return documentClassification == nsIDocument::FlashClassification::Allowed;
|
||||
return documentClassification == FlashClassification::Allowed;
|
||||
case nsIPluginTag::STATE_CLICKTOPLAY:
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -436,6 +436,20 @@ partial interface Document {
|
|||
[Func="IsChromeOrXBL"] readonly attribute boolean inlineScriptAllowedByCSP;
|
||||
};
|
||||
|
||||
// For more information on Flash classification, see
|
||||
// toolkit/components/url-classifier/flash-block-lists.rst
|
||||
enum FlashClassification {
|
||||
"unclassified", // Denotes a classification that has not yet been computed.
|
||||
// Allows for lazy classification.
|
||||
"unknown", // Site is not on the whitelist or blacklist
|
||||
"allowed", // Site is on the Flash whitelist
|
||||
"denied" // Site is on the Flash blacklist
|
||||
};
|
||||
partial interface Document {
|
||||
[ChromeOnly]
|
||||
readonly attribute FlashClassification documentFlashClassification;
|
||||
};
|
||||
|
||||
Document implements XPathEvaluator;
|
||||
Document implements GlobalEventHandlers;
|
||||
Document implements DocumentAndElementEventHandlers;
|
||||
|
|
|
@ -76,7 +76,8 @@ var testCases = [
|
|||
expectedPluginFallbackType: Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
|
||||
expectedActivated: false,
|
||||
expectedHasRunningPlugin: false,
|
||||
pluginListed: true
|
||||
pluginListed: true,
|
||||
expectedFlashClassification: "unknown"
|
||||
},
|
||||
{
|
||||
name: "Nested unknown domains",
|
||||
|
@ -84,28 +85,32 @@ var testCases = [
|
|||
expectedPluginFallbackType: Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
|
||||
expectedActivated: false,
|
||||
expectedHasRunningPlugin: false,
|
||||
pluginListed: true
|
||||
pluginListed: true,
|
||||
expectedFlashClassification: "unknown"
|
||||
},
|
||||
{
|
||||
name: "Allowed domain",
|
||||
domains: ["http://flashallow.example.com"],
|
||||
expectedActivated: true,
|
||||
expectedHasRunningPlugin: true,
|
||||
pluginListed: true
|
||||
pluginListed: true,
|
||||
expectedFlashClassification: "allowed"
|
||||
},
|
||||
{
|
||||
name: "Allowed nested domain",
|
||||
domains: ["http://example.com", "http://flashallow.example.com"],
|
||||
expectedActivated: true,
|
||||
expectedHasRunningPlugin: true,
|
||||
pluginListed: true
|
||||
pluginListed: true,
|
||||
expectedFlashClassification: "allowed"
|
||||
},
|
||||
{
|
||||
name: "Subdocument of allowed domain",
|
||||
domains: ["http://flashallow.example.com", "http://example.com"],
|
||||
expectedActivated: true,
|
||||
expectedHasRunningPlugin: true,
|
||||
pluginListed: true
|
||||
pluginListed: true,
|
||||
expectedFlashClassification: "allowed"
|
||||
},
|
||||
{
|
||||
name: "Exception to allowed domain",
|
||||
|
@ -113,7 +118,8 @@ var testCases = [
|
|||
expectedPluginFallbackType: Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
|
||||
expectedActivated: false,
|
||||
expectedHasRunningPlugin: false,
|
||||
pluginListed: true
|
||||
pluginListed: true,
|
||||
expectedFlashClassification: "unknown"
|
||||
},
|
||||
{
|
||||
name: "Blocked domain",
|
||||
|
@ -121,7 +127,8 @@ var testCases = [
|
|||
expectedPluginFallbackType: Ci.nsIObjectLoadingContent.PLUGIN_USER_DISABLED,
|
||||
expectedActivated: false,
|
||||
expectedHasRunningPlugin: false,
|
||||
pluginListed: false
|
||||
pluginListed: false,
|
||||
expectedFlashClassification: "denied"
|
||||
},
|
||||
{
|
||||
name: "Nested blocked domain",
|
||||
|
@ -129,7 +136,8 @@ var testCases = [
|
|||
expectedPluginFallbackType: Ci.nsIObjectLoadingContent.PLUGIN_USER_DISABLED,
|
||||
expectedActivated: false,
|
||||
expectedHasRunningPlugin: false,
|
||||
pluginListed: false
|
||||
pluginListed: false,
|
||||
expectedFlashClassification: "denied"
|
||||
},
|
||||
{
|
||||
name: "Subdocument of blocked subdocument",
|
||||
|
@ -137,7 +145,8 @@ var testCases = [
|
|||
expectedPluginFallbackType: Ci.nsIObjectLoadingContent.PLUGIN_USER_DISABLED,
|
||||
expectedActivated: false,
|
||||
expectedHasRunningPlugin: false,
|
||||
pluginListed: false
|
||||
pluginListed: false,
|
||||
expectedFlashClassification: "denied"
|
||||
},
|
||||
{
|
||||
name: "Blocked subdocument nested among in allowed documents",
|
||||
|
@ -145,7 +154,8 @@ var testCases = [
|
|||
expectedPluginFallbackType: Ci.nsIObjectLoadingContent.PLUGIN_USER_DISABLED,
|
||||
expectedActivated: false,
|
||||
expectedHasRunningPlugin: false,
|
||||
pluginListed: false
|
||||
pluginListed: false,
|
||||
expectedFlashClassification: "denied"
|
||||
},
|
||||
{
|
||||
name: "Exception to blocked domain",
|
||||
|
@ -153,7 +163,8 @@ var testCases = [
|
|||
expectedPluginFallbackType: Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
|
||||
expectedActivated: false,
|
||||
expectedHasRunningPlugin: false,
|
||||
pluginListed: true
|
||||
pluginListed: true,
|
||||
expectedFlashClassification: "unknown"
|
||||
},
|
||||
{
|
||||
name: "Sub-document blocked domain in top-level context",
|
||||
|
@ -161,7 +172,8 @@ var testCases = [
|
|||
expectedPluginFallbackType: Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
|
||||
expectedActivated: false,
|
||||
expectedHasRunningPlugin: false,
|
||||
pluginListed: true
|
||||
pluginListed: true,
|
||||
expectedFlashClassification: "unknown"
|
||||
},
|
||||
{
|
||||
name: "Sub-document blocked domain",
|
||||
|
@ -169,7 +181,8 @@ var testCases = [
|
|||
expectedPluginFallbackType: Ci.nsIObjectLoadingContent.PLUGIN_USER_DISABLED,
|
||||
expectedActivated: false,
|
||||
expectedHasRunningPlugin: false,
|
||||
pluginListed: false
|
||||
pluginListed: false,
|
||||
expectedFlashClassification: "denied"
|
||||
},
|
||||
{
|
||||
name: "Sub-document blocked subdocument of an allowed domain",
|
||||
|
@ -177,7 +190,8 @@ var testCases = [
|
|||
expectedPluginFallbackType: Ci.nsIObjectLoadingContent.PLUGIN_USER_DISABLED,
|
||||
expectedActivated: false,
|
||||
expectedHasRunningPlugin: false,
|
||||
pluginListed: false
|
||||
pluginListed: false,
|
||||
expectedFlashClassification: "denied"
|
||||
},
|
||||
{
|
||||
name: "Subdocument of Sub-document blocked domain",
|
||||
|
@ -185,7 +199,8 @@ var testCases = [
|
|||
expectedPluginFallbackType: Ci.nsIObjectLoadingContent.PLUGIN_USER_DISABLED,
|
||||
expectedActivated: false,
|
||||
expectedHasRunningPlugin: false,
|
||||
pluginListed: false
|
||||
pluginListed: false,
|
||||
expectedFlashClassification: "denied"
|
||||
},
|
||||
{
|
||||
name: "Sub-document exception in top-level context",
|
||||
|
@ -193,7 +208,8 @@ var testCases = [
|
|||
expectedPluginFallbackType: Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
|
||||
expectedActivated: false,
|
||||
expectedHasRunningPlugin: false,
|
||||
pluginListed: true
|
||||
pluginListed: true,
|
||||
expectedFlashClassification: "unknown"
|
||||
},
|
||||
{
|
||||
name: "Sub-document blocked domain exception",
|
||||
|
@ -201,7 +217,8 @@ var testCases = [
|
|||
expectedPluginFallbackType: Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
|
||||
expectedActivated: false,
|
||||
expectedHasRunningPlugin: false,
|
||||
pluginListed: true
|
||||
pluginListed: true,
|
||||
expectedFlashClassification: "unknown"
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -249,7 +266,8 @@ function getPluginInfo(browser, depth) {
|
|||
pluginFallbackType: pluginObj.pluginFallbackType,
|
||||
activated: pluginObj.activated,
|
||||
hasRunningPlugin: pluginObj.hasRunningPlugin,
|
||||
listed: ("Shockwave Flash" in win.navigator.plugins)
|
||||
listed: ("Shockwave Flash" in win.navigator.plugins),
|
||||
flashClassification: doc.documentFlashClassification
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -288,6 +306,10 @@ add_task(function* checkFlashBlockLists() {
|
|||
is(pluginInfo.listed, testCase.pluginListed,
|
||||
"Plugin's existance in navigator.plugins should match expected")
|
||||
}
|
||||
if ("expectedFlashClassification" in testCase) {
|
||||
is(pluginInfo.flashClassification, testCase.expectedFlashClassification,
|
||||
"Page's classification should match expected");
|
||||
}
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab);
|
||||
}
|
||||
|
@ -316,6 +338,8 @@ add_task(function* checkFlashBlockDisabled() {
|
|||
ok(pluginInfo.activated, "Plugin should be activated");
|
||||
ok(pluginInfo.hasRunningPlugin, "Plugin should be running");
|
||||
ok(pluginInfo.listed, "Flash should be listed in navigator.plugins");
|
||||
is(pluginInfo.flashClassification, "allowed",
|
||||
"Page's classification should be 'allowed'");
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче