1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
add_task(function* () {
registerCleanupFunction(function () {
clearAllPluginPermissions();
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
Services.prefs.clearUserPref("plugins.click_to_play");
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
gBrowser.removeCurrentTab();
window.focus();
gTestBrowser = null;
});
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
let newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
gTestBrowser = gBrowser.selectedBrowser;
});
add_task(function* () {
Services.prefs.setBoolPref("plugins.click_to_play", true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
yield promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_small.html");
// Work around for delayed PluginBindingAttached
yield promiseUpdatePluginBindings(gTestBrowser);
yield promisePopupNotification("click-to-play-plugins");
// Expecting a notification bar for hidden plugins
yield promiseForNotificationBar("plugin-hidden", gTestBrowser);
});
add_task(function* () {
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
yield promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_small.html");
// Work around for delayed PluginBindingAttached
yield promiseUpdatePluginBindings(gTestBrowser);
let notificationBox = gBrowser.getNotificationBox(gTestBrowser);
yield promiseForCondition(() => notificationBox.getNotificationWithValue("plugin-hidden") === null);
});
add_task(function* () {
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
yield promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_overlayed.html");
// Work around for delayed PluginBindingAttached
yield promiseUpdatePluginBindings(gTestBrowser);
// Expecting a plugin notification bar when plugins are overlaid.
yield promiseForNotificationBar("plugin-hidden", gTestBrowser);
});
add_task(function* () {
yield promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_overlayed.html");
// Work around for delayed PluginBindingAttached
yield promiseUpdatePluginBindings(gTestBrowser);
yield ContentTask.spawn(gTestBrowser, null, function* () {
let doc = content.document;
let plugin = doc.getElementById("test");
plugin.QueryInterface(Ci.nsIObjectLoadingContent);
Assert.equal(plugin.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
"Test 3b, plugin fallback type should be PLUGIN_CLICK_TO_PLAY");
});
let pluginInfo = yield promiseForPluginInfo("test");
ok(!pluginInfo.activated, "Test 1a, plugin should not be activated");
yield ContentTask.spawn(gTestBrowser, null, function* () {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(!(overlay && overlay.classList.contains("visible")),
"Test 3b, overlay should be hidden.");
});
});
add_task(function* () {
yield promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_positioned.html");
// Work around for delayed PluginBindingAttached
yield promiseUpdatePluginBindings(gTestBrowser);
// Expecting a plugin notification bar when plugins are overlaid offscreen.
yield promisePopupNotification("click-to-play-plugins");
yield promiseForNotificationBar("plugin-hidden", gTestBrowser);
yield ContentTask.spawn(gTestBrowser, null, function* () {
let doc = content.document;
let plugin = doc.getElementById("test");
plugin.QueryInterface(Ci.nsIObjectLoadingContent);
Assert.equal(plugin.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
"Test 4b, plugin fallback type should be PLUGIN_CLICK_TO_PLAY");
});
yield ContentTask.spawn(gTestBrowser, null, function* () {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
Assert.ok(!(overlay && overlay.classList.contains("visible")),
"Test 4b, overlay should be hidden.");
});
});
// Test that the notification bar is getting dismissed when directly activating plugins
// via the doorhanger.
add_task(function* () {
yield promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_small.html");
// Work around for delayed PluginBindingAttached
yield promiseUpdatePluginBindings(gTestBrowser);
// Expecting a plugin notification bar when plugins are overlaid offscreen.
yield promisePopupNotification("click-to-play-plugins");
yield ContentTask.spawn(gTestBrowser, null, function* () {
let doc = content.document;
let plugin = doc.getElementById("test");
plugin.QueryInterface(Ci.nsIObjectLoadingContent);
Assert.equal(plugin.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
"Test 6, Plugin should be click-to-play");
});
yield promisePopupNotification("click-to-play-plugins");
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(notification, "Test 6, Should have a click-to-play notification");
// simulate "always allow"
yield promiseForNotificationShown(notification);
PopupNotifications.panel.firstChild._primaryButton.click();
let notificationBox = gBrowser.getNotificationBox(gTestBrowser);
yield promiseForCondition(() => notificationBox.getNotificationWithValue("plugin-hidden") === null);
let pluginInfo = yield promiseForPluginInfo("test");
ok(pluginInfo.activated, "Test 7, plugin should be activated");
});
|