mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-12 06:52:25 +00:00
Bug 767636 - Expose plugin fallback type to extensions. r=josh
This commit is contained in:
parent
d9a9552c16
commit
4d855b443c
@ -112,6 +112,9 @@ function test1() {
|
|||||||
ok("application/x-unknown" in gTestBrowser.missingPlugins, "Test 1, Should know about application/x-unknown");
|
ok("application/x-unknown" in gTestBrowser.missingPlugins, "Test 1, Should know about application/x-unknown");
|
||||||
ok(!("application/x-test" in gTestBrowser.missingPlugins), "Test 1, Should not know about application/x-test");
|
ok(!("application/x-test" in gTestBrowser.missingPlugins), "Test 1, Should not know about application/x-test");
|
||||||
|
|
||||||
|
var pluginNode = gTestBrowser.contentDocument.getElementById("unknown");
|
||||||
|
is(pluginNode.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_UNSUPPORTED, "Test 1, plugin fallback type should be PLUGIN_UNSUPPORTED");
|
||||||
|
|
||||||
var plugin = get_test_plugin();
|
var plugin = get_test_plugin();
|
||||||
ok(plugin, "Should have a test plugin");
|
ok(plugin, "Should have a test plugin");
|
||||||
plugin.disabled = false;
|
plugin.disabled = false;
|
||||||
@ -143,6 +146,7 @@ function test3() {
|
|||||||
|
|
||||||
var pluginNode = gTestBrowser.contentDocument.getElementById("test");
|
var pluginNode = gTestBrowser.contentDocument.getElementById("test");
|
||||||
ok(pluginNode, "Test 3, Found plugin in page");
|
ok(pluginNode, "Test 3, Found plugin in page");
|
||||||
|
is(pluginNode.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_DISABLED, "Test 3, plugin fallback type should be PLUGIN_DISABLED");
|
||||||
var manageLink = gTestBrowser.contentDocument.getAnonymousElementByAttribute(pluginNode, "class", "managePluginsLink");
|
var manageLink = gTestBrowser.contentDocument.getAnonymousElementByAttribute(pluginNode, "class", "managePluginsLink");
|
||||||
ok(manageLink, "Test 3, found 'manage' link in plugin-problem binding");
|
ok(manageLink, "Test 3, found 'manage' link in plugin-problem binding");
|
||||||
|
|
||||||
@ -169,6 +173,8 @@ function test5() {
|
|||||||
ok(gTestBrowser.missingPlugins, "Test 5, Should be a missing plugin list");
|
ok(gTestBrowser.missingPlugins, "Test 5, Should be a missing plugin list");
|
||||||
ok("application/x-test" in gTestBrowser.missingPlugins, "Test 5, Should know about application/x-test");
|
ok("application/x-test" in gTestBrowser.missingPlugins, "Test 5, Should know about application/x-test");
|
||||||
ok(!("application/x-unknown" in gTestBrowser.missingPlugins), "Test 5, Should not know about application/x-unknown");
|
ok(!("application/x-unknown" in gTestBrowser.missingPlugins), "Test 5, Should not know about application/x-unknown");
|
||||||
|
var pluginNode = gTestBrowser.contentDocument.getElementById("test");
|
||||||
|
is(pluginNode.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_BLOCKLISTED, "Test 5, plugin fallback type should be PLUGIN_BLOCKLISTED");
|
||||||
|
|
||||||
prepareTest(test6, gTestRoot + "plugin_both.html");
|
prepareTest(test6, gTestRoot + "plugin_both.html");
|
||||||
}
|
}
|
||||||
@ -210,6 +216,9 @@ function test8() {
|
|||||||
ok(!gTestBrowser.missingPlugins, "Test 8, Should not be a missing plugin list");
|
ok(!gTestBrowser.missingPlugins, "Test 8, Should not be a missing plugin list");
|
||||||
ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser), "Test 8, Should have a click-to-play notification");
|
ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser), "Test 8, Should have a click-to-play notification");
|
||||||
|
|
||||||
|
var pluginNode = gTestBrowser.contentDocument.getElementById("test");
|
||||||
|
is(pluginNode.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY, "Test 8, plugin fallback type should be PLUGIN_CLICK_TO_PLAY");
|
||||||
|
|
||||||
prepareTest(test9a, gTestRoot + "plugin_test2.html");
|
prepareTest(test9a, gTestRoot + "plugin_test2.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,6 +581,7 @@ function test18a() {
|
|||||||
ok(clickToPlayNotification, "Test 18a, Should have a click-to-play notification");
|
ok(clickToPlayNotification, "Test 18a, Should have a click-to-play notification");
|
||||||
var doc = gTestBrowser.contentDocument;
|
var doc = gTestBrowser.contentDocument;
|
||||||
var plugin = doc.getElementById("test");
|
var plugin = doc.getElementById("test");
|
||||||
|
is(plugin.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_UPDATABLE, "Test 18a, plugin fallback type should be PLUGIN_VULNERABLE_UPDATABLE");
|
||||||
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||||
ok(!objLoadingContent.activated, "Test 18a, Plugin should not be activated");
|
ok(!objLoadingContent.activated, "Test 18a, Plugin should not be activated");
|
||||||
var overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
|
var overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
|
||||||
@ -612,6 +622,7 @@ function test18c() {
|
|||||||
ok(clickToPlayNotification, "Test 18c, Should have a click-to-play notification");
|
ok(clickToPlayNotification, "Test 18c, Should have a click-to-play notification");
|
||||||
var doc = gTestBrowser.contentDocument;
|
var doc = gTestBrowser.contentDocument;
|
||||||
var plugin = doc.getElementById("test");
|
var plugin = doc.getElementById("test");
|
||||||
|
is(plugin.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_NO_UPDATE, "Test 18c, plugin fallback type should be PLUGIN_VULNERABLE_NO_UPDATE");
|
||||||
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||||
ok(!objLoadingContent.activated, "Test 18c, Plugin should not be activated");
|
ok(!objLoadingContent.activated, "Test 18c, Plugin should not be activated");
|
||||||
var overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
|
var overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
|
||||||
|
@ -21,7 +21,7 @@ interface nsIURI;
|
|||||||
* This interface represents a content node that loads objects.
|
* This interface represents a content node that loads objects.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
[scriptable, uuid(e3e284a3-b4a8-49ef-af6b-c8c4a158db86)]
|
[scriptable, uuid(a3ca1295-362f-4094-a34f-19af5ebda98c)]
|
||||||
interface nsIObjectLoadingContent : nsISupports
|
interface nsIObjectLoadingContent : nsISupports
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -33,6 +33,29 @@ interface nsIObjectLoadingContent : nsISupports
|
|||||||
const unsigned long TYPE_DOCUMENT = 3;
|
const unsigned long TYPE_DOCUMENT = 3;
|
||||||
const unsigned long TYPE_NULL = 4;
|
const unsigned long TYPE_NULL = 4;
|
||||||
|
|
||||||
|
// The content type is not supported (e.g. plugin not installed)
|
||||||
|
const unsigned long PLUGIN_UNSUPPORTED = 0;
|
||||||
|
// Showing alternate content
|
||||||
|
const unsigned long PLUGIN_ALTERNATE = 1;
|
||||||
|
// The plugin exists, but is disabled
|
||||||
|
const unsigned long PLUGIN_DISABLED = 2;
|
||||||
|
// The plugin is blocklisted and disabled
|
||||||
|
const unsigned long PLUGIN_BLOCKLISTED = 3;
|
||||||
|
// The plugin is considered outdated, but not disabled
|
||||||
|
const unsigned long PLUGIN_OUTDATED = 4;
|
||||||
|
// The plugin has crashed
|
||||||
|
const unsigned long PLUGIN_CRASHED = 5;
|
||||||
|
// Suppressed by security policy
|
||||||
|
const unsigned long PLUGIN_SUPPRESSED = 6;
|
||||||
|
// Blocked by content policy
|
||||||
|
const unsigned long PLUGIN_USER_DISABLED = 7;
|
||||||
|
// The plugin is disabled until the user clicks on it
|
||||||
|
const unsigned long PLUGIN_CLICK_TO_PLAY = 8;
|
||||||
|
// The plugin is vulnerable (update available)
|
||||||
|
const unsigned long PLUGIN_VULNERABLE_UPDATABLE = 9;
|
||||||
|
// The plugin is vulnerable (no update available)
|
||||||
|
const unsigned long PLUGIN_VULNERABLE_NO_UPDATE = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The actual mime type (the one we got back from the network
|
* The actual mime type (the one we got back from the network
|
||||||
* request) for the element.
|
* request) for the element.
|
||||||
@ -105,4 +128,6 @@ interface nsIObjectLoadingContent : nsISupports
|
|||||||
* an <embed> with no src).
|
* an <embed> with no src).
|
||||||
*/
|
*/
|
||||||
readonly attribute nsIURI srcURI;
|
readonly attribute nsIURI srcURI;
|
||||||
|
|
||||||
|
readonly attribute unsigned long pluginFallbackType;
|
||||||
};
|
};
|
||||||
|
@ -2442,6 +2442,14 @@ nsObjectLoadingContent::GetActivated(bool *aActivated)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsObjectLoadingContent::GetPluginFallbackType(PRUint32* aPluginFallbackType)
|
||||||
|
{
|
||||||
|
NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_NOT_AVAILABLE);
|
||||||
|
*aPluginFallbackType = mFallbackType;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
nsObjectLoadingContent::ShouldPlay(FallbackType &aReason)
|
nsObjectLoadingContent::ShouldPlay(FallbackType &aReason)
|
||||||
{
|
{
|
||||||
|
@ -61,20 +61,28 @@ class nsObjectLoadingContent : public nsImageLoadingContent
|
|||||||
eType_Null = TYPE_NULL
|
eType_Null = TYPE_NULL
|
||||||
};
|
};
|
||||||
enum FallbackType {
|
enum FallbackType {
|
||||||
eFallbackUnsupported, // The content type is not supported (e.g. plugin
|
// The content type is not supported (e.g. plugin not installed)
|
||||||
// not installed)
|
eFallbackUnsupported = nsIObjectLoadingContent::PLUGIN_UNSUPPORTED,
|
||||||
eFallbackAlternate, // Showing alternate content
|
// Showing alternate content
|
||||||
eFallbackDisabled, // The plugin exists, but is disabled
|
eFallbackAlternate = nsIObjectLoadingContent::PLUGIN_ALTERNATE,
|
||||||
eFallbackBlocklisted, // The plugin is blocklisted and disabled
|
// The plugin exists, but is disabled
|
||||||
eFallbackOutdated, // The plugin is considered outdated, but not
|
eFallbackDisabled = nsIObjectLoadingContent::PLUGIN_DISABLED,
|
||||||
// disabled
|
// The plugin is blocklisted and disabled
|
||||||
eFallbackCrashed, // The plugin has crashed
|
eFallbackBlocklisted = nsIObjectLoadingContent::PLUGIN_BLOCKLISTED,
|
||||||
eFallbackSuppressed, // Suppressed by security policy
|
// The plugin is considered outdated, but not disabled
|
||||||
eFallbackUserDisabled, // Blocked by content policy
|
eFallbackOutdated = nsIObjectLoadingContent::PLUGIN_OUTDATED,
|
||||||
eFallbackClickToPlay, // The plugin is disabled until the user clicks on
|
// The plugin has crashed
|
||||||
// it
|
eFallbackCrashed = nsIObjectLoadingContent::PLUGIN_CRASHED,
|
||||||
eFallbackVulnerableUpdatable, // The plugin is vulnerable (update avail)
|
// Suppressed by security policy
|
||||||
eFallbackVulnerableNoUpdate // The plugin is vulnerable (no update avail)
|
eFallbackSuppressed = nsIObjectLoadingContent::PLUGIN_SUPPRESSED,
|
||||||
|
// Blocked by content policy
|
||||||
|
eFallbackUserDisabled = nsIObjectLoadingContent::PLUGIN_USER_DISABLED,
|
||||||
|
// The plugin is disabled until the user clicks on it
|
||||||
|
eFallbackClickToPlay = nsIObjectLoadingContent::PLUGIN_CLICK_TO_PLAY,
|
||||||
|
// The plugin is vulnerable (update available)
|
||||||
|
eFallbackVulnerableUpdatable = nsIObjectLoadingContent::PLUGIN_VULNERABLE_UPDATABLE,
|
||||||
|
// The plugin is vulnerable (no update available)
|
||||||
|
eFallbackVulnerableNoUpdate = nsIObjectLoadingContent::PLUGIN_VULNERABLE_NO_UPDATE
|
||||||
};
|
};
|
||||||
|
|
||||||
nsObjectLoadingContent();
|
nsObjectLoadingContent();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user