Bug 1675349: Update tests under dom/plugins/test for the removal of plugins. r=jmathies

ADDED/UPDATED
-------
dom/plugins/test/mochitest/browser_blockallplugins.js
Make sure that all plugin elements use the fallback for removed plugins.

dom/plugins/test/mochitest/test_mixed_case_mime.html
Bug 206659
Test MIME-type case sensitivity using "application/x-Second-Test"
Change to test "image/png".

dom/plugins/test/mochitest/test_plugin_fallback_focus.html
Test that (denying) object/embed focus and focusability are properly maintained when those elements change type to/from plugins.

REMOVED
-------
dom/plugins/test/unit/test_nice_plugin_name.js
bug 838290
Plugin permission string is "nicely" based on plugin lib name.

dom/plugins/test/unit/test_bug471245.js
bug 471245
Something to do with disabled plugins being enabled under some weird condition.

dom/plugins/test/unit/test_bug813245.js
bug 813245
Plugin registry file doesn't cause crash or incorrectly represent real plugin.

dom/plugins/test/unit/test_bug854467.js
bug 854467
PluginTag correctly controls click-to-play behavior.

dom/plugins/test/unit/test_plugin_default_state.js
bug 866390
Click-to-play abides plugin.default.state setting.

dom/plugins/test/unit/test_persist_in_prefs.js
Bug 830267
CTP state is maintained in settings (not pluginreg.dat) and persists regardless of plugin removal

dom/plugins/test/mochitest/test_NPNVdocumentOrigin.html
Bug 622199
Test NPNV connection to DOM properly handles documentOrigin.

dom/plugins/test/mochitest/test_NPPVpluginWantsAllNetworkStreams.html
Test NPPV connection to JS when plugin requests all HTTP stream <body>s (including failed requests)

dom/plugins/test/mochitest/test_bug1028200-*.html
Properly handle fullscreen wrt plugins doing things (like crashing)

dom/plugins/test/unit/test_bug471245.js
Bug 471245
Extensions should not enable inadvertently enable plugins when they consult PluginHost.

dom/plugins/test/unit/test_bug813245.js
Bug 813245
Do not crash when we read a corrupt pluginreg.dat

dom/plugins/test/unit/test_bug854467.js
Bug 854467
Should be able to unset CTP setting in chrome JS.

dom/plugins/test/unit/test_nice_plugin_name.js
Bug 838290
Permission string names for plugins should be pretty and not just based on plugin filename.

dom/plugins/test/unit/test_persist_in_prefs.js
Bug 830267
Persist plugin prefs in user prefs, not pluginreg.dat

dom/plugins/test/unit/test_plugin_default_state.js
Bug 866390
Plugins that use default CTP state should follow changes to the default.  Others should not be affected by changes.

dom/plugins/test/mochitest/test_bug1092842.html
bug 1092842
Plugin clipping around specific HTML element attributes.

dom/plugins/test/mochitest/test_bug1165981.html
bug 1165981
Test non-Flash plugins are blocked

dom/plugins/test/mochitest/test_bug1245545.html
bug 1245545
Test unloading plugins based on `dom.ipc.plugins.unloadTimeoutSecs`

dom/plugins/test/mochitest/test_bug1307694.html
bug 1307694
Test scale and salign attributes musst be processed in an order dependent way.  But salign is no longer supported.  The test uses special testplugin behavior.

dom/plugins/test/mochitest/test_bug532208.html
bug 532208
Test that plugins can handle large streams, using special testplugin behavior.

dom/plugins/test/mochitest/test_bug539565-1.html
dom/plugins/test/mochitest/test_bug539565-2.html
bug 539565
Plugins should get proper mouse coords in the face of CSS transformations

dom/plugins/test/mochitest/test_bug771202.html
bug 771202
Use JS-exported plugin functions after plugin is moved to a subdocument.

dom/plugins/test/mochitest/test_bug777098.html
bug 777098
Test that plugin is properly deleted and a JS exception is thrown when an invalid NPObject (from a dead instance) is passed to a plugin.

dom/plugins/test/mochitest/test_bug784131.html
bug 784131
Plugins should properly stop when they lose their frames (via e.g. `display:none`)

dom/plugins/test/mochitest/test_bug813906.html
bug 813906
Make sure plugins can't access chrome-privileged pages

dom/plugins/test/mochitest/test_bug852315.html
bug 852315
Tests a specific case where JS code that added an element in response to an <embed> event handler would alter a hash table in the midst of iteration, causing a crash.

dom/plugins/test/mochitest/test_bug854082.html
bug 854082
Tests that destroying the plugin's frame inside NPP_New does not cause a crash

dom/plugins/test/mochitest/test_bug863792.htm
bug 863792
Do not leak when a plugin removes itself from the document and inactivates the document in its NPP_New

dom/plugins/test/mochitest/test_bug967694.html
bug 967694
CTP dialog should not spawn plugin inside CTP dialog event.

dom/plugins/test/mochitest/test_bug985859.html
bug 985859
navigator.mimetypes should work as case-insensitive hashmap (there don't seem to be any legal mimetypes left now).

dom/plugins/test/mochitest/test_bug986930.html
bug 986930
Properly handle plugin with non-ASCII mime type.

dom/plugins/test/mochitest/test_copyText.html
Plugins should be able to use the clipboard.

dom/plugins/test/mochitest/test_crash_nested_loop.html
Plugins resulting in a call to PluginCrashed while still on the stack causing a browser crash (non-oop plugins).  So this is ancient (11 years).

dom/plugins/test/mochitest/test_crashing.html
Bug 560213
Test that plugin crashes generate exceptions and do not lead to heap corruption when using JS to call methods on the crashed plugin.

dom/plugins/test/mochitest/test_CrashService_crash.html
dom/plugins/test/mochitest/test_CrashService_hang.html
dom/plugins/test/mochitest/test_x11_error_crash.html
Bug 983313 and bug 1331320
Check that CrashService (which is currently only used by plugin tests) properly detects plugin crash, hang and crashes from X11 errors.

dom/plugins/test/mochitest/test_crashing2.html
Reloading should restore crashed plugin.  Test was already completely disabled.

dom/plugins/test/mochitest/test_defaultValue.html
Bug 679509
Make NPObjects ok to use as a primitve [[DefaultValue]], instead of calling valueOf on the NPObject itself.

dom/plugins/test/mochitest/test_bug751809.html
Bug 751809
Plugin CTP broke plugin input (ancient).

dom/plugins/test/mochitest/browser_bug1335475.js
bug 1335475
Test that plugins aren't available in chrome-privilege, null-principal, and file:// content but are available to http:// and about:blank content

dom/plugins/test/mochitest/browser_data_url_plugin.js
Bug 1381755
Test that data URIs inside iframes can't use plugins

dom/plugins/test/mochitest/browser_bug1196539.js
Test that plugin repaints when it should (and not more than that, modulo OS repaints)

dom/plugins/test/mochitest/test_hidden_plugin.html
Test navigator.plugins, including that disabling plugins removes them from navigator.plugins

dom/plugins/test/mochitest/test_enumerate.html
Test PluginHost's ability to expose plugin's JS API (looks for TestPlugin's SetColor)

dom/plugins/test/mochitest/test_clear_site_data.html
Directly test PluginHost's clearSiteData API.

dom/plugins/test/mochitest/test_instance_re-parent.html
Bug 90268
Test that reparenting plugin instance in DOM before spinning event loop does not destroy or restart it.

dom/plugins/test/mochitest/test_instance_unparent1.html
dom/plugins/test/mochitest/test_instance_unparent2.html
dom/plugins/test/mochitest/test_instance_unparent3.html
Bug 90268
Test that removing plugin from DOM destroys it (1) normally, (2) if reparented and removed in the same event cycle and (3) when its parent is the element that gets removed.

dom/plugins/test/mochitest/test_instantiation.html
Create that plugin is loaded when element is programmatically created (using createElement).

dom/plugins/test/mochitest/test_multipleinstanceobjects.html
Test NPObject access from multiple plugin instances

dom/plugins/test/mochitest/test_newstreamondestroy.html
Test calling NPN_GetURL from NPP_Destroy

dom/plugins/test/mochitest/test_npn_timers.html
Test NPN_Timer

dom/plugins/test/mochitest/test_npobject_getters.html
Test `pluginFoundElement` and `pluginFoundWindow` JS properties set on plugin instance by `NPP_New`.

dom/plugins/test/mochitest/test_npruntime_construct.html
Test that NP plugin JS method `constructObject` properly configures prototype chain

dom/plugins/test/mochitest/test_npruntime_identifiers.html
Test various ways the plugin JS reflection method can convert "identifiers" to JS values.

dom/plugins/test/mochitest/test_npruntime_npnevaluate.html
Test NPN_Evaluate (i.e. plugin executing JS code)

dom/plugins/test/mochitest/test_npruntime_npninvoke.html
Test NPN_Invoke (i.e. plugin calling JS method)

dom/plugins/test/mochitest/test_npruntime_npninvokedefault.html
Test NPN_InvokeDefault (i.e. plugin calling default JS method)

dom/plugins/test/mochitest/test_painting.html
Test invalidation and repaint requests for clipped plugins.

dom/plugins/test/mochitest/test_pluginstream_err.html
Bug 517078
Test that plugin streaming error reporting works

dom/plugins/test/mochitest/test_pluginstream_post.html
dom/plugins/test/mochitest/test_pluginstream_poststream.html
Test NPN_PostURL responds (1) by inserting response into given element or (2) by sending response to plugin with NPN_NewStream.

dom/plugins/test/mochitest/test_bug479979.xhtml
Bug 479979
NPN_SetValue should return error for unknown variables.

dom/plugins/test/mochitest/test_crash_notify.xhtml
dom/plugins/test/mochitest/test_crash_notify_no_report.xhtml
Check event data, crash report/minidump (or not using MOZ_CRASHREPORTER_NO_REPORT), etc for `plugin-crash` event.

dom/plugins/test/mochitest/test_crash_submit.xhtml
dom/plugins/test/mochitest/test_hang_submit.xhtml
Test plugin crash/hang report submission using mock server from toolkit.

dom/plugins/test/mochitest/test_pluginstream_referer.html
Bugs 410904 and 724465
Test NPN_PostURLNotify and NPN_GetURLNotify.

dom/plugins/test/mochitest/test_pluginstream_src.html
Test NPP_NewStream and NPP_DestroyStream using embed tag streammode/streamchunksize parameters.

dom/plugins/test/mochitest/test_pluginstream_src_dynamic.html
Bug 90268
Like test_pluginstream_src.html but using dynamic HTML elements.

dom/plugins/test/mochitest/test_pluginstream_src_referer.html
Bug 737433
Make sure plugin stream data includes the correct referrer (taken from its content)

dom/plugins/test/mochitest/test_propertyAndMethod.html
Test NPObject with property and method with the same name

dom/plugins/test/mochitest/test_queryCSSZoomFactor.htm
Bug 1171182
Test CSS zoom with plugins (handled with NPNVcontentsScaleFactor)

dom/plugins/test/mochitest/test_redirect_handling.html
Test NPN_PostURLNotify and NPN_GetURLNotify URL redirect support.

dom/plugins/test/mochitest/test_secondPlugin.html
Bug 749257
Test navigator.plugins and navigator.mimeTypes (via index and iteration) for proper behavior WRT active, CTP and disabled plugins.

dom/plugins/test/mochitest/test_src_url_change.html
Bug 726734
Changing embed src tag should destroy/restart plugin.

dom/plugins/test/mochitest/test_streamNotify.html
Test that plugin streams properly handle all URLs, including proper errors for malformed URLs.

dom/plugins/test/mochitest/test_streamatclose.html
Any open streams should be notified before NPP_Destroy.

dom/plugins/test/mochitest/test_stringHandling.html
Bug 1106552
Properly handle 0 bytes in strings passed to plugins as NPVariants.

dom/plugins/test/mochitest/test_visibility.html
Make sure plugins respect visibility attribute and issue the correct number of paints.

dom/plugins/test/mochitest/test_zero_opacity.html
Windowed plugins should use clip rect to avoid drawing opacity:0 displays.

dom/plugins/test/mochitest/test_cocoa_window_focus.htm
Test that NPCocoaEventWindowFocusChanged is properly sent for plugin's window

dom/plugins/test/mochitest/test_cocoa_focus.htm
Test that NPCocoaEventFocusChanged is properly sent for plugin's element

dom/plugins/test/mochitest/test_windowed_invalidate.html
Test NPN_Invalidate for windowed plugins

dom/plugins/test/mochitest/test_windowless_flash.htm
Make sure Flash always runs in windowless mode

dom/plugins/test/mochitest/test_windowless_ime.html
Test (windowless) plugins with IME

dom/plugins/test/mochitest/test_busy_hang.xhtml
dom/plugins/test/mochitest/test_idle_hang.xhtml
Test plugin busy/idle detection observers and events

dom/plugins/test/mochitest/test_object.html
Bug 783059
Test plugin "instantiation", mostly by stressing behavior when the plugin's element tags are programmatically updated.

dom/plugins/test/mochitest/test_convertpoint.xhtml
Test coordinate space transformations via NPN_ConvertPoint.

dom/plugins/test/mochitest/test_hangui.xhtml
Test the _plugin hung_ UI.

dom/plugins/test/mochitest/test_npruntime.xhtml
Simple test that npruntime (the JS/plugin bridge) works.

dom/plugins/test/mochitest/test_plugin_tag_clicktoplay.html
Make sure nsIPluginTags click-to-play state properly matches enabledState of plugin (in chrome code)

dom/plugins/test/mochitest/test_privatemode_perwindowpb.xhtml
Check that plugins can properly determine when run in private mode with NPNVprivateModeBool.

dom/plugins/test/mochitest/test_wmode.xhtml
Bad test that ends up checking the constant boolean in testplugin returned by pluginSupportsWindowMode() and "confirming" that mac and Linux don't support windowed mode but Windows does.

dom/plugins/test/mochitest/test_xulbrowser_plugin_visibility.xhtml
Tests that plugins properly get visibility and invalidate messages when in the current or not-current tab.

Differential Revision: https://phabricator.services.mozilla.com/D95910
This commit is contained in:
David Parks 2020-11-18 15:58:15 +00:00
Родитель 187eebabe6
Коммит 90be6e1a12
136 изменённых файлов: 164 добавлений и 8756 удалений

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

@ -455,16 +455,6 @@ module.exports = {
"dom/ipc/test.xhtml",
"dom/ipc/tests/test_process_error.xhtml",
"dom/notification/test/chrome/test_notification_system_principal.xhtml",
"dom/plugins/test/mochitest/test_busy_hang.xhtml",
"dom/plugins/test/mochitest/test_convertpoint.xhtml",
"dom/plugins/test/mochitest/test_crash_notify.xhtml",
"dom/plugins/test/mochitest/test_crash_notify_no_report.xhtml",
"dom/plugins/test/mochitest/test_crash_submit.xhtml",
"dom/plugins/test/mochitest/test_hang_submit.xhtml",
"dom/plugins/test/mochitest/test_hangui.xhtml",
"dom/plugins/test/mochitest/test_idle_hang.xhtml",
"dom/plugins/test/mochitest/test_xulbrowser_plugin_visibility.xhtml",
"dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xhtml",
"dom/security/test/general/test_bug1277803.xhtml",
"dom/serviceworkers/test/test_serviceworkerinfo.xhtml",
"dom/serviceworkers/test/test_serviceworkermanager.xhtml",

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

@ -3,12 +3,12 @@ HTTP load 48856-1.html
HTTP load 110650-1.html
skip-if(!haveTestPlugin) HTTP script 539897-1.html
asserts-if(winWidget&&browserIsRemote,0-1) skip-if(!haveTestPlugin) HTTP script 540114-1.html
HTTP load 570884.html
skip-if(!haveTestPlugin) HTTP load 570884.html
# This test relies on the reading of screenX/Y forcing a round trip to
# the X server, which is a bad assumption for <browser remote>.
# Plugin arch is going to change anyway with OOP content so skipping
# this test for now is OK.
skip-if(!haveTestPlugin||http.platform!="X11") HTTP load 598862.html
HTTP load 626602-1.html
skip-if(!haveTestPlugin) HTTP load 626602-1.html
HTTP load 752340.html
HTTP load 843086.xhtml

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

@ -1,9 +0,0 @@
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<h1>1028200 subpageA</h1>
<iframe id="iframe2" src="1028200-subpageA1.html" width="400" height="400"></iframe>
</body>
</html>

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

@ -1,9 +0,0 @@
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<h1>1028200 subpageA1</h1>
<embed id="plugin1" type="application/x-test" />
</body>
</html>

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

@ -1,9 +0,0 @@
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<h1>1028200 subpageB</h1>
<iframe id="iframe2" src="1028200-subpageB1.html" width="400" height="400"></iframe>
</body>
</html>

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

@ -1,11 +0,0 @@
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<h1>1028200 subpageB1</h1>
<div id="div1">
<embed id="plugin1" type="application/x-test" />
</div>
</body>
</html>

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

@ -1,9 +0,0 @@
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<h1>1028200 subpageC</h1>
<div id="div1"> </div>
</body>
</html>

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

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<object id="object" type="application/x-shockwave-flash"></object>
<embed id="embed" type="application/x-shockwave-flash"></embed>
</body>
</html>

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

@ -2,19 +2,16 @@
prefs =
plugin.load_flash_only=false
support-files =
block_all_plugins.html
head.js
plugin_data_url_test.html
plugin_test.html
plugin_subframe_test.html
plugin_no_scroll_div.html
[browser_blockallplugins.js]
[browser_bug1163570.js]
skip-if = true # Bug 1249878
[browser_bug1196539.js]
skip-if = (!e10s || os != "win" || webrender) # plugin painting test doesn't work with WR
[browser_tabswitchbetweenplugins.js]
skip-if = true #Bug 1538425
[browser_pluginscroll.js]
skip-if = (true || !e10s || os != "win") # Bug 1213631
[browser_bug1335475.js]
[browser_data_url_plugin.js]

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

@ -0,0 +1,66 @@
var gTestRoot = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content/",
"http://127.0.0.1:8888/"
);
add_task(async function() {
registerCleanupFunction(function() {
gBrowser.removeCurrentTab();
window.focus();
});
});
// simple tab load helper, pilfered from browser plugin tests
function promiseTabLoadEvent(tab, url) {
info("Wait tab event: load");
function handle(loadedUrl) {
if (loadedUrl === "about:blank" || (url && loadedUrl !== url)) {
info(`Skipping spurious load event for ${loadedUrl}`);
return false;
}
info("Tab event received: load");
return true;
}
let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, handle);
if (url) {
BrowserTestUtils.loadURI(tab.linkedBrowser, url);
}
return loaded;
}
add_task(async function() {
let pluginTab = (gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser));
await promiseTabLoadEvent(pluginTab, gTestRoot + "block_all_plugins.html");
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
let doc = content.document;
let objectElt = doc.getElementById("object");
Assert.ok(!!objectElt, "object should exist");
Assert.ok(
objectElt instanceof Ci.nsIObjectLoadingContent,
"object should be an nsIObjectLoadingContent"
);
Assert.ok(
objectElt.pluginFallbackType ==
Ci.nsIObjectLoadingContent.PLUGIN_BLOCK_ALL,
"object should be blocked"
);
let embedElt = doc.getElementById("embed");
Assert.ok(!!embedElt, "embed should exist");
Assert.ok(
embedElt instanceof Ci.nsIObjectLoadingContent,
"embed should be an nsIObjectLoadingContent"
);
Assert.ok(
embedElt.pluginFallbackType ==
Ci.nsIObjectLoadingContent.PLUGIN_BLOCK_ALL,
"embed should be blocked"
);
});
});

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

@ -1,167 +0,0 @@
var gTestRoot = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content/",
"http://127.0.0.1:8888/"
);
function checkPaintCount(aCount) {
ok(
aCount != 0,
"paint count can't be greater than zero, count was " + aCount
);
ok(
aCount < kMaxPaints,
"paint count should be within limits, count was " + aCount
);
}
// maximum number of paints we allow before failing. The test plugin doesn't
// animate so this should really be just 1, but operating systems can
// occasionally fire a few of these so we give these tests a fudge factor.
// A bad regression would either be 0, or 100+.
const kMaxPaints = 10;
add_task(async function() {
let result, tabSwitchedPromise;
// We want to make sure that we will paint in cases where we need to. The
// tab layer cache just gets in the way of measuring that.
await SpecialPowers.pushPrefEnv({
set: [["browser.tabs.remote.tabCacheSize", 0]],
});
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
let pluginTab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
gTestRoot + "plugin_test.html"
);
let homeTab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"about:home"
);
result = await SpecialPowers.spawn(
pluginTab.linkedBrowser,
[],
async function() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
return !!plugin;
}
);
is(result, true, "plugin is loaded");
result = await SpecialPowers.spawn(
pluginTab.linkedBrowser,
[],
async function() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
return !XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
}
);
is(result, true, "plugin is hidden");
// reset plugin paint count
await SpecialPowers.spawn(pluginTab.linkedBrowser, [], async function() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
XPCNativeWrapper.unwrap(plugin).resetPaintCount();
});
// select plugin tab
tabSwitchedPromise = waitTabSwitched();
gBrowser.selectedTab = pluginTab;
await tabSwitchedPromise;
// wait a bit for spurious paints
await waitForMs(100);
result = await SpecialPowers.spawn(
pluginTab.linkedBrowser,
[],
async function() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
}
);
is(result, true, "plugin is visible");
// check for good paint count
result = await SpecialPowers.spawn(
pluginTab.linkedBrowser,
[],
async function() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).getPaintCount();
}
);
checkPaintCount(result);
// select home tab
tabSwitchedPromise = waitTabSwitched();
gBrowser.selectedTab = homeTab;
await tabSwitchedPromise;
// reset paint count
await SpecialPowers.spawn(pluginTab.linkedBrowser, [], async function() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
XPCNativeWrapper.unwrap(plugin).resetPaintCount();
});
// wait a bit for spurious paints
await waitForMs(100);
// check for no paint count
result = await SpecialPowers.spawn(
pluginTab.linkedBrowser,
[],
async function() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).getPaintCount();
}
);
is(result, 0, "no paints, this is correct.");
result = await SpecialPowers.spawn(
pluginTab.linkedBrowser,
[],
async function() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
return !XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
}
);
is(result, true, "plugin is hidden");
// reset paint count
await SpecialPowers.spawn(pluginTab.linkedBrowser, [], async function() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
XPCNativeWrapper.unwrap(plugin).resetPaintCount();
});
// select plugin tab
tabSwitchedPromise = waitTabSwitched();
gBrowser.selectedTab = pluginTab;
await tabSwitchedPromise;
// check paint count
result = await SpecialPowers.spawn(
pluginTab.linkedBrowser,
[],
async function() {
let doc = content.document;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).getPaintCount();
}
);
checkPaintCount(result);
gBrowser.removeTab(homeTab);
gBrowser.removeTab(pluginTab);
});

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

@ -1,96 +0,0 @@
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir.replace(
"chrome://mochitests/content/",
"http://127.0.0.1:8888/"
);
add_task(async function() {
is(
navigator.plugins.length,
0,
"plugins should not be available to chrome-privilege pages"
);
ok(
!("application/x-test" in navigator.mimeTypes),
"plugins should not be available to chrome-privilege pages"
);
await BrowserTestUtils.withNewTab(
{ gBrowser, url: "about:blank" },
async function(browser) {
// about:blank triggered from a toplevel load should not inherit permissions
await SpecialPowers.spawn(browser, [], async function() {
is(
content.window.navigator.plugins.length,
0,
"plugins should not be available to null-principal about:blank"
);
ok(
!("application/x-test" in content.window.navigator.mimeTypes),
"plugins should not be available to null-principal about:blank"
);
});
let promise = BrowserTestUtils.browserLoaded(browser);
BrowserTestUtils.loadURI(browser, gTestRoot + "plugin_test.html");
await promise;
await SpecialPowers.spawn(browser, [], async function() {
ok(
content.window.navigator.plugins.length > 0,
"plugins should be available to HTTP-loaded pages"
);
ok(
"application/x-test" in content.window.navigator.mimeTypes,
"plugins should be available to HTTP-loaded pages"
);
let subwindow = content.document.getElementById("subf").contentWindow;
ok(
"application/x-test" in subwindow.navigator.mimeTypes,
"plugins should be available to an about:blank subframe loaded from a site"
);
});
// navigate from the HTTP page to an about:blank page which ought to
// inherit permissions
promise = BrowserTestUtils.browserLoaded(browser);
await SpecialPowers.spawn(browser, [], async function() {
content.document.getElementById("aboutlink").click();
});
await promise;
await SpecialPowers.spawn(browser, [], async function() {
is(
content.window.location.href,
"about:blank",
"sanity-check about:blank load"
);
ok(
"application/x-test" in content.window.navigator.mimeTypes,
"plugins should be available when a site triggers an about:blank load"
);
});
// navigate to the file: URI, which shouldn't allow plugins. This might
// be wrapped in jar:, but that shouldn't matter for this test
promise = BrowserTestUtils.browserLoaded(browser);
let converteduri = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIChromeRegistry)
.convertChromeURL(Services.io.newURI(rootDir + "plugin_test.html"));
BrowserTestUtils.loadURI(browser, converteduri.spec);
await promise;
await SpecialPowers.spawn(browser, [], async function() {
ok(
!("application/x-test" in content.window.navigator.mimeTypes),
"plugins should not be available to file: URI content"
);
});
}
);
// As much as it would be nice, this doesn't actually check ftp:// because
// we don't have a synthetic server.
});

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

@ -1,32 +0,0 @@
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir.replace(
"chrome://mochitests/content/",
"http://127.0.0.1:8888/"
);
add_task(async function() {
is(
navigator.plugins.length,
0,
"plugins should not be available to chrome-privilege pages"
);
await BrowserTestUtils.withNewTab(
{ gBrowser, url: gTestRoot + "plugin_data_url_test.html" },
async function(browser) {
await SpecialPowers.spawn(browser, [], async function() {
ok(
content.window.navigator.plugins.length > 0,
"plugins should be available to HTTP-loaded pages"
);
let dataFrameWin = content.document.getElementById("dataFrame")
.contentWindow;
is(
dataFrameWin.navigator.plugins.length,
0,
"plugins should not be available to data: URI in iframe on a site"
);
});
}
);
});

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

@ -1,35 +0,0 @@
[DEFAULT]
prefs =
plugin.load_flash_only=false
support-files =
hang_test.js
privatemode_perwindowpb.xhtml
plugin-utils.js
[test_bug479979.xhtml]
[test_bug751809.html]
[test_busy_hang.xhtml]
skip-if = (!crashreporter) || (os != "win")
[test_clear_site_data.html]
[test_convertpoint.xhtml]
skip-if = toolkit != "cocoa"
[test_crash_notify.xhtml]
skip-if = !crashreporter
[test_crash_notify_no_report.xhtml]
skip-if = !crashreporter
[test_crash_submit.xhtml]
skip-if = !crashreporter
[test_hang_submit.xhtml]
skip-if = !crashreporter
[test_hangui.xhtml]
skip-if = (!crashreporter) || (os != "win") || verify
support-files = hangui_subpage.html hangui_common.js hangui_iface.js dialog_watcher.js
[test_idle_hang.xhtml]
skip-if = (!crashreporter) || (os != "win")
[test_npruntime.xhtml]
[test_plugin_tag_clicktoplay.html]
[test_privatemode_perwindowpb.xhtml]
[test_xulbrowser_plugin_visibility.xhtml]
skip-if = (toolkit == "cocoa") || (os == "win")
support-files = xulbrowser_plugin_visibility.xhtml plugin_visibility_loader.html
[test_wmode.xhtml]

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

@ -1,142 +0,0 @@
<html>
<head>
<title>NPCocoaEventFocusChanged Tests</title>
</head>
<body>
<embed id="plugin1" type="application/x-test" width="100" height="100"></embed>
<embed id="plugin2" type="application/x-test" width="100" height="100"></embed>
<script type="application/javascript">
function is(aLeft, aRight, aMessage) {
window.opener.SimpleTest.is(aLeft, aRight, aMessage);
}
function ok(aValue, aMessage) {
window.opener.SimpleTest.ok(aValue, aMessage);
}
function synthesizeNativeMouseEvent(aX, aY, aNativeMsg, aModifiers, aElement, aCallback) {
var observer = {
observe(aSubject, aTopic, aData) {
if (aCallback && aTopic == "mouseevent") {
aCallback(aData);
}
},
};
SpecialPowers.DOMWindowUtils.sendNativeMouseEvent(aX, aY, aNativeMsg, aModifiers, aElement, observer);
return true;
}
function* runTests() {
var utils = SpecialPowers.DOMWindowUtils;
var scale = utils.screenPixelsPerCSSPixel;
var plugin1 = document.getElementById("plugin1"); // What we're testing.
var plugin2 = document.getElementById("plugin2"); // Dummy.
var plugin1Bounds = plugin1.getBoundingClientRect();
var plugin2Bounds = plugin2.getBoundingClientRect();
var plugin1X = (window.mozInnerScreenX + plugin1Bounds.left + 10);
var plugin1Y = (window.mozInnerScreenY + plugin1Bounds.top + 10);
var plugin2X = (window.mozInnerScreenX + plugin2Bounds.left + 10);
var plugin2Y = (window.mozInnerScreenY + plugin2Bounds.top + 10);
const NSLeftMouseDown = 1,
NSLeftMouseUp = 2;
if (plugin1.getEventModel() != 1) {
window.opener.todo(false, "Skipping this test when not testing the Cocoa event model");
return;
}
// Initialize to 0 since there is no initial state event,
// plugins should assume they do not initially have focus.
var expectedEventCount = 0;
// Make sure initial event count is correct.
is(plugin1.getFocusEventCount(), expectedEventCount, "Focus event count should be " + expectedEventCount);
// Make sure initial focus state is unknown (assumed false).
var initialStateUnknown = false;
try {
plugin1.getFocusState();
} catch (e) {
initialStateUnknown = true;
}
is(initialStateUnknown, true, "Initial state should be unknown, assumed false.");
// Give the plugin focus (the window is already focused).
yield synthesizeNativeMouseEvent(plugin1X * scale, plugin1Y * scale, NSLeftMouseDown, 0, plugin1, continueTest);
yield synthesizeNativeMouseEvent(plugin1X * scale, plugin1Y * scale, NSLeftMouseUp, 0, plugin1, continueTest);
expectedEventCount++;
is(plugin1.getFocusState(), true, "(1) Plugin should have focus.");
is(plugin1.getFocusEventCount(), expectedEventCount, "Focus event count should be " + expectedEventCount);
// Make sure window activation state changes don't spontaneously
// change plugin focus.
// Blur the window.
SpecialPowers.focus(opener);
is(plugin1.getFocusState(), true, "(2) Plugin should still have focus.");
is(plugin1.getFocusEventCount(), expectedEventCount, "Focus event count should be " + expectedEventCount);
// Focus the window.
SpecialPowers.focus(window);
is(plugin1.getFocusState(), true, "(3) Plugin should still have focus.");
is(plugin1.getFocusEventCount(), expectedEventCount, "Focus event count should be " + expectedEventCount);
// Take focus from the plugin.
yield synthesizeNativeMouseEvent(plugin2X * scale, plugin2Y * scale, NSLeftMouseDown, 0, plugin2, continueTest);
yield synthesizeNativeMouseEvent(plugin2X * scale, plugin2Y * scale, NSLeftMouseUp, 0, plugin2, continueTest);
expectedEventCount++;
is(plugin1.getFocusState(), false, "(4) Plugin should not have focus.");
is(plugin1.getFocusEventCount(), expectedEventCount, "Focus event count should be " + expectedEventCount);
// Make sure window activation causes the plugin to be informed of focus
// changes that took place while the window was inactive.
// Give the plugin focus (the window is already focused).
yield synthesizeNativeMouseEvent(plugin1X * scale, plugin1Y * scale, NSLeftMouseDown, 0, plugin1, continueTest);
yield synthesizeNativeMouseEvent(plugin1X * scale, plugin1Y * scale, NSLeftMouseUp, 0, plugin1, continueTest);
expectedEventCount++;
// Blur the window.
SpecialPowers.focus(opener);
// Take focus from the plugin while the window is blurred.
plugin2.focus();
is(plugin1.getFocusState(), true, "(5) Plugin should still have focus.");
is(plugin1.getFocusEventCount(), expectedEventCount, "Focus event count should be " + expectedEventCount);
// Focus the window.
SpecialPowers.focus(window);
expectedEventCount++;
is(plugin1.getFocusState(), false, "(6) Plugin should not have focus.");
is(plugin1.getFocusEventCount(), expectedEventCount, "Focus event count should be " + expectedEventCount);
}
var gTestContinuation = null;
function continueTest() {
if (!gTestContinuation) {
gTestContinuation = runTests();
}
var ret = gTestContinuation.next();
if (ret.done) {
window.opener.testsFinished();
} else {
is(ret.value, true, "Mouse event successfully synthesized");
}
}
// Onload hander doesn't work for these tests -- no events arrive at the plugin.
window.opener.SimpleTest.waitForFocus(continueTest, window);
</script>
</body>
</html>

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

@ -1,95 +0,0 @@
<html>
<head>
<title>NPCocoaEventWindowFocusChanged Tests</title>
</head>
<body onload="runTests()">
<embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
<embed id="plugin2" type="application/x-test" width="400" height="400"></embed>
<script type="application/javascript">
function is(aLeft, aRight, aMessage) {
window.opener.SimpleTest.is(aLeft, aRight, aMessage);
}
function ok(aValue, aMessage) {
window.opener.SimpleTest.ok(aValue, aMessage);
}
function executeSoon(func) {
window.opener.SimpleTest.executeSoon(func);
}
function waitForFocus(aCb, aTarget, aBlank) {
window.opener.SimpleTest.waitForFocus(aCb, aTarget, aBlank);
}
function runTests() {
var plugin1 = document.getElementById("plugin1");
var plugin2 = document.getElementById("plugin2");
if (plugin1.getEventModel() != 1) {
window.opener.todo(false, "Skipping this test when not testing the Cocoa event model");
window.opener.testsFinished();
return;
}
// The first plugin will have in-page focus for these tests.
plugin1.focus();
// The expected event count which applies to all instances.
// Initialize to 1 to account for the initial state event.
var expectedEventCount = 1;
// First make sure the plugins got an initial window focus event.
// Since this window was just opened it should be in the front. If
// the plugin has not been sent an initial window state then it will
// be in an unknown state and it will throw an exception.
try {
is(plugin1.getTopLevelWindowActivationState(), true, "Activation state should be: activated");
is(plugin1.getTopLevelWindowActivationEventCount(), expectedEventCount, "Window focus event count should be " + expectedEventCount);
is(plugin2.getTopLevelWindowActivationState(), true, "Activation state should be: activated");
is(plugin2.getTopLevelWindowActivationEventCount(), expectedEventCount, "Window focus event count should be " + expectedEventCount);
} catch (e) {
ok(false, "Plugin does not know its initial top-level window activation state!");
}
var fm = SpecialPowers.Services.focus;
waitForFocus(function() {
// Make sure the plugin handled the focus event before checking.
executeSoon(function() {
expectedEventCount++;
is(plugin1.getTopLevelWindowActivationState(), false, "Activation state should be: deactivated");
is(plugin1.getTopLevelWindowActivationEventCount(), expectedEventCount, "Window focus event count should be " + expectedEventCount);
is(plugin2.getTopLevelWindowActivationState(), false, "Activation state should be: deactivated");
is(plugin2.getTopLevelWindowActivationEventCount(), expectedEventCount, "Window focus event count should be " + expectedEventCount);
// Bring our window back to the front and make sure plugins were properly notified.
fm.focusedWindow = window;
waitForFocus(function() {
// Make sure the plugin handled the focus event before checking.
executeSoon(function() {
expectedEventCount++;
is(plugin1.getTopLevelWindowActivationState(), true, "Activation state should be: activated");
is(plugin1.getTopLevelWindowActivationEventCount(), expectedEventCount, "Window focus event count should be " + expectedEventCount);
is(plugin2.getTopLevelWindowActivationState(), true, "Activation state should be: activated");
is(plugin2.getTopLevelWindowActivationEventCount(), expectedEventCount, "Window focus event count should be " + expectedEventCount);
window.opener.testsFinished();
});
}, window);
});
}, window.opener);
// Send our window to the back and make sure plugins were properly notified.
// Calling window.blur() is not allowed.
fm.focusedWindow = window.opener;
}
</script>
</body>
</html>

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

@ -1,4 +0,0 @@
<html>
<body onload="window.parent.frameLoaded()">
<h1>Crashing subpage</h1>
<embed id="plugin1" type="application/x-test" width="400" height="400" drawmode="solid" color="FF00FFFF"></embed>

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

@ -1,245 +0,0 @@
/* eslint-env mozilla/chrome-worker */
const EVENT_OBJECT_SHOW = 0x8002;
const EVENT_OBJECT_HIDE = 0x8003;
const WINEVENT_OUTOFCONTEXT = 0;
const WINEVENT_SKIPOWNPROCESS = 2;
const QS_ALLINPUT = 0x04ff;
const INFINITE = 0xffffffff;
const WAIT_OBJECT_0 = 0;
const WAIT_TIMEOUT = 258;
const PM_NOREMOVE = 0;
var user32;
function DialogWatcher(titleText, onDialogStart, onDialogEnd) {
this.titleText = titleText;
this.onDialogStart = onDialogStart;
this.onDialogEnd = onDialogEnd;
}
DialogWatcher.prototype.init = function() {
this.hwnd = undefined;
if (!this.user32) {
this.user32 = ctypes.open("user32.dll");
}
if (!this.findWindow) {
this.findWindow = user32.declare(
"FindWindowW",
ctypes.winapi_abi,
ctypes.uintptr_t,
ctypes.char16_t.ptr,
ctypes.char16_t.ptr
);
}
if (!this.winEventProcType) {
this.winEventProcType = ctypes.FunctionType(
ctypes.stdcall_abi,
ctypes.void_t,
[
ctypes.uintptr_t,
ctypes.uint32_t,
ctypes.uintptr_t,
ctypes.long,
ctypes.long,
ctypes.uint32_t,
ctypes.uint32_t,
]
).ptr;
}
if (!this.setWinEventHook) {
this.setWinEventHook = user32.declare(
"SetWinEventHook",
ctypes.winapi_abi,
ctypes.uintptr_t,
ctypes.uint32_t,
ctypes.uint32_t,
ctypes.uintptr_t,
this.winEventProcType,
ctypes.uint32_t,
ctypes.uint32_t,
ctypes.uint32_t
);
}
if (!this.unhookWinEvent) {
this.unhookWinEvent = user32.declare(
"UnhookWinEvent",
ctypes.winapi_abi,
ctypes.int,
ctypes.uintptr_t
);
}
if (!this.pointType) {
this.pointType = ctypes.StructType("tagPOINT", [
{ x: ctypes.long },
{ y: ctypes.long },
]);
}
if (!this.msgType) {
this.msgType = ctypes.StructType("tagMSG", [
{ hwnd: ctypes.uintptr_t },
{ message: ctypes.uint32_t },
{ wParam: ctypes.uintptr_t },
{ lParam: ctypes.intptr_t },
{ time: ctypes.uint32_t },
{ pt: this.pointType },
]);
}
if (!this.peekMessage) {
this.peekMessage = user32.declare(
"PeekMessageW",
ctypes.winapi_abi,
ctypes.int,
this.msgType.ptr,
ctypes.uintptr_t,
ctypes.uint32_t,
ctypes.uint32_t,
ctypes.uint32_t
);
}
if (!this.msgWaitForMultipleObjects) {
this.msgWaitForMultipleObjects = user32.declare(
"MsgWaitForMultipleObjects",
ctypes.winapi_abi,
ctypes.uint32_t,
ctypes.uint32_t,
ctypes.uintptr_t.ptr,
ctypes.int,
ctypes.uint32_t,
ctypes.uint32_t
);
}
if (!this.getWindowTextW) {
this.getWindowTextW = user32.declare(
"GetWindowTextW",
ctypes.winapi_abi,
ctypes.int,
ctypes.uintptr_t,
ctypes.char16_t.ptr,
ctypes.int
);
}
if (!this.messageBox) {
// Handy for debugging this code
this.messageBox = user32.declare(
"MessageBoxW",
ctypes.winapi_abi,
ctypes.int,
ctypes.uintptr_t,
ctypes.char16_t.ptr,
ctypes.char16_t.ptr,
ctypes.uint32_t
);
}
};
DialogWatcher.prototype.getWindowText = function(hwnd) {
var bufType = ctypes.ArrayType(ctypes.char16_t);
var buffer = new bufType(256);
if (this.getWindowTextW(hwnd, buffer, buffer.length)) {
return buffer.readString();
}
return undefined;
};
DialogWatcher.prototype.processWindowEvents = function(timeout) {
var onWinEvent = function(
self,
hook,
event,
hwnd,
idObject,
idChild,
dwEventThread,
dwmsEventTime
) {
var nhwnd = Number(hwnd);
if (event == EVENT_OBJECT_SHOW) {
if (nhwnd == self.hwnd) {
// We've already picked up this event via FindWindow
return;
}
var windowText = self.getWindowText(hwnd);
if (windowText == self.titleText && self.onDialogStart) {
self.hwnd = nhwnd;
self.onDialogStart(nhwnd);
}
} else if (
event == EVENT_OBJECT_HIDE &&
nhwnd == self.hwnd &&
self.onDialogEnd
) {
self.onDialogEnd();
self.hwnd = null;
}
};
var self = this;
var callback = this.winEventProcType(function(
hook,
event,
hwnd,
idObject,
idChild,
dwEventThread,
dwmsEventTime
) {
onWinEvent(
self,
hook,
event,
hwnd,
idObject,
idChild,
dwEventThread,
dwmsEventTime
);
});
var hook = this.setWinEventHook(
EVENT_OBJECT_SHOW,
EVENT_OBJECT_HIDE,
0,
callback,
0,
0,
WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS
);
if (!hook) {
return null;
}
// Check if the window is already showing
var hwnd = this.findWindow(null, this.titleText);
if (hwnd && hwnd > 0) {
this.hwnd = Number(hwnd);
if (this.onDialogStart) {
this.onDialogStart(this.hwnd);
}
}
if (!timeout) {
timeout = INFINITE;
}
var waitStatus = WAIT_OBJECT_0;
var expectingStart = this.onDialogStart && this.hwnd === undefined;
var startWaitTime = Date.now();
while (this.hwnd === undefined || (this.onDialogEnd && this.hwnd)) {
waitStatus = this.msgWaitForMultipleObjects(
0,
null,
0,
expectingStart ? INFINITE : timeout,
0
);
if (waitStatus == WAIT_OBJECT_0) {
var msg = new this.msgType();
this.peekMessage(msg.address(), 0, 0, 0, PM_NOREMOVE);
}
if (waitStatus == WAIT_TIMEOUT || Date.now() - startWaitTime >= timeout) {
break;
}
}
this.unhookWinEvent(hook);
// Returns true if the hook was successful, something was found, and we never timed out
return this.hwnd !== undefined && waitStatus == WAIT_OBJECT_0;
};

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

@ -1,22 +0,0 @@
/* eslint-env mozilla/frame-script */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
function getTestPlugin(pluginName) {
var ph = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
var tags = ph.getPluginTags();
var name = pluginName || "Test Plug-in";
for (var tag of tags) {
if (tag.name == name) {
return tag;
}
}
return null;
}
addMessageListener("check-plugin-unload", function(message) {
var tag = getTestPlugin();
sendAsyncMessage("check-plugin-unload", tag.loaded);
});

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

@ -1,117 +0,0 @@
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
var success = false;
var observerFired = false;
var observerPromise = null;
var testObserver = {
idleHang: true,
observe(subject, topic, data) {
observerFired = true;
ok(true, "Observer fired");
is(topic, "plugin-crashed", "Checking correct topic");
is(data, null, "Checking null data");
ok(subject instanceof Ci.nsIPropertyBag2, "got Propbag");
ok(subject instanceof Ci.nsIWritablePropertyBag2, "got writable Propbag");
var pluginId = subject.getPropertyAsAString("pluginDumpID");
isnot(pluginId, "", "got a non-empty plugin crash id");
var additionalDumps = subject.getPropertyAsACString("additionalMinidumps");
isnot(additionalDumps, "", "got a non-empty additionalDumps field");
// check plugin dump and extra files
let profD = Services.dirsvc.get("ProfD", Ci.nsIFile);
profD.append("minidumps");
let pluginDumpFile = profD.clone();
pluginDumpFile.append(pluginId + ".dmp");
ok(pluginDumpFile.exists(), "plugin minidump exists");
let pluginExtraFile = profD.clone();
pluginExtraFile.append(pluginId + ".extra");
ok(pluginExtraFile.exists(), "plugin extra file exists");
observerPromise = OS.File.read(pluginExtraFile.path, {
encoding: "utf-8",
}).then(json => {
let extraData = JSON.parse(json);
// check additional dumps
ok(
"additional_minidumps" in extraData,
"got field for additional minidumps"
);
is(
additionalDumps,
extraData.additional_minidumps,
"the annotation matches the propbag entry"
);
let dumpNames = extraData.additional_minidumps.split(",");
ok(dumpNames.includes("browser"), "browser in additional_minidumps");
for (let name of dumpNames) {
let file = profD.clone();
file.append(pluginId + "-" + name + ".dmp");
ok(file.exists(), "additional dump '" + name + "' exists");
}
// check cpu usage field
ok("PluginCpuUsage" in extraData, "got extra field for plugin cpu usage");
let cpuUsage = parseFloat(extraData.PluginCpuUsage);
if (this.idleHang) {
ok(cpuUsage == 0, "plugin cpu usage is 0%");
} else {
ok(cpuUsage > 0, "plugin cpu usage is >0%");
}
});
},
QueryInterface: ChromeUtils.generateQI([
"nsIObserver",
"nsISupportsWeakReference",
]),
};
function onPluginCrashed(aEvent) {
ok(true, "Plugin crashed notification received");
ok(observerFired, "Observer should have fired first");
is(aEvent.type, "PluginCrashed", "event is correct type");
var pluginElement = document.getElementById("plugin1");
is(
pluginElement,
aEvent.target,
"Plugin crashed event target is plugin element"
);
ok(
aEvent instanceof PluginCrashedEvent,
"plugin crashed event has the right interface"
);
is(typeof aEvent.pluginDumpID, "string", "pluginDumpID is correct type");
isnot(aEvent.pluginDumpID, "", "got a non-empty dump ID");
is(typeof aEvent.pluginName, "string", "pluginName is correct type");
is(aEvent.pluginName, "Test Plug-in", "got correct plugin name");
is(typeof aEvent.pluginFilename, "string", "pluginFilename is correct type");
isnot(aEvent.pluginFilename, "", "got a non-empty filename");
// The app itself may or may not have decided to submit the report, so
// allow either true or false here.
ok(
"submittedCrashReport" in aEvent,
"submittedCrashReport is a property of event"
);
is(
typeof aEvent.submittedCrashReport,
"boolean",
"submittedCrashReport is correct type"
);
Services.obs.removeObserver(testObserver, "plugin-crashed");
observerPromise.then(() => {
SimpleTest.finish();
});
}

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

@ -1,19 +0,0 @@
// Plugin Hang UI constants
const HANGUIOP_NOTHING = 0;
const HANGUIOP_CANCEL = 1;
const HANGUIOP_COMMAND = 2;
const IDC_CONTINUE = 1001;
const IDC_STOP = 1002;
const IDC_NOFUTURE = 1003;
// Windows constants
const WM_CLOSE = 0x0010;
const WM_COMMAND = 0x0111;
const BM_GETCHECK = 0x00f0;
const BM_SETCHECK = 0x00f1;
const BN_CLICKED = 0;
const BST_CHECKED = 1;
// Test-specific constants
const EPSILON_MS = 1000;
const STALL_DURATION = 2;

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

@ -1,147 +0,0 @@
/* eslint-env mozilla/chrome-worker */
var user32;
var sendMessage;
var getDlgItem;
var messageBox;
var watcher;
/* import-globals-from hangui_common.js */
importScripts("hangui_common.js");
/* import-globals-from dialog_watcher.js */
importScripts("dialog_watcher.js");
function initCTypes() {
if (!user32) {
user32 = ctypes.open("user32.dll");
}
if (!getDlgItem) {
getDlgItem = user32.declare(
"GetDlgItem",
ctypes.winapi_abi,
ctypes.uintptr_t,
ctypes.uintptr_t,
ctypes.int
);
}
if (!sendMessage) {
sendMessage = user32.declare(
"SendMessageW",
ctypes.winapi_abi,
ctypes.intptr_t,
ctypes.uintptr_t,
ctypes.uint32_t,
ctypes.uintptr_t,
ctypes.intptr_t
);
}
if (!messageBox) {
// Handy for debugging the test itself
messageBox = user32.declare(
"MessageBoxW",
ctypes.winapi_abi,
ctypes.int,
ctypes.uintptr_t,
ctypes.char16_t.ptr,
ctypes.char16_t.ptr,
ctypes.uint32_t
);
}
if (!watcher) {
watcher = new DialogWatcher("Warning: Unresponsive plugin");
}
}
function postSuccess(params) {
self.postMessage({ status: true, params });
}
function postFail(params, msg) {
self.postMessage({ status: false, params, msg });
}
function onDialogStart(inparams, hwnd) {
var params = Object.create(inparams);
params.testName += " (Start)";
params.callback = null;
if (!params.expectToFind) {
postFail(params, "Dialog showed when we weren't expecting it to!");
return;
}
if (params.opCode == HANGUIOP_CANCEL) {
sendMessage(hwnd, WM_CLOSE, 0, 0);
} else if (params.opCode == HANGUIOP_COMMAND) {
if (params.check) {
var checkbox = getDlgItem(hwnd, IDC_NOFUTURE);
if (!checkbox) {
postFail(params, "Couldn't find checkbox");
return;
}
sendMessage(checkbox, BM_SETCHECK, BST_CHECKED, 0);
sendMessage(
hwnd,
WM_COMMAND,
(BN_CLICKED << 16) | IDC_NOFUTURE,
checkbox
);
}
var button = getDlgItem(hwnd, params.commandId);
if (!button) {
postFail(
params,
"GetDlgItem failed to find button with ID " + params.commandId
);
return;
}
sendMessage(
hwnd,
WM_COMMAND,
(BN_CLICKED << 16) | params.commandId,
button
);
}
postSuccess(params);
}
function onDialogEnd(inparams) {
var params = Object.create(inparams);
params.testName += " (End)";
params.callback = inparams.callback;
postSuccess(params);
}
self.onmessage = function(event) {
initCTypes();
watcher.init();
var params = event.data;
var timeout = params.timeoutMs;
if (params.expectToFind) {
watcher.onDialogStart = function(hwnd) {
onDialogStart(params, hwnd);
};
if (params.expectToClose) {
watcher.onDialogEnd = function() {
onDialogEnd(params);
};
}
} else {
watcher.onDialogStart = null;
watcher.onDialogEnd = null;
}
var result = watcher.processWindowEvents(timeout);
if (result === null) {
postFail(params, "Hook failed");
} else if (!result) {
if (params.expectToFind) {
postFail(params, "The dialog didn't show but we were expecting it to");
} else {
postSuccess(params);
}
}
};
self.onerror = function(event) {
var msg =
"Error: " + event.message + " at " + event.filename + ":" + event.lineno;
postFail(null, msg);
};

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

@ -1,4 +0,0 @@
<html>
<body onload="window.parent.frameLoaded()">
<embed id="plugin1" type="application/x-test" width="400" height="400"></embed>

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

@ -1,7 +1,7 @@
function handleRequest(request, response)
{
response.processAsync();
response.setHeader("Content-Type", "application/x-Second-Test", false);
response.setHeader("Content-Type", "image/pNG", false);
response.write("Hello world.\n");
response.finish();

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

@ -4,16 +4,9 @@ prefs =
skip-if = headless # crash on shutdown, no other failures
support-files =
307-xo-redirect.sjs
crashing_subpage.html
1028200-subpageA.html
1028200-subpageA1.html
1028200-subpageB.html
1028200-subpageB1.html
1028200-subpageC.html
file_authident.js
file_bug771202.html
file_bug863792.html
file_bug1245545.js
large-pic.jpg
loremipsum.txt
loremipsum.xtest
@ -30,134 +23,23 @@ support-files =
post.sjs
plugin-utils.js
[test_bug1028200-1.html]
skip-if = !crashreporter
fail-if = (xorigin && fission) # Element is no longer fullscreen
[test_bug1028200-2.html]
skip-if = !crashreporter
[test_bug1028200-3.html]
skip-if = !crashreporter
fail-if = (xorigin && fission) # Element is no longer fullscreen
[test_bug1028200-4.html]
skip-if = !crashreporter
fail-if = (xorigin && fission) # Element is no longer fullscreen
[test_bug1028200-5.html]
skip-if = !crashreporter
fail-if = (xorigin && fission) # Element is no longer fullscreen
[test_bug1028200-6.html]
skip-if = !crashreporter
[test_bug1028200-7.html]
skip-if = !crashreporter
[test_bug532208.html]
[test_bug539565-1.html]
[test_bug539565-2.html]
[test_bug771202.html]
[test_bug777098.html]
[test_bug784131.html]
[test_bug813906.html]
[test_bug852315.html]
[test_bug854082.html]
[test_bug863792.html]
[test_bug967694.html]
[test_bug985859.html]
[test_bug986930.html]
[test_bug1092842.html]
skip-if = (verify && (os == 'win')) || (os == "win" && webrender) # win/webrender bug 1296400
[test_bug1165981.html]
skip-if =
processor == 'aarch64' && os == 'win'
xorigin && !fission # JavaScript error: test_bug1165981.html:line 51: TypeError: pluginElement.identifierToStringTest is not a function; this test incorrectly passes when fission is enabled because the permission is being checked for the frame site rather than the top-level site.
reason = Plugins are not supported on Windows/AArch64
[test_bug1245545.html]
[test_bug1307694.html]
skip-if = verify || (processor == 'aarch64' && os == 'win') # aarch64 due to 1541241
fail-if = (xorigin && !fission)
[test_cocoa_focus.html]
skip-if = toolkit != "cocoa" || e10s # Bug 1194534
support-files = cocoa_focus.html
[test_cocoa_window_focus.html]
skip-if = toolkit != "cocoa" # Bug 1194534
support-files = cocoa_window_focus.html
[test_copyText.html]
skip-if = toolkit != "gtk"
[test_crash_nested_loop.html]
skip-if = toolkit != "gtk"
[test_crashing.html]
skip-if = !crashreporter
[test_crashing2.html]
skip-if = (!crashreporter) || true # Bug 566049
[test_CrashService_crash.html]
skip-if = !crashreporter || e10s
[test_CrashService_hang.html]
skip-if = !crashreporter || e10s
[test_defaultValue.html]
skip-if = (verify && !debug && (os == 'linux'))
[test_enumerate.html]
[test_hanging.html]
skip-if = !crashreporter || e10s
[test_hidden_plugin.html]
[test_instance_re-parent.html]
[test_instance_unparent1.html]
[test_instance_unparent2.html]
[test_instance_unparent3.html]
[test_instantiation.html]
[test_mixed_case_mime.html]
skip-if = (processor == 'aarch64' && os == 'win')
reason = Plugins are not supported on Windows/AArch64
[test_multipleinstanceobjects.html]
[test_newstreamondestroy.html]
[test_npn_timers.html]
[test_npobject_getters.html]
[test_NPNVdocumentOrigin.html]
[test_NPPVpluginWantsAllNetworkStreams.html]
[test_npruntime_construct.html]
[test_npruntime_identifiers.html]
[test_npruntime_npnevaluate.html]
[test_npruntime_npninvoke.html]
[test_npruntime_npninvokedefault.html]
[test_object.html]
[test_painting.html]
skip-if = (toolkit == "cocoa" && e10s) # bug 1252230
[test_plugin_fallback_focus.html]
[test_plugin_scroll_painting.html]
skip-if = true # Bug 596491
[test_pluginstream_err.html]
[test_pluginstream_geturl.html]
skip-if = true # Bug 1267432
[test_pluginstream_geturlnotify.html]
skip-if = true # Bug 1267432
[test_pluginstream_post.html]
[test_pluginstream_poststream.html]
[test_pluginstream_referer.html]
fail-if = xorigin
[test_pluginstream_src.html]
[test_pluginstream_src_dynamic.html]
[test_pluginstream_src_referer.html]
fail-if = xorigin
[test_positioning.html]
skip-if = true # disabled due to oddness, perhaps scrolling of the mochitest window?
[test_propertyAndMethod.html]
[test_queryCSSZoomFactor.html]
[test_queryContentsScaleFactor.html]
skip-if = (toolkit != "cocoa") || (os != "win")
[test_queryContentsScaleFactorWindowed.html]
skip-if = (toolkit != "cocoa") || (os != "win")
[test_redirect_handling.html]
[test_refresh_navigator_plugins.html]
skip-if = e10s # Bug 1090576
[test_secondPlugin.html]
[test_src_url_change.html]
[test_streamatclose.html]
[test_streamNotify.html]
[test_stringHandling.html]
[test_visibility.html]
skip-if = toolkit == "cocoa"
[test_windowed_invalidate.html]
skip-if = os != "win" || webrender # win/webrender bug 1296400
[test_windowless_flash.html]
skip-if = !(os == "win" && processor == "x86_64") || verify
[test_windowless_ime.html]
skip-if = os != "win" || (os == "win" && processor == "aarch64") # aarch64 due to 1536350
[test_x11_error_crash.html]
skip-if = !crashreporter || e10s || toolkit != "gtk"
[test_zero_opacity.html]
skip-if = os == "win" && webrender # win/webrender bug 1296400

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

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="testplugin" type="application/x-test" drawmode="solid" color="ff00ff00" wmode="window"
style="position:absolute; top:50px; left:50px; width:500px; height:250px">
<div style="display:block; height:3000px;"></div>
<iframe id="dataFrame" src="data:text/html,foo" width="300" height="300"></iframe>
</body>
</html>

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

@ -1,6 +0,0 @@
<!DOCTYPE html>
<html>
<body style="background-color: #88AAFF;">
<h1>This Page Has a Solid Plugin</h1>
<p><embed id="p" type="application/x-test" drawmode="solid" color="FFFF0000" width="200" height="200"></embed>

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

@ -1,11 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window title="NPAPI Private Mode Tests"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<body xmlns="http://www.w3.org/1999/xhtml">
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
<embed id="plugin2" type="application/x-test" width="200" height="200"></embed>
</body>
</window>

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

@ -1,27 +0,0 @@
<head>
<title>nsICrashService plugin crash</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<body>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout(
"crashAndGetCrashServiceRecord() polls for async crash recording");
SimpleTest.requestCompleteLog();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
window.frameLoaded = function frameLoaded_toCrash() {
SimpleTest.expectChildProcessCrash();
crashAndGetCrashServiceRecord("crash", function(cm, crash) {
var isPluginCrash = crash.isOfType(cm.PROCESS_TYPE_PLUGIN, cm.CRASH_TYPE_CRASH);
ok(isPluginCrash, "Record should be a plugin crash");
if (!isPluginCrash) {
dump("Crash type: " + crash.type + "\n");
}
SimpleTest.finish();
});
};
</script>
<iframe id="iframe1" src="crashing_subpage.html" width="600" height="600"></iframe>

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

@ -1,28 +0,0 @@
<head>
<title>nsICrashService plugin hang</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<body>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout(
"crashAndGetCrashServiceRecord() polls for async crash recording");
SimpleTest.requestCompleteLog();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
window.frameLoaded = function frameLoaded_toCrash() {
SimpleTest.expectChildProcessCrash();
// the default timeout is annoying high for mochitest runs
var timeoutPref = "dom.ipc.plugins.timeoutSecs";
SpecialPowers.setIntPref(timeoutPref, 5);
crashAndGetCrashServiceRecord("hang", function(cm, crash) {
ok(crash.isOfType(cm.PROCESS_TYPE_PLUGIN, cm.CRASH_TYPE_HANG),
"Record should be a plugin hang");
SimpleTest.finish();
});
};
</script>
<iframe id="iframe1" src="crashing_subpage.html" width="600" height="600"></iframe>

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

@ -1,46 +0,0 @@
<html>
<head>
<title>Test NPNVdocumentOrigin</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
</head>
<body onload="runTest()">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
function runTest() {
"use strict";
var p1 = document.getElementById("plugin1");
var realOrigin = "http://mochi.test:8888";
// Test with no modifications
is(p1.getNPNVdocumentOrigin(), realOrigin, "Checking for expected origin.");
// This used to test that shadowing window.location.toString didn't confuse
// getNPNVdocumentOrigin. But now we explicitly throw when that happens. So
// just verify that we throw. There's no reason why getNPNVdocumentOrigin _would_
// be confused in this case anyway.
try {
window.location.toString = function() { return "http://victim.rckc.at/"; };
ok(false, "Should throw when shadowing window.location.toString");
} catch (e) {
ok(true, "Should throw when shadowing window.location.toString");
}
// Create a plugin in a new window with about:blank
var newWindow = window.open("about:blank");
newWindow.onload = function() {
newWindow.document.writeln('<embed id="plugin2" type="application/x-test" width="200" height="200"></embed>');
var p2 = newWindow.document.getElementById("plugin2");
is(p2.getNPNVdocumentOrigin(), realOrigin, "Checking for expected origin of plugin in new about:blank window.");
newWindow.close();
SimpleTest.finish();
};
}
</script>
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
</body>
</html>

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

@ -1,77 +0,0 @@
<html>
<head>
<title>Test NPPVpluginWantsAllNetworkStreams</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
</head>
<body onload="runTests()">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
var p = null;
var missingDoc = "not-found.html";
var expectedWriteURL = "";
var expectedNotifyStatus = -1;
var writeHappened = false;
var expectedWrite = false;
function writeCallback(url) {
writeHappened = true;
}
function notifyCallback(status, data) {
is(writeHappened, expectedWrite, "Test for expected write.");
is(status, expectedNotifyStatus, "Test for expected stream notification status.");
runNextTest();
}
function test1() {
// In this test we do not expect a stream for the missing document.
p.setPluginWantsAllStreams(false);
expectedWriteURL = missingDoc;
expectedNotifyStatus = 1;
writeHappened = false;
expectedWrite = false;
p.streamTest(missingDoc, false, null, writeCallback, notifyCallback, null, false);
}
function test2() {
// In this test we expect a stream for the missing document.
p.setPluginWantsAllStreams(true);
expectedWriteURL = missingDoc;
expectedNotifyStatus = 0;
writeHappened = false;
expectedWrite = true;
p.streamTest(missingDoc, false, null, writeCallback, notifyCallback, null, false);
}
var tests = [test1, test2];
var currentTest = -1;
function runNextTest() {
currentTest++;
if (currentTest < tests.length) {
tests[currentTest]();
} else {
SimpleTest.finish();
}
}
function runTests() {
p = document.getElementById("plugin1");
runNextTest();
}
</script>
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
</body>
</html>

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

@ -1,107 +0,0 @@
<head>
<meta charset="utf-8">
<title>Plugin Crash, FullScreenElement Cancelled, div[F] -> iframe -> iframe -> plugin</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
</head>
<body onLoad="load()">
<script class="testbody" type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
SimpleTest.expectChildProcessCrash();
SimpleTest.requestFlakyTimeout("This is needed in the event the " +
"fullscreen element fails to cancel fullscreen. The fullscreen " +
"element is expected to exit fullscreen but takes some time to " +
"register as having exited when using `mozCancelFullScreen`. So we " +
"can't just check that `mozFullScreenElement` is true or false after " +
"having called `mozCancelFullScreen` without the timeout because it " +
"will return the value prior to actually cancelling. A timeout is " +
"preferred here as opposed to polling methods similar to " +
"`SimpleTest.waitForCondition` in `SimpleTest.js` for reasons of" +
"idiomaticity."
);
/**
* FullScreen element is expected to remain alive after the test ends; this
* stops it.
*/
SimpleTest.registerCleanupFunction(() => {
if (this.document.mozFullScreenElement) {
let fullScreenChange = promiseFullScreenChange();
this.document.mozCancelFullScreen();
return fullScreenChange;
}
return Promise.resolve();
});
/**
* Start with a fullscreen element.
* Then crash the plugin - which is expected to be a child of the full
* screen element - and therefore exit out of the fullscreen element.
*/
let load = function testCrashChildPlugin_expectFullScreenElementToBeCancelled() {
add_task(async function() {
/* Needed to be able to programatically (without user interaction) enter
* fullscreen (has been deemed a security issue otherwise and therefore
* disabled by default)
*/
await SpecialPowers.pushPrefEnv({
"set": [
["full-screen-api.allow-trusted-requests-only", false],
],
});
});
add_task(async function() {
let fullScreenElement = document.getElementById("div1");
let plugin = document.getElementById("iframe1")
.contentDocument.getElementById("iframe2")
.contentDocument.getElementById("plugin1");
let fullScreenChange = promiseFullScreenChange();
fullScreenElement.mozRequestFullScreen();
await fullScreenChange;
ok(true, "Element is fullscreen");
await crashPlugin(plugin)
.then(() => {
ok(true, "Plugin was crashed");
})
.catch(() => {
ok(false, "Plugin was crashed");
});
});
add_task(async function() {
/**
* We expect the fullscreen mode to change in this test. We'll wait
* 5 seconds for any kind of fullscreen change to occur, and fail if it
* doesn't.
*/
await new Promise((resolve, reject) => {
let timeoutId;
let onFullScreenChange = () => {
document.removeEventListener("fullscreenchange", onFullScreenChange);
clearTimeout(timeoutId);
resolve();
};
document.addEventListener("fullscreenchange", onFullScreenChange);
timeoutId = setTimeout(() => {
document.removeEventListener("fullscreenchange", onFullScreenChange);
reject();
}, 5000);
})
.then(() => {
ok(true, "Element is no longer fullscreen");
})
.catch(() => {
ok(false, "Element is no longer fullscreen");
});
});
};
</script>
<div id="div1">
<iframe id="iframe1" src="1028200-subpageA.html" height="600" width="600"></iframe>
</div>
</body>

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

@ -1,105 +0,0 @@
<head>
<meta charset="utf-8">
<title>Plugin Crash, FullScreenElement Remains, div[F];plugin</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
</head>
<body onLoad="load()">
<script class="testbody" type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
SimpleTest.expectChildProcessCrash();
SimpleTest.requestFlakyTimeout("This is needed in the event the " +
"fullscreen element fails to cancel fullscreen. The fullscreen " +
"element is expected to exit fullscreen but takes some time to " +
"register as having exited when using `mozCancelFullScreen`. So we " +
"can't just check that `mozFullScreenElement` is true or false after " +
"having called `mozCancelFullScreen` without the timeout because it " +
"will return the value prior to actually cancelling. A timeout is " +
"preferred here as opposed to polling methods similar to " +
"`SimpleTest.waitForCondition` in `SimpleTest.js` for reasons of" +
"idiomaticity."
);
/**
* FullScreen element is expected to remain alive after the test ends; this
* stops it.
*/
SimpleTest.registerCleanupFunction(() => {
if (this.document.mozFullScreenElement) {
let fullScreenChange = promiseFullScreenChange();
this.document.mozCancelFullScreen();
return fullScreenChange;
}
return Promise.resolve();
});
/**
* Start with a fullscreen element.
* Then crash the plugin - which is expected to not be a child of the full
* screen element - and therefore remain in the fullscreen element.
*/
let load = function testCrashChildPlugin_expectFullScreenElementToRemain() {
add_task(async function() {
/* Needed to be able to programatically (without user interaction) enter
* fullscreen (has been deemed a security issue otherwise and therefore
* disabled by default)
*/
await SpecialPowers.pushPrefEnv({
"set": [
["full-screen-api.allow-trusted-requests-only", false],
],
});
});
add_task(async function() {
let fullScreenElement = document.getElementById("div1");
let plugin = document.getElementById("plugin1");
let fullScreenChange = promiseFullScreenChange();
fullScreenElement.mozRequestFullScreen();
await fullScreenChange;
ok(true, "Element is fullscreen");
await crashPlugin(plugin)
.then(() => {
ok(true, "Plugin was crashed");
})
.catch(() => {
ok(false, "Plugin was crashed");
});
});
add_task(async function() {
/**
* We expect the fullscreen mode to _not_ change in this test. We'll wait
* 5 seconds for any kind of fullscreen change to occur, and fail if it
* does. Otherwise, we'll assume fullscreen didn't change and finish the
* test.
*/
await new Promise((resolve, reject) => {
let timeoutId;
let onFullScreenChange = () => {
document.removeEventListener("fullscreenchange", onFullScreenChange);
clearTimeout(timeoutId);
reject();
};
document.addEventListener("fullscreenchange", onFullScreenChange);
timeoutId = setTimeout(() => {
document.removeEventListener("fullscreenchange", onFullScreenChange);
resolve();
}, 5000);
})
.then(() => {
ok(true, "Element is still fullscreen");
})
.catch(() => {
ok(false, "Element is still fullscreen");
});
});
};
</script>
<div id="div1"></div>
<embed id="plugin1" type="application/x-test" />
</body>

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

@ -1,105 +0,0 @@
<head>
<meta charset="utf-8">
<title>Plugin Crash, FullScreenElement Cancelled, iframe[F] -> iframe -> div -> plugin</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
</head>
<body onLoad="load()">
<script class="testbody" type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
SimpleTest.expectChildProcessCrash();
SimpleTest.requestFlakyTimeout("This is needed in the event the " +
"fullscreen element fails to cancel fullscreen. The fullscreen " +
"element is expected to exit fullscreen but takes some time to " +
"register as having exited when using `mozCancelFullScreen`. So we " +
"can't just check that `mozFullScreenElement` is true or false after " +
"having called `mozCancelFullScreen` without the timeout because it " +
"will return the value prior to actually cancelling. A timeout is " +
"preferred here as opposed to polling methods similar to " +
"`SimpleTest.waitForCondition` in `SimpleTest.js` for reasons of" +
"idiomaticity."
);
/**
* FullScreen element is expected to remain alive after the test ends; this
* stops it.
*/
SimpleTest.registerCleanupFunction(() => {
if (this.document.mozFullScreenElement) {
let fullScreenChange = promiseFullScreenChange();
this.document.mozCancelFullScreen();
return fullScreenChange;
}
return Promise.resolve();
});
/**
* Start with a fullscreen element.
* Then crash the plugin - which is expected to be a child of the full
* screen element - and therefore exit out of the fullscreen element.
*/
let load = function testCrashChildPlugin_expectFullScreenElementToBeCancelled() {
add_task(async function() {
/* Needed to be able to programatically (without user interaction) enter
* fullscreen (has been deemed a security issue otherwise and therefore
* disabled by default)
*/
await SpecialPowers.pushPrefEnv({
"set": [
["full-screen-api.allow-trusted-requests-only", false],
],
});
});
add_task(async function() {
let fullScreenElement = document.getElementById("iframe1");
let plugin = document.getElementById("iframe1")
.contentDocument.getElementById("iframe2")
.contentDocument.getElementById("plugin1");
let fullScreenChange = promiseFullScreenChange();
fullScreenElement.mozRequestFullScreen();
await fullScreenChange;
ok(true, "Element is fullscreen");
await crashPlugin(plugin)
.then(() => {
ok(true, "Plugin was crashed");
})
.catch(() => {
ok(false, "Plugin was crashed");
});
});
add_task(async function() {
/**
* We expect the fullscreen mode to change in this test. We'll wait
* 5 seconds for any kind of fullscreen change to occur, and fail if it
* doesn't.
*/
await new Promise((resolve, reject) => {
let timeoutId;
let onFullScreenChange = () => {
document.removeEventListener("fullscreenchange", onFullScreenChange);
clearTimeout(timeoutId);
resolve();
};
document.addEventListener("fullscreenchange", onFullScreenChange);
timeoutId = setTimeout(() => {
document.removeEventListener("fullscreenchange", onFullScreenChange);
reject();
}, 5000);
})
.then(() => {
ok(true, "Element is no longer fullscreen");
})
.catch(() => {
ok(false, "Element is no longer fullscreen");
});
});
};
</script>
<iframe id="iframe1" src="1028200-subpageB.html" height="600" width="600"></iframe>
</body>

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

@ -1,105 +0,0 @@
<head>
<meta charset="utf-8">
<title>Plugin Crash, FullScreenElement Cancelled, iframe[F] -> iframe -> div -> plugin</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
</head>
<body onLoad="load()">
<script class="testbody" type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
SimpleTest.expectChildProcessCrash();
SimpleTest.requestFlakyTimeout("This is needed in the event the " +
"fullscreen element fails to cancel fullscreen. The fullscreen " +
"element is expected to exit fullscreen but takes some time to " +
"register as having exited when using `mozCancelFullScreen`. So we " +
"can't just check that `mozFullScreenElement` is true or false after " +
"having called `mozCancelFullScreen` without the timeout because it " +
"will return the value prior to actually cancelling. A timeout is " +
"preferred here as opposed to polling methods similar to " +
"`SimpleTest.waitForCondition` in `SimpleTest.js` for reasons of" +
"idiomaticity."
);
/**
* FullScreen element is expected to remain alive after the test ends; this
* stops it.
*/
SimpleTest.registerCleanupFunction(() => {
if (this.document.mozFullScreenElement) {
let fullScreenChange = promiseFullScreenChange();
this.document.mozCancelFullScreen();
return fullScreenChange;
}
return Promise.resolve();
});
/**
* Start with a fullscreen element.
* Then crash the plugin - which is expected to be a child of the full
* screen element - and therefore exit out of the fullscreen element.
*/
let load = function testCrashChildPlugin_expectFullScreenElementToBeCancelled() {
add_task(async function() {
/* Needed to be able to programatically (without user interaction) enter
* fullscreen (has been deemed a security issue otherwise and therefore
* disabled by default)
*/
await SpecialPowers.pushPrefEnv({
"set": [
["full-screen-api.allow-trusted-requests-only", false],
],
});
});
add_task(async function() {
let fullScreenElement = document.getElementById("iframe1");
let plugin = document.getElementById("iframe1")
.contentDocument.getElementById("iframe2")
.contentDocument.getElementById("plugin1");
let fullScreenChange = promiseFullScreenChange();
fullScreenElement.mozRequestFullScreen();
await fullScreenChange;
ok(true, "Element is fullscreen");
await crashPlugin(plugin)
.then(() => {
ok(true, "Plugin was crashed");
})
.catch(() => {
ok(false, "Plugin was crashed");
});
});
add_task(async function() {
/**
* We expect the fullscreen mode to change in this test. We'll wait
* 5 seconds for any kind of fullscreen change to occur, and fail if it
* doesn't.
*/
await new Promise((resolve, reject) => {
let timeoutId;
let onFullScreenChange = () => {
document.removeEventListener("fullscreenchange", onFullScreenChange);
clearTimeout(timeoutId);
resolve();
};
document.addEventListener("fullscreenchange", onFullScreenChange);
timeoutId = setTimeout(() => {
document.removeEventListener("fullscreenchange", onFullScreenChange);
reject();
}, 5000);
})
.then(() => {
ok(true, "Element is no longer fullscreen");
})
.catch(() => {
ok(false, "Element is no longer fullscreen");
});
});
};
</script>
<iframe id="iframe1" src="1028200-subpageB.html" height="600" width="600"></iframe>
</body>

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

@ -1,105 +0,0 @@
<head>
<meta charset="utf-8">
<title>Plugin Crash, FullScreenElement Cancelled, div[F] -> plugin</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
</head>
<body onLoad="load()">
<script class="testbody" type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
SimpleTest.expectChildProcessCrash();
SimpleTest.requestFlakyTimeout("This is needed in the event the " +
"fullscreen element fails to cancel fullscreen. The fullscreen " +
"element is expected to exit fullscreen but takes some time to " +
"register as having exited when using `mozCancelFullScreen`. So we " +
"can't just check that `mozFullScreenElement` is true or false after " +
"having called `mozCancelFullScreen` without the timeout because it " +
"will return the value prior to actually cancelling. A timeout is " +
"preferred here as opposed to polling methods similar to " +
"`SimpleTest.waitForCondition` in `SimpleTest.js` for reasons of" +
"idiomaticity."
);
/**
* FullScreen element is expected to remain alive after the test ends; this
* stops it.
*/
SimpleTest.registerCleanupFunction(() => {
if (this.document.mozFullScreenElement) {
let fullScreenChange = promiseFullScreenChange();
this.document.mozCancelFullScreen();
return fullScreenChange;
}
return Promise.resolve();
});
/**
* Start with a fullscreen element.
* Then crash the plugin - which is expected to be a child of the full
* screen element - and therefore exit out of the fullscreen element.
*/
let load = function testCrashChildPlugin_expectFullScreenElementToBeCancelled() {
add_task(async function() {
/* Needed to be able to programatically (without user interaction) enter
* fullscreen (has been deemed a security issue otherwise and therefore
* disabled by default)
*/
await SpecialPowers.pushPrefEnv({
"set": [
["full-screen-api.allow-trusted-requests-only", false],
],
});
});
add_task(async function() {
let fullScreenElement = document.getElementById("div1");
let plugin = document.getElementById("plugin1");
let fullScreenChange = promiseFullScreenChange();
fullScreenElement.mozRequestFullScreen();
await fullScreenChange;
ok(true, "Element is fullscreen");
await crashPlugin(plugin)
.then(() => {
ok(true, "Plugin was crashed");
})
.catch(() => {
ok(false, "Plugin was crashed");
});
});
add_task(async function() {
/**
* We expect the fullscreen mode to change in this test. We'll wait
* 5 seconds for any kind of fullscreen change to occur, and fail if it
* doesn't.
*/
await new Promise((resolve, reject) => {
let timeoutId;
let onFullScreenChange = () => {
document.removeEventListener("fullscreenchange", onFullScreenChange);
clearTimeout(timeoutId);
resolve();
};
document.addEventListener("fullscreenchange", onFullScreenChange);
timeoutId = setTimeout(() => {
document.removeEventListener("fullscreenchange", onFullScreenChange);
reject();
}, 5000);
})
.then(() => {
ok(true, "Element is no longer fullscreen");
})
.catch(() => {
ok(false, "Element is no longer fullscreen");
});
});
};
</script>
<div id="div1">
<embed id="plugin1" type="application/x-test" />
</div>
</body>

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

@ -1,105 +0,0 @@
<head>
<meta charset="utf-8">
<title>Plugin Crash, FullScreenElement Remains, iframe[F];plugin</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
</head>
<body onLoad="load()">
<script class="testbody" type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
SimpleTest.expectChildProcessCrash();
SimpleTest.requestFlakyTimeout("This is needed in the event the " +
"fullscreen element fails to cancel fullscreen. The fullscreen " +
"element is expected to exit fullscreen but takes some time to " +
"register as having exited when using `mozCancelFullScreen`. So we " +
"can't just check that `mozFullScreenElement` is true or false after " +
"having called `mozCancelFullScreen` without the timeout because it " +
"will return the value prior to actually cancelling. A timeout is " +
"preferred here as opposed to polling methods similar to " +
"`SimpleTest.waitForCondition` in `SimpleTest.js` for reasons of" +
"idiomaticity."
);
/**
* FullScreen element is expected to remain alive after the test ends; this
* stops it.
*/
SimpleTest.registerCleanupFunction(() => {
if (this.document.mozFullScreenElement) {
let fullScreenChange = promiseFullScreenChange();
this.document.mozCancelFullScreen();
return fullScreenChange;
}
return Promise.resolve();
});
/**
* Start with a fullscreen element.
* Then crash the plugin - which is expected to not be a child of the full
* screen element - and therefore remain in the fullscreen element.
*/
let load = function testCrashChildPlugin_expectFullScreenElementToRemain() {
add_task(async function() {
/* Needed to be able to programatically (without user interaction) enter
* fullscreen (has been deemed a security issue otherwise and therefore
* disabled by default)
*/
await SpecialPowers.pushPrefEnv({
"set": [
["full-screen-api.allow-trusted-requests-only", false],
],
});
});
add_task(async function() {
let fullScreenElement = document.getElementById("iframe1");
let plugin = document.getElementById("plugin1");
let fullScreenChange = promiseFullScreenChange();
fullScreenElement.mozRequestFullScreen();
await fullScreenChange;
ok(true, "Element is fullscreen");
await crashPlugin(plugin)
.then(() => {
ok(true, "Plugin was crashed");
})
.catch(() => {
ok(false, "Plugin was crashed");
});
});
add_task(async function() {
/**
* We expect the fullscreen mode to _not_ change in this test. We'll wait
* 5 seconds for any kind of fullscreen change to occur, and fail if it
* does. Otherwise, we'll assume fullscreen didn't change and finish the
* test.
*/
await new Promise((resolve, reject) => {
let timeoutId;
let onFullScreenChange = () => {
document.removeEventListener("fullscreenchange", onFullScreenChange);
clearTimeout(timeoutId);
reject();
};
document.addEventListener("fullscreenchange", onFullScreenChange);
timeoutId = setTimeout(() => {
document.removeEventListener("fullscreenchange", onFullScreenChange);
resolve();
}, 5000);
})
.then(() => {
ok(true, "Element is still fullscreen");
})
.catch(() => {
ok(false, "Element is still fullscreen");
});
});
};
</script>
<iframe id="iframe1"></iframe>
<embed id="plugin1" type="application/x-test" />
</body>

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

@ -1,107 +0,0 @@
<head>
<meta charset="utf-8">
<title>Plugin Crash, FullScreenElement Remains, iframe -> div[F]; iframe -> iframe -> plugin</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
</head>
<body onLoad="load()">
<script class="testbody" type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
SimpleTest.expectChildProcessCrash();
SimpleTest.requestFlakyTimeout("This is needed in the event the " +
"fullscreen element fails to cancel fullscreen. The fullscreen " +
"element is expected to exit fullscreen but takes some time to " +
"register as having exited when using `mozCancelFullScreen`. So we " +
"can't just check that `mozFullScreenElement` is true or false after " +
"having called `mozCancelFullScreen` without the timeout because it " +
"will return the value prior to actually cancelling. A timeout is " +
"preferred here as opposed to polling methods similar to " +
"`SimpleTest.waitForCondition` in `SimpleTest.js` for reasons of" +
"idiomaticity."
);
/**
* FullScreen element is expected to remain alive after the test ends; this
* stops it.
*/
SimpleTest.registerCleanupFunction(() => {
if (this.document.mozFullScreenElement) {
let fullScreenChange = promiseFullScreenChange();
this.document.mozCancelFullScreen();
return fullScreenChange;
}
return Promise.resolve();
});
/**
* Start with a fullscreen element.
* Then crash the plugin - which is expected to not be a child of the full
* screen element - and therefore remain in the fullscreen element.
*/
let load = function testCrashChildPlugin_expectFullScreenElementToRemain() {
add_task(async function() {
/* Needed to be able to programatically (without user interaction) enter
* fullscreen (has been deemed a security issue otherwise and therefore
* disabled by default)
*/
await SpecialPowers.pushPrefEnv({
"set": [
["full-screen-api.allow-trusted-requests-only", false],
],
});
});
add_task(async function() {
let fullScreenElement = document.getElementById("iframeA");
let plugin = document.getElementById("iframe1")
.contentDocument.getElementById("iframe2")
.contentDocument.getElementById("plugin1");
let fullScreenChange = promiseFullScreenChange();
fullScreenElement.mozRequestFullScreen();
await fullScreenChange;
ok(true, "Element is fullscreen");
await crashPlugin(plugin)
.then(() => {
ok(true, "Plugin was crashed");
})
.catch(() => {
ok(false, "Plugin was crashed");
});
});
add_task(async function() {
/**
* We expect the fullscreen mode to _not_ change in this test. We'll wait
* 5 seconds for any kind of fullscreen change to occur, and fail if it
* does. Otherwise, we'll assume fullscreen didn't change and finish the
* test.
*/
await new Promise((resolve, reject) => {
let timeoutId;
let onFullScreenChange = () => {
document.removeEventListener("fullscreenchange", onFullScreenChange);
clearTimeout(timeoutId);
reject();
};
document.addEventListener("fullscreenchange", onFullScreenChange);
timeoutId = setTimeout(() => {
document.removeEventListener("fullscreenchange", onFullScreenChange);
resolve();
}, 5000);
})
.then(() => {
ok(true, "Element is still fullscreen");
})
.catch(() => {
ok(false, "Element is still fullscreen");
});
});
};
</script>
<iframe id="iframeA" src="1028200-subpageC.html" allowfullscreen="true"></iframe>
<iframe id="iframe1" src="1028200-subpageA.html" height="600" width="600"></iframe>
</body>

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

@ -1,47 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Bug 1092842</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<body onload="startTest()">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
var p = null;
function startTest() {
p = document.getElementById("theplugin");
if (!p.hasWidget()) {
todo(false, "This test is only relevant for windowed plugins");
SimpleTest.finish();
return;
}
// Wait for the plugin to have painted once.
var interval = setInterval(function() {
if (!p.getPaintCount())
return;
clearInterval(interval);
doTest();
SimpleTest.finish();
}, 100);
}
function doTest() {
is(p.getClipRegionRectCount(), 1, "getClipRegionRectCount should be a single rect");
var dpr = window.devicePixelRatio;
is(p.getClipRegionRectEdge(0, 2) - p.getClipRegionRectEdge(0, 0), 100 * dpr, "width of clip region rect");
is(p.getClipRegionRectEdge(0, 3) - p.getClipRegionRectEdge(0, 1), 26 * dpr, "height of clip region rect");
}
</script>
<div style="position:fixed; z-index:1; left:0; right:0; top:0; height:100px; border-bottom:24px solid blue; background:pink; transform:translateZ(0)"></div>
<object id="theplugin" type="application/x-test" drawmode="solid" color="ff00ff00" wmode="window"
style="position:absolute; top:50px; left:0; width:100px; height:100px"></object>
<p id="display"></p>

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

@ -1,74 +0,0 @@
<html>
<head>
<title>Bug 1165981 Test</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<script class="testbody" type="application/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
function findPlugin(pluginName) {
for (var i = 0; i < navigator.plugins.length; i++) {
var plugin = navigator.plugins[i];
if (plugin.name === pluginName) {
return plugin;
}
}
return null;
}
function findMimeType(mimeTypeType) {
for (var i = 0; i < navigator.mimeTypes.length; i++) {
var mimeType = navigator.mimeTypes[i];
if (mimeType.type === mimeTypeType) {
return mimeType;
}
}
return null;
}
function createNode(id, type) {
let obj = document.createElement("object");
obj.type = type;
obj.id = id;
obj.width = 200;
obj.height = 200;
document.body.appendChild(obj);
}
async function run() {
ok(await SpecialPowers.setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, "Shockwave Flash"), "Should find allowed test flash plugin");
ok(!await SpecialPowers.setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, "Third Test Plug-in"), "Should not find disallowed plugin");
await SpecialPowers.pushPermissions([{type: "plugin:flash", allow: true, context: document}]);
createNode("plugin-flash", "application/x-shockwave-flash-test");
createNode("disallowedPlugin", "application/x-third-test");
var pluginElement = document.getElementById("plugin-flash");
is(pluginElement.identifierToStringTest("foo"), "foo", "Should be able to call a function provided by the plugin");
pluginElement = document.getElementById("disallowedPlugin");
is(typeof pluginElement.identifierToStringTest, "undefined", "Should NOT be able to call a function on a disallowed plugin");
ok(navigator.plugins["Shockwave Flash"], "Should have queried a plugin named 'Shockwave Flash'");
ok(!navigator.plugins["Third Test Plug-in"], "Should NOT have queried a disallowed plugin named 'Third Test Plug-in'");
ok(findPlugin("Shockwave Flash"), "Should have found a plugin named 'Shockwave Flash'");
ok(!findPlugin("Third Test Plug-in"), "Should NOT found a disallowed plugin named 'Third Test Plug-in'");
ok(navigator.mimeTypes["application/x-shockwave-flash-test"], "Should have queried a MIME type named 'application/x-shockwave-flash-test'");
ok(!navigator.mimeTypes["application/x-third-test"], "Should NOT have queried a disallowed type named 'application/x-third-test'");
ok(findMimeType("application/x-shockwave-flash-test"), "Should have found a MIME type named 'application/x-shockwave-flash-test'");
ok(!findMimeType("application/x-third-test"), "Should NOT have found a disallowed MIME type named 'application/x-third-test'");
SimpleTest.finish();
}
</script>
<body onload="run()">
</body>
</html>

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

@ -1,52 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta><charset="utf-8"/>
<title>Test Modifying Plugin click-to-play Flag</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="startTest()">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
SpecialPowers.pushPrefEnv({ "set": [
["dom.ipc.plugins.unloadTimeoutSecs", 0],
] });
function startTest() {
let url = SimpleTest.getTestFileURL("file_bug1245545.js");
let script = SpecialPowers.loadChromeScript(url);
script.addMessageListener("check-plugin-unload", testChromeUnload);
var testPlugin = getTestPlugin();
ok(testPlugin, "Should have Test Plug-in");
is(testPlugin.loaded, true, "Test plugin should be loaded");
var pluginNode = document.getElementById("theplugin");
pluginNode.remove();
// Poll for plugin to unload.
function testContentUnload() {
if (!testPlugin.loaded) {
ok(true, "Test plugin unloaded in client process");
// Start the chrome unload test
testChromeUnload(true);
} else {
setTimeout(testContentUnload, 0);
}
}
function testChromeUnload(isLoaded) {
if (!isLoaded) {
ok(true, "Test plugin unloaded in chrome process");
SimpleTest.finish();
} else {
script.sendAsyncMessage("check-plugin-unload");
}
}
testContentUnload();
}
</script>
<object id="theplugin" type="application/x-test"></object>
</body>
</html>

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

@ -1,44 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onLoad="addPerms()">
<script type="text/javascript">
SimpleTest.waitForExplicitFinish();
function addPerms() {
SpecialPowers.pushPermissions([{type: "plugin:flash", allow: true, context: document}], addPluginElement);
}
function addPluginElement() {
SpecialPowers.DOMWindowUtils.plugins[0].playPlugin();
var p = document.createElement("embed");
p.setAttribute("id", "plugin2");
p.setAttribute("type", "application/x-shockwave-flash-test");
p.setAttribute("scale", "noscale");
p.setAttribute("salign", "lt");
document.body.appendChild(p);
SimpleTest.executeSoon(function() {
runTests();
});
}
function runTests() {
var p = document.getElementById("plugin1");
ok(p.setColor != undefined, "Static plugin parameter (salign/scale) ordering were correct");
var p2 = document.getElementById("plugin2");
ok(p2.setColor != undefined, "Dynamic plugin parameter (salign/scale) ordering were correct");
SimpleTest.finish();
}
</script>
<p id="display"></p>
<div id="div1">
<embed id="plugin1" type="application/x-shockwave-flash-test" width="200" height="200" scale="noscale" salign="lt"></embed>
</div>
</body>
</html>

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

@ -1,39 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window title="NPAPI Set Undefined Value Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript" src="plugin-utils.js"></script>
<body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
<script class="testbody" type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
async function runTests() {
var pluginElement1 = document.getElementById("plugin1");
await SimpleTest.promiseWaitForCondition(() => pluginElement1.setUndefinedValueTest !== undefined,
"Waited too long for plugin to activate");
var rv = true; // we want !true from the test plugin
var exceptionThrown = false;
try {
rv = pluginElement1.setUndefinedValueTest();
} catch (e) {
exceptionThrown = true;
}
is(exceptionThrown, false, "Exception thrown setting undefined variable.");
is(rv, false, "Setting undefined variable succeeded.");
// give the UI a chance to settle with the current enabled plugin state
// before we finish the test and reset the state to disabled. Otherwise
// the UI shows the plugin infobar!
SimpleTest.executeSoon(SimpleTest.finish);
}
]]>
</script>
<embed id="plugin1" type="application/x-test" width="300" height="300"></embed>
</body>
</window>

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

@ -1,27 +0,0 @@
<head>
<title>Test for correct async delivery of large streams, bug
532208</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<body onload="setTimeout(runTests, 2000)">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
function runTests() {
try {
document.getElementById("plugin1").getPaintCount();
ok(true, "Data delivery didn't crash");
} catch (e) {
ok(false, "Data delivery crashed");
}
SimpleTest.finish();
}
</script>
<embed id="plugin1" type="application/x-test" width="400"
height="400" src="large-pic.jpg" functiontofail="npp_write_rpc" streammode="normal"></embed>

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

@ -1,93 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=539565
-->
<head>
<title>Test #1 for Bug 539565</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script class="testbody" type="text/javascript">
function runTests() {
var moveBy = 17;
var waitedForPaint = 0;
function waitForPaint(func) {
waitedForPaint = 0;
var testplugin = $("plugin1");
testplugin.last_paint_count = testplugin.getPaintCount ? testplugin.getPaintCount() : -2;
function waitForPaintCountIncrement() {
waitedForPaint++;
moveBy = -moveBy;
$("abs").style.left = ($("abs").offsetLeft + moveBy) + "px";
document.documentElement.offsetHeight;
var pc = testplugin.getPaintCount ? testplugin.getPaintCount() : -2;
if (waitedForPaint == 20 || (pc != testplugin.last_paint_count && pc >= 0)) {
setTimeout(func, 0);
} else {
setTimeout(waitForPaintCountIncrement, 50);
}
}
waitForPaintCountIncrement();
}
function doClick(x, y, func) {
synthesizeMouse($("plugin1"), x, y, {}, window);
setTimeout(func, 0);
}
function verify(test, x, y, next) {
var p = $("plugin1").getLastMouseX();
const delta = 2;
var dpr = window.devicePixelRatio / SpecialPowers.getFullZoom(window);
ok(p - delta <= x * dpr && x * dpr <= p + delta, "test" + test + " LastMouseX got " + p + " expected " + x +
" with fullZoom=" + SpecialPowers.getFullZoom(window) + " MozTransform='" + $("container").style.MozTransform + "'");
p = $("plugin1").getLastMouseY();
ok(p - delta <= y * dpr && y * dpr <= p + delta, "test" + test + " LastMouseY got " + p + " expected " + y +
" with fullZoom=" + SpecialPowers.getFullZoom(window) + " MozTransform='" + $("container").style.MozTransform + "'");
if (next) next();
}
function click(x, y, next) {
waitForPaint(function() { doClick(x, y, next); });
}
function zoom(factor) {
SpecialPowers.setFullZoom(window, factor);
}
function test1() { // fullZoom=1 (sanity check)
zoom(1);
click(55, 136, function() { verify("1", 55, 136, test2); });
}
function test2() { // fullZoom=2
zoom(2);
click(40, 108, function() { verify("2", 80, 216, test2b); });
}
function test2b() {
click(108, 112, function() { verify("2c", 216, 224, endTest); });
}
function endTest() {
zoom(1);
SimpleTest.finish();
}
setTimeout(function() { waitForPaint(test1); }, 1000);
}
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>
</head>
<body onload="runTests()">
<div id="container" style="position:relative;top: 0px; left: 0px; width: 640px; height: 480px;">
<div id="abs" style="position:absolute; left:90px; top:90px; width:20px; height:20px; background:blue; pointer-events:none;"></div>
<embed id="plugin1" type="application/x-test" wmode="transparent" width="200" height="200"></embed>
</div>
</body>
</html>

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

@ -1,113 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=539565
-->
<head>
<title>Test #2 for Bug 539565</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script class="testbody" type="text/javascript">
function runTests() {
var moveBy = 17;
var waitedForPaint = 0;
function waitForPaint(func) {
waitedForPaint = 0;
var testplugin = $("plugin1");
testplugin.last_paint_count = testplugin.getPaintCount ? testplugin.getPaintCount() : -2;
function waitForPaintCountIncrement() {
waitedForPaint++;
moveBy = -moveBy;
$("abs").style.left = ($("abs").offsetLeft + moveBy) + "px";
document.documentElement.offsetHeight;
var pc = testplugin.getPaintCount ? testplugin.getPaintCount() : -2;
if (waitedForPaint == 20 || (pc != testplugin.last_paint_count && pc >= 0)) {
setTimeout(func, 0);
} else {
setTimeout(waitForPaintCountIncrement, 50);
}
}
waitForPaintCountIncrement();
}
function doClick(x, y, func) {
synthesizeMouse($("plugin1"), x, y, {}, window);
setTimeout(func, 0);
}
function verify(test, x, y, next) {
var p = $("plugin1").getLastMouseX();
const delta = 2;
var dpr = window.devicePixelRatio / SpecialPowers.getFullZoom(window);
ok(p - delta <= x * dpr && x * dpr <= p + delta, "test" + test + " LastMouseX got " + p + " expected " + x +
" with fullZoom=" + SpecialPowers.getFullZoom(window) + " MozTransform='" + $("container").style.MozTransform + "'");
p = $("plugin1").getLastMouseY();
ok(p - delta <= y * dpr && y * dpr <= p + delta, "test" + test + " LastMouseY got " + p + " expected " + y +
" with fullZoom=" + SpecialPowers.getFullZoom(window) + " MozTransform='" + $("container").style.MozTransform + "'");
if (next) next();
}
function click(x, y, next) {
waitForPaint(function() { doClick(x, y, next); });
}
function zoom(factor) {
SpecialPowers.setFullZoom(window, factor);
}
function test3() { // fullZoom=1 + scale(2)
zoom(1);
//
// ======================== BUG WARNING =========================================
// 'container' already has -moz-transform:scale(2) in its style attribute.
// Removing that and setting MozTransform dynamically here (as in test4)
// makes the test fail ("getLastMouseX is not a function" in verify() above)
// Looks like the plugin instance got destroyed and we never recover from that...
// ==============================================================================
//
click(50, 136, function() { verify("3", 25, 68, test3b); });
}
function test3b() {
click(208, 212, function() { verify("3b", 104, 106, test4); });
}
function test4() { // fullZoom=2 + scale(0.5)
zoom(2);
var container = $("container");
container.style.MozTransformOrigin = "0px 0px";
container.style.MozTransform = "scale(0.5)";
document.documentElement.offsetHeight;
click(60, 52, function() { verify("4", 240, 208, test5); });
}
function test5() { // fullZoom=2 + scale(2)
zoom(2);
var container = $("container");
container.style.MozTransformOrigin = "0px 0px";
container.style.MozTransform = "scale(2)";
document.documentElement.offsetHeight;
click(108, 112, function() { verify("5", 108, 112, endTest); });
}
function endTest() {
zoom(1);
SimpleTest.finish();
}
setTimeout(function() { waitForPaint(test3); }, 1000);
}
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>
</head>
<body onload="runTests()">
<div id="container" style="position:relative;top: 0px; left: 0px; width: 640px; height: 480px; -moz-transform:scale(2); -moz-transform-origin:0px 0px;">
<div id="abs" style="position:absolute; left:90px; top:90px; width:20px; height:20px; background:blue; pointer-events:none;"></div>
<embed id="plugin1" type="application/x-test" wmode="transparent" width="200" height="200"></embed>
</div>
</body>
</html>

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

@ -1,81 +0,0 @@
<html>
<head>
<title>Bug 751809</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<script type="application/javascript">
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_CLICKTOPLAY);
</script>
</head>
<body onload="go();">
<embed id="plugin" type="application/x-test" width="400" height="400" drawmode="solid" color="FF00FFFF"></embed>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
const utils = window.windowUtils;
function go() {
var plugin = document.getElementById("plugin");
var objLoadingContent = SpecialPowers.wrap(plugin);
ok(!objLoadingContent.activated, "plugin should not be activated");
SimpleTest.waitForFocus(afterWindowFocus);
}
function afterWindowFocus() {
var plugin = document.getElementById("plugin");
var objLoadingContent = SpecialPowers.wrap(plugin);
objLoadingContent.playPlugin();
var condition = () => plugin.setColor !== undefined;
SimpleTest.waitForCondition(condition, afterPluginActivation,
"Waited too long for plugin to activate");
}
function afterPluginActivation() {
var plugin = document.getElementById("plugin");
var objLoadingContent = SpecialPowers.wrap(plugin);
ok(objLoadingContent.activated, "plugin should be activated now");
// Triggering a paint and waiting for it to be flushed makes sure
// that both plugin and platform see the plugin element as visible.
// See bug 805330 for details.
/* global waitForAllPaintsFlushed */
plugin.setColor("FF000088");
waitForAllPaintsFlushed(afterPaintsFlushed);
}
function afterPaintsFlushed() {
var plugin = document.getElementById("plugin");
try {
is(plugin.getMouseUpEventCount(), 0, "Plugin should not have received mouse events yet.");
} catch (e) {
ok(false, "plugin.getMouseUpEventCount() shouldn't throw");
}
synthesizeMouseAtCenter(plugin, {});
var condition = () => plugin.getMouseUpEventCount() > 0;
SimpleTest.waitForCondition(condition, afterFirstClick,
"Waited too long for plugin to receive the mouse click");
}
function afterFirstClick() {
var plugin = document.getElementById("plugin");
try {
is(plugin.getMouseUpEventCount(), 1, "Plugin should have received 1 mouse up event.");
} catch (e) {
ok(false, "plugin.getMouseUpEventCount() shouldn't throw");
}
SimpleTest.finish();
}
</script>
</body>
</html>

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

@ -1,48 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=771202
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 771202</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=771202">Mozilla Bug 771202</a>
<pre id="test">
<script type="application/javascript">
/** Test for recreating spliced plugin prototype chains after tranplant. **/
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
function go() {
// Set things up.
var win = document.getElementById("ifr").contentWindow;
var plugin = win.document.getElementById("pluginElement");
var testValue = plugin.getObjectValue();
function checkPlugin() {
dump("About to call checkObjectValue\n");
ok(plugin.checkObjectValue(testValue), "Plugin proto should work correctly");
}
// First, check things before transplanting.
checkPlugin();
// Adopt the plugin and retest.
document.body.appendChild(plugin);
checkPlugin();
// All done.
SimpleTest.finish();
}
</script>
</pre>
<iframe id="ifr" onload="go();" src="file_bug771202.html">
</body>
</html>

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

@ -1,59 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=777098
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 777098</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="go();">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=777098">Mozilla Bug 777098</a>
<pre id="test">
<script type="application/javascript">
/** Test for passing dead NPObjects back into plugins. **/
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
function go() {
var plugin = document.getElementById("plugin");
// Get wrapped npobject from plugin (plugin.__proto__)
var val = plugin.getObjectValue();
// Force a re-instantiate by re-setting dummy uri,
// making val a wrapper for a dead plugin
// eslint-disable-next-line no-self-assign
plugin.data = plugin.data;
// The correct behavior is an exception, if plugin.checkObjectValue succeeds
// the plugin wasn't torn down for some reason, and if we crash... that's bad
function pluginCheck() {
try {
plugin.checkObjectValue(val);
} catch (e) {
return true;
}
return false;
}
// Spin the event loop so the instantiation can complete
window.setTimeout(function() {
ok(pluginCheck(), "Shouldn't explode");
// All done.
SimpleTest.finish();
}, 0);
}
</script>
</pre>
<object data="data:text/plain,a" width=200 height=200 type="application/x-test" id="plugin"></object>
</body>
</html>

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

@ -1,85 +0,0 @@
<!doctype html>
<html>
<head>
<title>Test for Bug 784131</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<base href="chrome://browser/content/">
</head>
<body>
<script type="text/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>
<embed id="body" type="application/x-test">
<div>
<embed id="nested" type="application/x-test">
</div>
<script type="application/javascript">
function getObjectValue(obj) {
try {
return obj.getObjectValue();
} catch (e) {
return null;
}
}
SimpleTest.waitForExplicitFinish();
var body_embed = document.querySelector("embed#body");
var nested_embed = document.querySelector("embed#nested");
var nested_parent = nested_embed.parentNode;
// Ensure plugins are spawned
var body_obj = getObjectValue(body_embed);
var nested_obj = getObjectValue(nested_embed);
isnot(body_obj, null, "body plugin spawned");
isnot(nested_obj, null, "nested plugin spawned");
// Display:none the plugin and the nested plugin's parent
body_embed.style.display = "none";
nested_parent.style.display = "none";
body_embed.clientTop;
nested_embed.clientTop;
// Plugins should still be running the same instance
ok(body_embed.checkObjectValue(body_obj), "body plugin still running");
ok(nested_embed.checkObjectValue(nested_obj), "nested plugin still running");
// Spin event loop
SimpleTest.executeSoon(function() {
// Plugins should be stopped
is(getObjectValue(body_embed), null, "body plugin gone");
is(getObjectValue(nested_embed), null, "nested plugin gone");
// Restart plugins...
body_embed.style.display = "inherit";
nested_parent.style.display = "inherit";
// Ensure plugins are spawned
var body_objs = getObjectValue(body_embed);
var nested_objs = getObjectValue(nested_embed);
isnot(body_objs, null, "body plugin spawned");
isnot(nested_objs, null, "nested plugin spawned");
// Take away frames again, flush layout, restore frames
body_embed.style.display = "none";
nested_parent.style.display = "none";
body_embed.clientTop;
nested_embed.clientTop;
body_embed.style.display = "inherit";
nested_parent.style.display = "inherit";
body_embed.clientTop;
nested_embed.clientTop;
// Spin event loop, ensure plugin remains running
SimpleTest.executeSoon(function() {
ok(body_embed.checkObjectValue(body_objs), "body plugin still running");
ok(nested_embed.checkObjectValue(nested_objs), "nested plugin still running");
SimpleTest.finish();
});
});
</script>
</body>
</html>

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

@ -1,68 +0,0 @@
<!doctype html>
<html>
<head>
<title>Test for Bug 813906</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<base href="chrome://browser/content/">
</head>
<body>
<script type="application/javascript">
function f() {
document.getElementsByTagName("base")[0].href = "http://www.safe.com/";
}
</script>
<script type="application/javascript">
SimpleTest.requestFlakyTimeout(
"Blocking an iframe does not cause the onerror event to be fired");
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
var frameLoadCount = 0;
function frameNavBlocked() {
isnot(SpecialPowers.wrap(window.frame1).location.href.indexOf("chrome://"),
0, "plugin shouldnt be able to cause navigation to chrome URLs");
SimpleTest.finish();
}
function frameLoaded() {
frameLoadCount++;
if (frameLoadCount == 1) {
document.getElementsByTagName("object")[0].type = "application/x-test";
document.getElementsByTagName("use")[0].setAttributeNS("http://www.w3.org/1999/xlink", "href", location.href + "#a");
// wait two seconds and verify that frame navigation did not succeed
setTimeout(frameNavBlocked, 2000);
return;
}
// we should never get here, but just in case, make sure the test fails in that case.
ok(false, "onload() event should not fire for blocked navigation");
SimpleTest.finish();
}
</script>
<!-- Note that <svg:use> ends up creating an anonymous subtree, which means that the plugin
reflector gets hoisted into the XBL scope, and isn't accessible to content. We pass
the 'donttouchelement' parameter to the plugin to prevent it from trying to define the
'pluginFoundElement' property on the plugin reflector, since doing so would throw a
security exception. -->
<svg>
<symbol id="a">
<foreignObject>
<object bugmode="813906" frame="frame1"><param name="donttouchelement"></param></object>
</foreignObject>
</symbol>
<use />
</svg>
<iframe name="frame1" onload="frameLoaded()"></iframe>
</body>
</html>

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

@ -1,62 +0,0 @@
<!doctype html>
<html>
<head>
<title>Test for Bug 852315</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<base href="chrome://browser/content/">
</head>
<body>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
// Tests that the document-inactive notification stopping plugins does not
// fatally re-enter when adding other plugins to the document.
var i = document.createElement("iframe");
var ob = document.body;
i.addEventListener("load", function loadfunc() {
var d = i.contentWindow.document;
var e = i.contentDocument.createElement("embed");
var destroyran = false;
e.type = "application/x-test";
i.contentDocument.body.appendChild(e);
// On despawn, append an embed tag to document.
e.callOnDestroy(function() {
var e2 = d.createElement("embed");
d.body.appendChild(e2);
destroyran = true;
});
// Navigate the frame to cause the document with the plugin to go inactive
i.removeEventListener("load", loadfunc);
i.src = "about:blank";
const MAX_ATTEMPTS = 50;
var attempts = 0;
function checkPluginDestroyRan() {
// We may need to retry a few times until the plugin stop event makes
// its way through the event queue.
if (attempts < MAX_ATTEMPTS && !destroyran) {
++attempts;
SimpleTest.executeSoon(checkPluginDestroyRan);
} else {
info("Number of retry attempts: " + attempts);
ok(destroyran, "OnDestroy callback ran and did not crash");
SimpleTest.finish();
}
}
SimpleTest.executeSoon(checkPluginDestroyRan);
});
document.body.appendChild(i);
</script>
</body>
</html>

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

@ -1,38 +0,0 @@
<!doctype html>
<html>
<head>
<title>Test for Bug 854082</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<base href="chrome://browser/content/">
</head>
<body>
<script type="application/javascript">
// Tests that destroying the plugin's frame inside NPP_New does not cause a
// crash
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
// Create an object that will spawn asynchronously
var o = document.createElement("object");
o.type = "application/x-test";
// The test plugin sets pluginFoundElement on its element inside NPP_New,
// abuse this to run arbitrary script.
var setterCalled;
o.__defineSetter__("pluginFoundElement", function() {
o.style.display = "none";
// Access clientTop to force layout flush
o.clientTop;
ok(true, "Setter called and did not crash");
SimpleTest.finish();
setterCalled = true;
});
document.body.appendChild(o);
</script>
</body>
</html>

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

@ -1,40 +0,0 @@
<!doctype html>
<html>
<head>
<title>Test for Bug 863792</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<script type="application/javascript">
// A plugin that removes itself from the document and inactivates said document
// inside NPP_New. We should not leak the instance. See also test_bug854082
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
var i = document.createElement("iframe");
i.src = "file_bug863792.html";
i.width = 500;
i.height = 500;
document.body.appendChild(i);
i.addEventListener("load", function() {
SpecialPowers.forceGC();
SpecialPowers.forceCC();
SimpleTest.executeSoon(function() {
SpecialPowers.forceGC();
SpecialPowers.forceCC();
SimpleTest.executeSoon(function() {
ok(true, "Didn't crash");
SimpleTest.finish();
});
});
});
</script>
</body>
</html>

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

@ -1,78 +0,0 @@
<!doctype html>
<html>
<head>
<title>Test for Bug 967694</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<script type="application/javascript">
// Touching a plugin from chrome scope should not spawn it, bug should
// synchronously spawn it from content scope
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
var plugin;
var spPlugin;
function recreatePlugin() {
if (plugin) {
document.body.removeChild(plugin);
}
plugin = document.createElement("embed");
plugin.type = "application/x-test";
document.body.appendChild(plugin);
// Plugin should now be queued for async spawning.
spPlugin = SpecialPowers.wrap(plugin);
is(spPlugin.displayedType, spPlugin.TYPE_PLUGIN, "Should be configured as plugin");
ok(!spPlugin.hasRunningPlugin, "Should not be spawned yet");
}
recreatePlugin();
// Try various JS operations with chrome context
var thrown = false;
// Get and set non-existent Property
var hi = spPlugin._testShouldntExist;
spPlugin._testShouldntExist = 5;
// Call some test-plugin function
try {
var val = spPlugin.getObjectValue();
} catch (e) {
thrown = true;
}
ok(thrown, "Function call should have thrown");
ok(!spPlugin.hasRunningPlugin, "Plugin should not have spawned");
// Try property access from content
hi = plugin._testShouldntExistContent;
ok(spPlugin.hasRunningPlugin, "Should've caused plugin to spawn");
// Property set
recreatePlugin();
plugin._testShouldntExistContent = 5;
ok(spPlugin.hasRunningPlugin, "Should've caused plugin to spawn");
// Call test plugin function. Should succeed.
recreatePlugin();
thrown = false;
try {
var value = plugin.getObjectValue();
} catch (e) {
thrown = true;
}
ok(!thrown, "Call should have succeeded");
ok(spPlugin.hasRunningPlugin, "Call should have synchronously spawned plugin");
ok(plugin.checkObjectValue(value), "Plugin should recognize self");
</script>
</body>
</html>

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

@ -1,27 +0,0 @@
<!doctype html>
<html>
<head>
<title>Test for Bug 985859</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<base href="chrome://browser/content/">
</head>
<body>
<script type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
var testType = navigator.mimeTypes["application/x-test"];
var testTypeCap = navigator.mimeTypes["Application/x-Test"];
var testTypeCap2 = navigator.mimeTypes["APPLICATION/X-TEST"];
ok(testType, "Test plugin should be found");
is(testType, testTypeCap, "navigator.mimeTypes should be case insensitive");
is(testType, testTypeCap2, "navigator.mimeTypes should be case insensitive");
</script>
</body>
</html>

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

@ -1,20 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Test for Bug 986930</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="plugin-utils.js"></script>
</head>
<body>
<script class="testbody" type="application/javascript">
var testPlugin = getTestPlugin("Test Plug-in");
var mimeDescriptions = testPlugin.getMimeDescriptions();
is(mimeDescriptions[0], "Test \u2122 mimetype",
"Plugin should handle non-ascii mime description");
</script>
</body>
</html>

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

@ -1,49 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window title="Basic Plugin Tests"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<title>Plugin Busy Hang Test</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript" src="hang_test.js" />
<script type="application/javascript" src="plugin-utils.js"></script>
<script type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>
<body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
SimpleTest.expectChildProcessCrash();
async function runTests() {
// Default plugin hang timeout is too high for mochitests
var prefs = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefBranch);
var timeoutPref = "dom.ipc.plugins.timeoutSecs";
prefs.setIntPref(timeoutPref, 5);
var os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
os.addObserver(testObserver, "plugin-crashed", true);
testObserver.idleHang = false;
document.addEventListener("PluginCrashed", onPluginCrashed, false);
var pluginElement = document.getElementById("plugin1");
await SimpleTest.promiseWaitForCondition(() => pluginElement.hang !== undefined,
"Waited too long for plugin to activate");
try {
pluginElement.hang(true);
} catch (e) {
}
}
]]>
</script>
</window>

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

@ -1,242 +0,0 @@
<html>
<head>
<title>NPAPI ClearSiteData/GetSitesWithData Functionality</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
</head>
<body>
<script type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
const pluginHostIface = Ci.nsIPluginHost;
var pluginHost = Cc["@mozilla.org/plugin/host;1"].
getService(pluginHostIface);
const FLAG_CLEAR_ALL = pluginHostIface.FLAG_CLEAR_ALL;
const FLAG_CLEAR_CACHE = pluginHostIface.FLAG_CLEAR_CACHE;
var p = document.getElementById("plugin1");
// Since we're running with chrome permissions, accessing the plugin wont
// synchronously spawn it -- wait for the async spawning to finish.
SimpleTest.executeSoon(function() {
// Make sure clearing by timerange is supported.
p.setSitesWithDataCapabilities(true);
ok(PluginUtils.withTestPlugin(runTest), "Test plugin found");
});
function stored(needles) {
var something = pluginHost.siteHasData(this.pluginTag, null);
if (!needles)
return something;
if (!something)
return false;
for (var i = 0; i < needles.length; ++i) {
if (!pluginHost.siteHasData(this.pluginTag, needles[i]))
return false;
}
return true;
}
function checkThrows(fn, result) {
try {
fn();
throw new Error("bad exception");
} catch (e) {
is(e.result, result, "Correct exception thrown");
}
}
function runTest(pluginTag) {
this.pluginTag = pluginTag;
p.setSitesWithData(
"foo.com:0:5," +
"foo.com:0:7," +
"bar.com:0:10," +
"baz.com:0:10," +
"foo.com:1:7," +
"qux.com:1:5," +
"quz.com:1:8"
);
ok(stored(["foo.com", "bar.com", "baz.com", "qux.com", "quz.com"]),
"Data stored for sites");
// Clear nothing.
pluginHost.clearSiteData(pluginTag, null, FLAG_CLEAR_ALL, 4, {callback() { test1(); }});
}
function test1() {
ok(stored(["foo.com", "bar.com", "baz.com", "qux.com", "quz.com"]),
"Data stored for sites");
pluginHost.clearSiteData(this.pluginTag, null, FLAG_CLEAR_CACHE, 4, {callback() { test2(); }});
}
function test2() {
ok(stored(["foo.com", "bar.com", "baz.com", "qux.com", "quz.com"]),
"Data stored for sites");
// Clear cache data 5 seconds or older.
pluginHost.clearSiteData(this.pluginTag, null, FLAG_CLEAR_CACHE, 5, {callback() { test3(); }});
}
function test3() {
ok(stored(["foo.com", "bar.com", "baz.com", "quz.com"]),
"Data stored for sites");
ok(!stored(["qux.com"]), "Data cleared for qux.com");
// Clear cache data for foo.com, but leave non-cache data.
pluginHost.clearSiteData(this.pluginTag, "foo.com", FLAG_CLEAR_CACHE, 20, {callback() { test4(); }});
}
function test4() {
ok(stored(["foo.com", "bar.com", "baz.com", "quz.com"]),
"Data stored for sites");
// Clear all data 7 seconds or older.
pluginHost.clearSiteData(this.pluginTag, null, FLAG_CLEAR_ALL, 7, {callback() { test5(); }});
}
function test5() {
ok(stored(["bar.com", "baz.com", "quz.com"]), "Data stored for sites");
ok(!stored(["foo.com"]), "Data cleared for foo.com");
ok(!stored(["qux.com"]), "Data cleared for qux.com");
// Clear all cache data.
pluginHost.clearSiteData(this.pluginTag, null, FLAG_CLEAR_CACHE, 20, {callback() { test6(); }});
}
function test6() {
ok(stored(["bar.com", "baz.com"]), "Data stored for sites");
ok(!stored(["quz.com"]), "Data cleared for quz.com");
// Clear all data for bar.com.
pluginHost.clearSiteData(this.pluginTag, "bar.com", FLAG_CLEAR_ALL, 20, {callback(rv) { test7(rv); }});
}
function test7() {
ok(stored(["baz.com"]), "Data stored for baz.com");
ok(!stored(["bar.com"]), "Data cleared for bar.com");
// Disable clearing by age.
p.setSitesWithDataCapabilities(false);
pluginHost.clearSiteData(this.pluginTag, null, FLAG_CLEAR_ALL, 20, {callback(rv) {
is(rv, Cr.NS_ERROR_PLUGIN_TIME_RANGE_NOT_SUPPORTED);
test8(rv);
}});
}
function test8() {
pluginHost.clearSiteData(this.pluginTag, null, FLAG_CLEAR_CACHE, 20, {callback(rv) {
is(rv, Cr.NS_ERROR_PLUGIN_TIME_RANGE_NOT_SUPPORTED);
test9(rv);
}});
}
function test9() {
pluginHost.clearSiteData(this.pluginTag, "baz.com", FLAG_CLEAR_ALL, 20, {callback(rv) {
is(rv, Cr.NS_ERROR_PLUGIN_TIME_RANGE_NOT_SUPPORTED);
test10(rv);
}});
}
function test10() {
pluginHost.clearSiteData(this.pluginTag, "baz.com", FLAG_CLEAR_CACHE, 20, {callback(rv) {
is(rv, Cr.NS_ERROR_PLUGIN_TIME_RANGE_NOT_SUPPORTED);
test11();
}});
}
function test11() {
// Clear cache for baz.com and globally for all ages.
pluginHost.clearSiteData(this.pluginTag, "baz.com", FLAG_CLEAR_CACHE, -1, {callback(rv) { test12(); }});
}
function test12() {
pluginHost.clearSiteData(this.pluginTag, null, FLAG_CLEAR_CACHE, -1, {callback(rv) { test13(); }});
}
function test13() {
// Check that all of the above were no-ops.
ok(stored(["baz.com"]), "Data stored for baz.com");
// Clear everything for baz.com.
pluginHost.clearSiteData(this.pluginTag, "baz.com", FLAG_CLEAR_ALL, -1, {callback(rv) { test14(); }});
}
function test14() {
ok(!stored(["baz.com"]), "Data cleared for baz.com");
ok(!stored(null), "All data cleared");
// Set data to test subdomains, IP literals, and 'localhost'-like hosts.
p.setSitesWithData(
"foo.com:0:0," +
"bar.foo.com:0:0," +
"baz.foo.com:0:0," +
"bar.com:0:0," +
"[192.168.1.1]:0:0," +
"localhost:0:0"
);
ok(stored(["foo.com", "nonexistent.foo.com", "bar.com", "192.168.1.1", "localhost"]),
"Data stored for sites");
// Clear data for "foo.com" and its subdomains.
pluginHost.clearSiteData(this.pluginTag, "foo.com", FLAG_CLEAR_ALL, -1, {callback(rv) { test15(); }});
}
function test15() {
ok(stored(["bar.com", "192.168.1.1", "localhost"]), "Data stored for sites");
ok(!stored(["foo.com"]), "Data cleared for foo.com");
ok(!stored(["bar.foo.com"]), "Data cleared for subdomains of foo.com");
// Clear data for "bar.com" using a subdomain.
pluginHost.clearSiteData(this.pluginTag, "foo.bar.com", FLAG_CLEAR_ALL, -1, {callback(rv) { test16(); }});
}
function test16() {
ok(!stored(["bar.com"]), "Data cleared for bar.com");
// Clear data for "192.168.1.1".
pluginHost.clearSiteData(this.pluginTag, "192.168.1.1", FLAG_CLEAR_ALL, -1, {callback(rv) { test17(); }});
}
function test17() {
ok(!stored(["192.168.1.1"]), "Data cleared for 192.168.1.1");
// Clear data for "localhost".
pluginHost.clearSiteData(this.pluginTag, "localhost", FLAG_CLEAR_ALL, -1, {callback(rv) { test18(); }});
}
function test18() {
ok(!stored(null), "All data cleared");
// Set data to test international domains.
p.setSitesWithData(
"b\u00FCcher.es:0:0," +
"b\u00FCcher.uk:0:0," +
"xn--bcher-kva.NZ:0:0"
);
// Check that both the ACE and UTF-8 representations register.
ok(stored(["b\u00FCcher.es", "xn--bcher-kva.es", "b\u00FCcher.uk", "xn--bcher-kva.uk"]),
"Data stored for sites");
// Clear data for the UTF-8 version.
pluginHost.clearSiteData(this.pluginTag, "b\u00FCcher.es", FLAG_CLEAR_ALL, -1, {callback(rv) { test19(); }});
}
function test19() {
ok(!stored(["b\u00FCcher.es"]), "Data cleared for UTF-8 representation");
ok(!stored(["xn--bcher-kva.es"]), "Data cleared for ACE representation");
// Clear data for the ACE version.
pluginHost.clearSiteData(this.pluginTag, "xn--bcher-kva.uk", FLAG_CLEAR_ALL, -1, {callback(rv) { test20(); }});
}
function test20() {
ok(!stored(["b\u00FCcher.uk"]), "Data cleared for UTF-8 representation");
ok(!stored(["xn--bcher-kva.uk"]), "Data cleared for ACE representation");
// The NPAPI spec requires that the plugin report sites in normalized
// UTF-8. We do happen to normalize the result anyway, so while that's not
// strictly required, we test it here.
ok(stored(["b\u00FCcher.nz", "xn--bcher-kva.nz"]),
"Data stored for sites");
pluginHost.clearSiteData(this.pluginTag, "b\u00FCcher.nz", FLAG_CLEAR_ALL, -1, {callback(rv) { test21(); }});
}
function test21() {
ok(!stored(["b\u00FCcher.nz"]), "Data cleared for UTF-8 representation");
ok(!stored(["xn--bcher-kva.nz"]), "Data cleared for ACE representation");
ok(!stored(null), "All data cleared");
SimpleTest.finish();
}
</script>
</body>
</html>

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

@ -1,28 +0,0 @@
<html>
<head>
<title>NPCocoaEventFocusChanged Tests</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="runTests()">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
var gOtherWindow;
function runTests() {
// We have to have two top-level windows in play in order to run these tests.
gOtherWindow = window.open("cocoa_focus.html", "", "width=250,height=250");
}
function testsFinished() {
// Tests have finished running, close the new window and end tests.
gOtherWindow.close();
SimpleTest.finish();
}
</script>
</body>
</html>

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

@ -1,28 +0,0 @@
<html>
<head>
<title>NPCocoaEventWindowFocusChanged Tests</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="runTests()">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
var gOtherWindow;
function runTests() {
// We have to have two top-level windows in play in order to run these tests.
gOtherWindow = window.open("cocoa_window_focus.html", "", "width=200,height=200");
}
function testsFinished() {
// Tests have finished running, close the new window and end tests.
gOtherWindow.close();
SimpleTest.finish();
}
</script>
</body>
</html>

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

@ -1,83 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window title="Basic Plugin Tests"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript" src="plugin-utils.js"></script>
<script type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>
<body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
async function runTests() {
var pluginElement = document.getElementById("plugin1");
await SimpleTest.promiseWaitForCondition(() => pluginElement.convertPointX !== undefined,
"Waited too long for plugin to activate");
// Poll to see if the plugin is in the right place yet.
// Check if x-coordinate 0 in plugin space is 0 in window space. If it is,
// the plugin hasn't been placed yet.
if (pluginElement.convertPointX(1, 0, 0, 2) == 0) {
setTimeout(runTests, 0);
return;
}
var domWindowUtils = window.windowUtils;
var pluginRect = pluginElement.getBoundingClientRect();
var pluginX = pluginRect.left + (window.mozInnerScreenX - window.screenX);
var pluginY = pluginRect.top + (window.mozInnerScreenY - window.screenY);
var windowX = window.screenX;
var windowY = window.screenY;
var windowHeight = window.outerHeight;
var screenHeight = window.screen.height;
// arbitrary coordinates of test point in plugin top-left origin terms
var xOffset = 5;
var yOffset = 5;
var NPCoordinateSpacePluginX = 0 + xOffset;
var NPCoordinateSpacePluginY = 0 + yOffset;
var NPCoordinateSpaceWindowX = pluginX + xOffset;
var NPCoordinateSpaceWindowY = (windowHeight - pluginY) - yOffset;
var NPCoordinateSpaceFlippedWindowX = pluginX + xOffset;
var NPCoordinateSpaceFlippedWindowY = pluginY + yOffset;
var NPCoordinateSpaceScreenX = windowX + pluginX + xOffset;
var NPCoordinateSpaceScreenY = ((screenHeight - windowY) - pluginY) - yOffset;
var NPCoordinateSpaceFlippedScreenX = windowX + pluginX + xOffset;
var NPCoordinateSpaceFlippedScreenY = windowY + pluginY + yOffset;
// these are in coordinate space enumeration order
var xValues = new Array(NPCoordinateSpacePluginX, NPCoordinateSpaceWindowX, NPCoordinateSpaceFlippedWindowX, NPCoordinateSpaceScreenX, NPCoordinateSpaceFlippedScreenX);
var yValues = new Array(NPCoordinateSpacePluginY, NPCoordinateSpaceWindowY, NPCoordinateSpaceFlippedWindowY, NPCoordinateSpaceScreenY, NPCoordinateSpaceFlippedScreenY);
var i;
for (i = 0; i < 5; i = i + 1) {
var sourceCoordSpaceValue = i + 1;
var j;
for (j = 0; j < 5; j = j + 1) {
var destCoordSpaceValue = j + 1;
xResult = pluginElement.convertPointX(sourceCoordSpaceValue, xValues[i], yValues[i], destCoordSpaceValue);
yResult = pluginElement.convertPointY(sourceCoordSpaceValue, xValues[i], yValues[i], destCoordSpaceValue);
is(xResult, xValues[j], "convertPointX: space " + sourceCoordSpaceValue + " to space " + destCoordSpaceValue + " mismatch");
is(yResult, yValues[j], "convertPointY: space " + sourceCoordSpaceValue + " to space " + destCoordSpaceValue + " mismatch");
}
}
SimpleTest.finish();
}
]]>
</script>
</window>

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

@ -1,40 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test copying text from browser to plugin</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<script class="testbody" type="text/javascript">
function runTests() {
var text = " some text \n to copy 'n paste ";
var textElt = document.getElementById("input");
var plugin = document.getElementById("plugin1");
// Make sure we wait for the clipboard
SimpleTest.waitForClipboard(text, () => {
textElt.focus();
textElt.value = text;
textElt.select();
SpecialPowers.wrap(textElt).editor.copy();
}, () => {
is(plugin.getClipboardText(), text);
SimpleTest.finish();
}, () => {
ok(false, "Failed to set the clipboard text!");
SimpleTest.finish();
});
}
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>
</head>
<body onload="runTests()">
<embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
<textarea id="input"></textarea>
</body>
</html>

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

@ -1,44 +0,0 @@
<head>
<title>Plugin crashing in nested loop</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<body>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
window.frameLoaded = function frameLoaded_toCrash() {
var iframe = document.getElementById("iframe1");
var p = iframe.contentDocument.getElementById("plugin1");
// This test is for bug 550026, which is inherently nondeterministic.
// If we hit that bug, the browser process would crash when the plugin
// crashes in crashInNestedLoop. If not, we'll pass "spuriously".
try {
p.crashInNestedLoop();
// The plugin didn't crash when expected. This happens sometimes. Give
// it longer to crash. If it crashes (but not at the apropriate time),
// soft fail with a todo; if it doesn't crash then something went wrong,
// so fail.
SimpleTest.requestFlakyTimeout("sometimes the plugin takes a little longer to crash");
setTimeout(
function() {
try {
p.getPaintCount();
ok(false, "plugin should crash");
} catch (e) {
todo(false, "p.crashInNestedLoop() should throw an exception");
}
SimpleTest.finish();
},
1000);
} catch (e) {
ok(true, "p.crashInNestedLoop() should throw an exception");
SimpleTest.finish();
}
};
</script>
<iframe id="iframe1" src="crashing_subpage.html" width="600" height="600"></iframe>

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

@ -1,119 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window title="Basic Plugin Tests"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript" src="plugin-utils.js"></script>
<script type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>
<body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
const {PromiseUtils} = ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm");
SimpleTest.waitForExplicitFinish();
SimpleTest.expectChildProcessCrash();
var success = false;
var observerFired = false;
var observerDeferred = PromiseUtils.defer();
var eventListenerDeferred = PromiseUtils.defer();
var testObserver = {
observe: function(subject, topic, data) {
observerFired = true;
ok(true, "Observer fired");
is(topic, "plugin-crashed", "Checking correct topic");
is(data, null, "Checking null data");
ok((subject instanceof Ci.nsIPropertyBag2), "got Propbag");
ok((subject instanceof Ci.nsIWritablePropertyBag2), "got writable Propbag");
var id = subject.getPropertyAsAString("pluginDumpID");
isnot(id, "", "got a non-empty crash id");
ok(subject.hasKey("additionalMinidumps"), "the additionalMinidumps key is present");
let directoryService =
Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
let profD = directoryService.get("ProfD", Ci.nsIFile);
profD.append("minidumps");
let dumpFile = profD.clone();
dumpFile.append(id + ".dmp");
ok(dumpFile.exists(), "minidump exists");
let extraFile = profD.clone();
extraFile.append(id + ".extra");
ok(extraFile.exists(), "extra file exists");
observerDeferred.resolve();
},
QueryInterface: function(iid) {
if (iid.equals(Ci.nsIObserver) ||
iid.equals(Ci.nsISupportsWeakReference) ||
iid.equals(Ci.nsISupports))
return this;
throw Components.Exception("", Cr.NS_NOINTERFACE);
}
};
function onPluginCrashed(aEvent) {
ok(true, "Plugin crashed notification received");
ok(observerFired, "Observer should have fired first");
is(aEvent.type, "PluginCrashed", "event is correct type");
var pluginElement = document.getElementById("plugin1");
is (pluginElement, aEvent.target, "Plugin crashed event target is plugin element");
ok(aEvent instanceof PluginCrashedEvent,
"plugin crashed event has the right interface");
is(typeof aEvent.pluginDumpID, "string", "pluginDumpID is correct type");
isnot(aEvent.pluginDumpID, "", "got a non-empty dump ID");
is(typeof aEvent.pluginName, "string", "pluginName is correct type");
is(aEvent.pluginName, "Test Plug-in", "got correct plugin name");
is(typeof aEvent.pluginFilename, "string", "pluginFilename is correct type");
isnot(aEvent.pluginFilename, "", "got a non-empty filename");
// The app itself may or may not have decided to submit the report, so
// allow either true or false here.
ok("submittedCrashReport" in aEvent, "submittedCrashReport is a property of event");
is(typeof aEvent.submittedCrashReport, "boolean", "submittedCrashReport is correct type");
var os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
os.removeObserver(testObserver, "plugin-crashed");
eventListenerDeferred.resolve();
}
async function runTests() {
var os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
os.addObserver(testObserver, "plugin-crashed", true);
document.addEventListener("PluginCrashed", onPluginCrashed, false);
var pluginElement = document.getElementById("plugin1");
await SimpleTest.promiseWaitForCondition(() => pluginElement.crash !== undefined,
"Waited too long for plugin to activate");
try {
pluginElement.crash();
} catch (e) {
}
Promise.all([
observerDeferred.promise,
eventListenerDeferred.promise
]).then(() => {
SimpleTest.finish();
});
}
]]>
</script>
</window>

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

@ -1,125 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window title="Basic Plugin Tests"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript" src="plugin-utils.js"></script>
<script type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>
<body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
SimpleTest.waitForExplicitFinish();
var success = false;
var observerFired = false;
var testObserver = {
observe: function(subject, topic, data) {
observerFired = true;
ok(true, "Observer fired");
is(topic, "plugin-crashed", "Checking correct topic");
is(data, null, "Checking null data");
ok((subject instanceof Ci.nsIPropertyBag2), "got Propbag");
ok((subject instanceof Ci.nsIWritablePropertyBag2),
"got writable Propbag");
var id = subject.getPropertyAsAString("pluginDumpID");
isnot(id, "", "got a non-empty crash id");
ok(subject.hasKey("additionalMinidumps"), "the additionalMinidumps key is present");
let directoryService =
Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
let pendingD = directoryService.get("UAppData",
Ci.nsIFile);
pendingD.append("Crash Reports");
pendingD.append("pending");
let dumpFile = pendingD.clone();
dumpFile.append(id + ".dmp");
ok(dumpFile.exists(), "minidump exists");
let extraFile = pendingD.clone();
extraFile.append(id + ".extra");
ok(extraFile.exists(), "extra file exists");
Services.crashmanager.ensureCrashIsPresent(id).then(() => {
// cleanup, to be nice, this will execute before SimpleTest.finish()
dumpFile.remove(false);
extraFile.remove(false);
});
},
QueryInterface: function(iid) {
if (iid.equals(Ci.nsIObserver) ||
iid.equals(Ci.nsISupportsWeakReference) ||
iid.equals(Ci.nsISupports))
return this;
throw Components.Exception("", Cr.NS_NOINTERFACE);
}
};
function onPluginCrashed(aEvent) {
ok(true, "Plugin crashed notification received");
ok(observerFired, "Observer should have fired first");
is(aEvent.type, "PluginCrashed", "event is correct type");
var pluginElement = document.getElementById("plugin1");
is (pluginElement, aEvent.target, "Plugin crashed event target is plugin element");
ok(aEvent instanceof PluginCrashedEvent,
"plugin crashed event has the right interface");
is(typeof aEvent.pluginName, "string", "pluginName is correct type");
is(aEvent.pluginName, "Test Plug-in");
// The app itself may or may not have decided to submit the report, so
// allow either true or false here.
ok("submittedCrashReport" in aEvent, "submittedCrashReport is a property of event");
is(typeof aEvent.submittedCrashReport, "boolean", "submittedCrashReport is correct type");
var os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
os.removeObserver(testObserver, "plugin-crashed");
// re-set MOZ_CRASHREPORTER_NO_REPORT
let env = Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment);
env.set("MOZ_CRASHREPORTER_NO_REPORT", "1");
Services.crashmanager.ensureCrashIsPresent(aEvent.pluginDumpID).then(() => {
SimpleTest.finish();
});
}
async function runTests() {
// the test harness will have set MOZ_CRASHREPORTER_NO_REPORT,
// ensure that we can change the setting and have our minidumps
// wind up in Crash Reports/pending
let env = Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment);
env.set("MOZ_CRASHREPORTER_NO_REPORT", "");
var os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
os.addObserver(testObserver, "plugin-crashed", true);
document.addEventListener("PluginCrashed", onPluginCrashed, false);
var pluginElement = document.getElementById("plugin1");
await SimpleTest.promiseWaitForCondition(() => pluginElement.crash !== undefined,
"Waited too long for plugin to activate");
try {
pluginElement.crash();
} catch (e) {
}
}
]]>
</script>
</window>

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

@ -1,160 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window title="Basic Plugin Tests"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" />
<script type="application/javascript" src="plugin-utils.js"></script>
<script type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>
<body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
SimpleTest.ignoreAllUncaughtExceptions();
const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
var crashReporter =
Cc["@mozilla.org/toolkit/crash-reporter;1"]
.getService(Ci.nsICrashReporter);
var oldServerURL = crashReporter.serverURL;
const SERVER_URL = "http://example.com/browser/toolkit/crashreporter/test/browser/crashreport.sjs";
var testObserver = {
observe: function(subject, topic, data) {
if (data == "submitting") // not done yet
return;
is(data, "success", "report should have been submitted successfully");
is(topic, "crash-report-status", "Checking correct topic");
ok(subject instanceof Ci.nsIPropertyBag2,
"Subject should be a property bag");
ok(subject.hasKey("minidumpID"), "Should have a local crash ID");
let crashID = subject.getPropertyAsAString("minidumpID");
isnot(crashID, "", "Local crash ID should not be an empty string");
ok(subject.hasKey("serverCrashID"), "Should have a server crash ID");
let remoteID = subject.getPropertyAsAString("serverCrashID");
isnot(remoteID, "", "Server crash ID should not be an empty string");
// Verify the data. The SJS script will return the data that was POSTed
let req = new XMLHttpRequest();
req.open("GET", SERVER_URL + "?id=" + remoteID, false);
req.send(null);
is(req.status, 200, "Server response should be 200 OK");
let submitted = JSON.parse(req.responseText);
ok(!("Throttleable" in submitted), "Submit request should not be Throttleable");
is(submitted.ProcessType, "plugin", "Should specify ProcessType=plugin");
// Cleanup
// First remove our fake submitted report
let file = Services.dirsvc.get("UAppData", Ci.nsIFile);
file.append("Crash Reports");
file.append("submitted");
file.append(remoteID + ".txt");
file.remove(false);
// Next unregister our observer
var os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
os.removeObserver(testObserver, "crash-report-status");
// Then re-set MOZ_CRASHREPORTER_NO_REPORT
let env = Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment);
env.set("MOZ_CRASHREPORTER_NO_REPORT", "1");
// Finally re-set crashreporter URL
crashReporter.serverURL = oldServerURL;
// Check and cleanup CrashManager.
(async function() {
let cm = Services.crashmanager;
await cm.ensureCrashIsPresent(crashID);
let store = await cm._getStore();
is(store.crashesCount, 1, "Store should have only 1 item");
let crash = store.getCrash(crashID);
ok(!!crash, "Store should have the crash record");
ok(crash.isOfType(cm.PROCESS_TYPE_PLUGIN, cm.CRASH_TYPE_CRASH),
"Crash type should be plugin-crash");
is(crash.remoteID, remoteID, "Crash remoteID should match");
is(crash.submissions.size, 1, "Crash should have a submission");
let submission = crash.submissions.values().next().value;
is(submission.result, cm.SUBMISSION_RESULT_OK,
"Submission should be successful");
store.reset();
SimpleTest.finish();
})();
},
QueryInterface: function(iid) {
if (iid.equals(Ci.nsIObserver) ||
iid.equals(Ci.nsISupportsWeakReference) ||
iid.equals(Ci.nsISupports))
return this;
throw Components.Exception("", Cr.NS_NOINTERFACE);
}
};
async function onPluginCrashed(aEvent) {
ok(true, "Plugin crashed notification received");
is(aEvent.type, "PluginCrashed", "event is correct type");
await SimpleTest.promiseWaitForCondition(
() => aEvent.target.openOrClosedShadowRoot.getElementById("submitButton"),
"Waiting for submit button to exist."
);
let submitButton = aEvent.target.openOrClosedShadowRoot.getElementById("submitButton");
// try to submit this report
sendMouseEvent({type:'click'}, submitButton, window);
}
function runTests() {
// the test harness will have set MOZ_CRASHREPORTER_NO_REPORT,
// ensure that we can change the setting and have our minidumps
// wind up in Crash Reports/pending
let env = Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment);
env.set("MOZ_CRASHREPORTER_NO_REPORT", "");
// Override the crash reporter URL to send to our fake server
crashReporter.serverURL = NetUtil.newURI(SERVER_URL);
var os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
os.addObserver(testObserver, "crash-report-status", true);
document.addEventListener("PluginCrashed", onPluginCrashed, false);
var pluginElement = document.getElementById("plugin1");
try {
(async function() {
// Clear data in CrashManager in case previous tests caused something
// to be added.
let store = await Services.crashmanager._getStore();
store.reset();
await SimpleTest.promiseWaitForCondition(() => pluginElement.crash !== undefined,
"Waited too long for plugin to activate");
pluginElement.crash();
})();
} catch (e) {
}
}
]]>
</script>
</window>

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

@ -1,58 +0,0 @@
<head>
<title>Plugin crashing</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<body>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
window.frameLoaded = function frameLoaded_toCrash() {
SimpleTest.expectChildProcessCrash();
var iframe = document.getElementById("iframe1");
var p = iframe.contentDocument.getElementById("plugin1");
p.setColor("FFFF00FF");
try {
p.crash();
ok(false, "p.crash() should throw an exception");
} catch (e) {
ok(true, "p.crash() should throw an exception");
}
// Create random identifiers to test bug 560213
for (var i = 0; i < 5; ++i) {
var r = "rid_" + Math.floor(Math.random() * 10000 + 1);
try {
ok(!(r in p), "unknown identifier in crashed plugin should fail silently");
} catch (e) {
ok(false, "unknown identifier check threw");
}
}
try {
p.setColor("FFFF0000");
ok(false, "p.setColor should throw after the plugin crashes");
} catch (e) {
ok(true, "p.setColor should throw after the plugin crashes");
}
window.frameLoaded = function reloaded() {
var p1 = iframe.contentDocument.getElementById("plugin1");
try {
p1.setColor("FF00FF00");
ok(true, "Reloading worked");
} catch (e) {
ok(false, "Reloading didn't give us a usable plugin");
}
SimpleTest.finish();
};
iframe.contentWindow.location.reload();
};
</script>
<iframe id="iframe1" src="crashing_subpage.html" width="600" height="600"></iframe>

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

@ -1,72 +0,0 @@
<head>
<title>Plugin crashing</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<body onload="mainLoaded()">
<iframe id="iframe1" src="about:blank" width="600" height="600"></iframe>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
var iframe = document.getElementById("iframe1");
function mainLoaded() {
SimpleTest.expectChildProcessCrash();
var p = iframe.contentDocument.createElement("embed");
p.setAttribute("id", "plugin1");
p.setAttribute("type", "application/x-test");
p.setAttribute("width", "400");
p.setAttribute("height", "400");
p.setAttribute("drawmode", "solid");
p.setAttribute("color", "FF00FFFF");
p.setAttribute("newCrash", "true");
iframe.contentDocument.body.appendChild(p);
// The plugin will now crash when it is instantiated, but
// that happens asynchronously. HACK: this should use an
// event instead of nested pending runnables, but I don't
// know of any DOM event that's fired when a plugin is
// instantiated.
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
ok(p.setColor === undefined,
"Plugin should have crashed on creation");
window.frameLoaded = reloaded1;
iframe.contentWindow.location.replace("crashing_subpage.html");
});
});
}
function reloaded1() {
var p = iframe.contentDocument.getElementById("plugin1");
try {
p.setColor("FF00FF00");
ok(true, "Reloading after crash-on-new worked");
} catch (e) {
ok(false, "Reloading after crash-on-new didn't give us a usable plugin");
}
p.crashOnDestroy();
// the child crash should happen here
p.remove();
window.frameLoaded = reloaded2;
SimpleTest.executeSoon(function() {
iframe.contentWindow.location.reload();
});
}
function reloaded2() {
var p = iframe.contentDocument.getElementById("plugin1");
try {
p.setColor("FF00FF00");
ok(true, "Reloading after crash-on-destroy worked");
} catch (e) {
ok(false, "Reloading after crash-on-destroy didn't give us a usable plugin");
}
SimpleTest.finish();
}
</script>

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

@ -1,38 +0,0 @@
<html>
<head>
<title>NPObject [[DefaultValue]] implementation</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="run()">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
function run() {
var plugin = document.getElementById("plugin");
var pluginProto = Object.getPrototypeOf(plugin);
plugin.propertyAndMethod = {};
plugin.propertyAndMethod + "baz";
ok(true, "|plugin.propertyAndMethod + \"baz\"| shouldn't assert");
pluginProto.propertyAndMethod = {};
pluginProto.propertyAndMethod + "quux";
ok(true, "|pluginProto.propertyAndMethod + \"quux\"| shouldn't assert");
plugin + "foo";
ok(true, "|plugin + \"foo\"| shouldn't assert");
pluginProto + "bar";
ok(true, "|pluginProto + \"bar\"| shouldn't assert");
SimpleTest.finish();
}
</script>
<embed id="plugin" type="application/x-test" wmode="window"></embed>
</body>
</html>

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

@ -1,36 +0,0 @@
<html>
<head>
<title>NPAPI Cookie Tests</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
</head>
<body onload="runTests()">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
function runTests() {
var pluginElement = document.getElementById("plugin1");
var c = 0;
var foundSetColor = false;
for (var n in pluginElement) {
++c;
ok(n in pluginElement, "Enumerated property which doesn't exist?");
if (n == "setColor")
foundSetColor = true;
}
ok(c > 0, "Should have enumerated some properties");
ok(foundSetColor, "Should have enumerated .setColor");
SimpleTest.finish();
}
</script>
<p id="display"></p>
<embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
</body>
</html>

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

@ -1,164 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window title="Basic Plugin Tests"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" />
<script type="application/javascript" src="plugin-utils.js"></script>
<script type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>
<body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
SimpleTest.ignoreAllUncaughtExceptions();
const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const crashReporter = Cc["@mozilla.org/toolkit/crash-reporter;1"].getService(Ci.nsICrashReporter);
const SERVER_URL = "http://example.com/browser/toolkit/crashreporter/test/browser/crashreport.sjs";
var oldServerURL = crashReporter.serverURL;
const oldTimeoutPref = Services.prefs.getIntPref("dom.ipc.plugins.timeoutSecs");
var testObserver = {
observe: function(subject, topic, data) {
if (data == "submitting") // not done yet
return;
is(data, "success", "report should have been submitted successfully");
is(topic, "crash-report-status", "Checking correct topic");
ok(subject instanceof Ci.nsIPropertyBag2, "Subject should be a property bag");
ok(subject.hasKey("minidumpID"), "Should have a local crash ID");
let crashID = subject.getPropertyAsAString("minidumpID");
isnot(crashID, "", "Local crash ID should not be an empty string");
ok(subject.hasKey("serverCrashID"), "Should have a server crash ID");
let remoteID = subject.getPropertyAsAString("serverCrashID");
isnot(remoteID, "", "Server crash ID should not be an empty string");
// Verify the data. The SJS script will return the data that was POSTed
let req = new XMLHttpRequest();
req.open("GET", SERVER_URL + "?id=" + remoteID, false);
req.send(null);
is(req.status, 200, "Server response should be 200 OK");
let submitted = JSON.parse(req.responseText);
ok(!("Throttleable" in submitted), "Submit request should not be Throttleable");
is(submitted.ProcessType, "plugin", "Should specify ProcessType=plugin");
ok("PluginHang" in submitted, "Request should contain PluginHang field");
ok("additional_minidumps" in submitted, "Request should contain additional_minidumps field");
let dumpNames = submitted.additional_minidumps.split(',');
ok(dumpNames.includes("browser"), "additional_minidumps should contain browser");
info("additional_minidumps="+submitted.additional_minidumps);
ok("upload_file_minidump" in submitted, "Request should contain upload_file_minidump field");
ok("upload_file_minidump_browser" in submitted, "Request should contain upload_file_minidump_browser field");
// Cleanup
// First remove our fake submitted report
let file = Services.dirsvc.get("UAppData", Ci.nsIFile);
file.append("Crash Reports");
file.append("submitted");
file.append(remoteID + ".txt");
file.remove(false);
// Next unregister our observer
Services.obs.removeObserver(testObserver, "crash-report-status");
// Then re-set MOZ_CRASHREPORTER_NO_REPORT
let env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
env.set("MOZ_CRASHREPORTER_NO_REPORT", "1");
// Finally re-set prefs
crashReporter.serverURL = oldServerURL;
Services.prefs.setIntPref("dom.ipc.plugins.timeoutSecs", oldTimeoutPref);
// Check and cleanup CrashManager.
(async function() {
let cm = Services.crashmanager;
await cm.ensureCrashIsPresent(crashID);
let store = await cm._getStore();
is(store.crashesCount, 1, "Store should have only 1 item");
let crash = store.getCrash(crashID);
ok(!!crash, "Store should have the crash record");
ok(crash.isOfType(cm.PROCESS_TYPE_PLUGIN, cm.CRASH_TYPE_HANG),
"Crash type should be plugin-hang");
is(crash.remoteID, remoteID, "Crash remoteID should match");
is(crash.submissions.size, 1, "Crash should have a submission");
let submission = crash.submissions.values().next().value;
is(submission.result, cm.SUBMISSION_RESULT_OK,
"Submission should be successful");
store.reset();
SimpleTest.finish();
})();
},
QueryInterface: function(iid) {
if (iid.equals(Ci.nsIObserver) ||
iid.equals(Ci.nsISupportsWeakReference) ||
iid.equals(Ci.nsISupports))
return this;
throw Components.Exception("", Cr.NS_NOINTERFACE);
}
};
async function onPluginCrashed(aEvent) {
ok(true, "Plugin crashed notification received");
is(aEvent.type, "PluginCrashed", "event is correct type");
await SimpleTest.promiseWaitForCondition(
() => aEvent.target.openOrClosedShadowRoot.getElementById("submitButton"),
"Waiting for submit button to exist."
);
let submitButton = aEvent.target.openOrClosedShadowRoot.getElementById("submitButton");
// try to submit this report
sendMouseEvent({type:'click'}, submitButton, window);
}
async function runTests() {
// Default plugin hang timeout is too high for mochitests
Services.prefs.setIntPref("dom.ipc.plugins.timeoutSecs", 1);
// the test harness will have set MOZ_CRASHREPORTER_NO_REPORT,
// ensure that we can change the setting and have our minidumps
// wind up in Crash Reports/pending
let env = Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment);
env.set("MOZ_CRASHREPORTER_NO_REPORT", "");
// Override the crash reporter URL to send to our fake server
crashReporter.serverURL = NetUtil.newURI(SERVER_URL);
// Hook into plugin crash events
Services.obs.addObserver(testObserver, "crash-report-status", true);
document.addEventListener("PluginCrashed", onPluginCrashed, false);
var pluginElement = document.getElementById("plugin1");
await SimpleTest.promiseWaitForCondition(() => pluginElement.hang !== undefined,
"Waited too long for plugin to activate");
try {
(async function() {
// Clear data in CrashManager in case previous tests caused something
// to be added.
let store = await Services.crashmanager._getStore();
store.reset();
pluginElement.hang();
})();
} catch (e) {
}
}
]]>
</script>
</window>

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

@ -1,260 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window title="Basic Plugin Tests"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<title>Plugin Hang UI Test</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript"
src="plugin-utils.js" />
<script type="application/javascript" src="hang_test.js" />
<script type="application/javascript" src="hangui_common.js" />
<body xmlns="http://www.w3.org/1999/xhtml">
<iframe id="iframe1" src="hangui_subpage.html" width="400" height="400"></iframe>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
SimpleTest.expectChildProcessCrash();
SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
true]]});
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
const hangUITimeoutPref = "dom.ipc.plugins.hangUITimeoutSecs";
const hangUIMinDisplayPref = "dom.ipc.plugins.hangUIMinDisplaySecs";
const timeoutPref = "dom.ipc.plugins.timeoutSecs";
var worker = new ChromeWorker("hangui_iface.js");
worker.onmessage = function(event) {
var result = event.data;
var params = result.params;
var output = params.testName;
if (result.msg) {
output += ": " + result.msg;
}
ok(result.status, output);
if (params.callback) {
var cb = eval(params.callback);
var timeout = setTimeout(function() { clearTimeout(timeout); cb(); }, 100);
}
};
worker.onerror = function(event) {
var output = "Error: " + event.message + " at " + event.filename + ":" + event.lineno;
ok(false, output);
};
var iframe;
var p;
var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
function hanguiOperation(testName, timeoutSec, expectFind, expectClose, opCode,
commandId, check, cb) {
var timeoutMs = timeoutSec * 1000 + EPSILON_MS;
worker.postMessage({ "timeoutMs": timeoutMs, "expectToFind": expectFind,
"expectToClose": expectClose, "opCode": opCode,
"commandId": commandId, "check": check,
"testName": testName, "callback": cb });
}
function hanguiExpect(testName, shouldBeShowing, shouldClose, cb) {
var timeoutSec = Services.prefs.getIntPref(hangUITimeoutPref);
if (!shouldBeShowing && !timeoutSec) {
timeoutSec = Services.prefs.getIntPref(timeoutPref);
}
hanguiOperation(testName, timeoutSec, shouldBeShowing, shouldClose, HANGUIOP_NOTHING, 0, false, cb);
}
function hanguiContinue(testName, check, cb) {
var timeoutSec = Services.prefs.getIntPref(hangUITimeoutPref);
hanguiOperation(testName, timeoutSec, true, true, HANGUIOP_COMMAND, IDC_CONTINUE, check, cb);
}
function hanguiStop(testName, check, cb) {
var timeoutSec = Services.prefs.getIntPref(hangUITimeoutPref);
hanguiOperation(testName, timeoutSec, true, true, HANGUIOP_COMMAND, IDC_STOP, check, cb);
}
function hanguiCancel(testName, cb) {
var timeoutSec = Services.prefs.getIntPref(hangUITimeoutPref);
hanguiOperation(testName, timeoutSec, true, true, HANGUIOP_CANCEL, 0, false, cb);
}
function finishTest() {
if (obsCount > 0) {
os.removeObserver(testObserver, "plugin-crashed");
--obsCount;
}
Services.prefs.clearUserPref(hangUITimeoutPref);
Services.prefs.clearUserPref(hangUIMinDisplayPref);
Services.prefs.clearUserPref(timeoutPref);
SimpleTest.finish();
}
function runTests() {
resetVars();
hanguiOperation("Prime ChromeWorker", 0, false, false, HANGUIOP_NOTHING, 0,
false, "test1");
}
window.frameLoaded = runTests;
var obsCount = 0;
function onPluginCrashedHangUI(aEvent) {
ok(true, "Plugin crashed notification received");
is(aEvent.type, "PluginCrashed", "event is correct type");
is(p, aEvent.target, "Plugin crashed event target is plugin element");
ok(aEvent instanceof PluginCrashedEvent,
"plugin crashed event has the right interface");
is(typeof aEvent.pluginDumpID, "string", "pluginDumpID is correct type");
isnot(aEvent.pluginDumpID, "", "got a non-empty dump ID");
is(typeof aEvent.pluginName, "string", "pluginName is correct type");
is(aEvent.pluginName, "Test Plug-in", "got correct plugin name");
is(typeof aEvent.pluginFilename, "string", "pluginFilename is correct type");
isnot(aEvent.pluginFilename, "", "got a non-empty filename");
// The app itself may or may not have decided to submit the report, so
// allow either true or false here.
ok("submittedCrashReport" in aEvent, "submittedCrashReport is a property of event");
is(typeof aEvent.submittedCrashReport, "boolean", "submittedCrashReport is correct type");
os.removeObserver(testObserver, "plugin-crashed");
--obsCount;
}
function resetVars() {
iframe = document.getElementById('iframe1');
p = iframe.contentDocument.getElementById("plugin1");
if (obsCount == 0) {
os.addObserver(testObserver, "plugin-crashed", true);
++obsCount;
}
iframe.contentDocument.addEventListener("PluginCrashed",
onPluginCrashedHangUI,
false);
}
function test9b() {
hanguiExpect("test9b: Plugin Hang UI is not showing (checkbox)", false);
p.stall(STALL_DURATION);
hanguiExpect("test9b: Plugin Hang UI is still not showing (checkbox)", false, false, "finishTest");
p.stall(STALL_DURATION);
}
function test9a() {
resetVars();
Services.prefs.setIntPref(hangUITimeoutPref, 1);
Services.prefs.setIntPref(hangUIMinDisplayPref, 1);
Services.prefs.setIntPref(timeoutPref, 45);
hanguiContinue("test9a: Continue button works with checkbox", true, "test9b");
p.stall(STALL_DURATION);
}
function test9() {
window.frameLoaded = test9a;
iframe.contentWindow.location.reload();
}
function test8a() {
resetVars();
Services.prefs.setIntPref(hangUITimeoutPref, 1);
Services.prefs.setIntPref(hangUIMinDisplayPref, 4);
hanguiExpect("test8a: Plugin Hang UI is not showing (disabled due to hangUIMinDisplaySecs)", false, false, "test9");
var exceptionThrown = false;
try {
p.hang();
} catch(e) {
exceptionThrown = true;
}
ok(exceptionThrown, "test8a: Exception thrown from hang() when plugin was terminated");
}
function test8() {
window.frameLoaded = test8a;
iframe.contentWindow.location.reload();
}
function test7a() {
resetVars();
Services.prefs.setIntPref(hangUITimeoutPref, 0);
hanguiExpect("test7a: Plugin Hang UI is not showing (disabled)", false, false, "test8");
var exceptionThrown = false;
try {
p.hang();
} catch(e) {
exceptionThrown = true;
}
ok(exceptionThrown, "test7a: Exception thrown from hang() when plugin was terminated");
}
function test7() {
window.frameLoaded = test7a;
iframe.contentWindow.location.reload();
}
function test6() {
Services.prefs.setIntPref(hangUITimeoutPref, 1);
Services.prefs.setIntPref(hangUIMinDisplayPref, 1);
Services.prefs.setIntPref(timeoutPref, 3);
hanguiExpect("test6: Plugin Hang UI is showing", true, true, "test7");
var exceptionThrown = false;
try {
p.hang();
} catch(e) {
exceptionThrown = true;
}
ok(exceptionThrown, "test6: Exception thrown from hang() when plugin was terminated (child timeout)");
}
function test5a() {
resetVars();
hanguiCancel("test5a: Close button works", "test6");
p.stall(STALL_DURATION);
}
function test5() {
window.frameLoaded = test5a;
iframe.contentWindow.location.reload();
}
function test4() {
hanguiStop("test4: Stop button works", false, "test5");
// We'll get an exception here because the plugin was terminated
var exceptionThrown = false;
try {
p.hang();
} catch(e) {
exceptionThrown = true;
}
ok(exceptionThrown, "test4: Exception thrown from hang() when plugin was terminated");
}
function test3() {
hanguiContinue("test3: Continue button works", false, "test4");
p.stall(STALL_DURATION);
}
function test2() {
// This test is identical to test1 because there were some bugs where the
// Hang UI would show on the first hang but not on subsequent hangs
hanguiExpect("test2: Plugin Hang UI is showing", true, true, "test3");
p.stall(STALL_DURATION);
}
function test1() {
Services.prefs.setIntPref(hangUITimeoutPref, 1);
Services.prefs.setIntPref(hangUIMinDisplayPref, 1);
Services.prefs.setIntPref(timeoutPref, 45);
hanguiExpect("test1: Plugin Hang UI is showing", true, true, "test2");
p.stall(STALL_DURATION);
}
]]>
</script>
</window>

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

@ -1,43 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Test whether we are adding the dummy plugin correctly when there is only 1 plugin and its hidden</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<body>
<script type="application/javascript">
"use strict";
{
SimpleTest.waitForExplicitFinish();
let ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"].getService(SpecialPowers.Ci.nsIPluginHost);
let plugins = ph.getPluginTags();
let testPluginName = plugins[0].name;
let prefName = "plugins.navigator.hidden_ctp_plugin";
try {
SpecialPowers.getCharPref(prefName);
} catch (ex) {}
let promise = SpecialPowers.pushPrefEnv({ set: [[prefName, testPluginName]]});
promise.then(function() {
for (let i = 0; i < plugins.length; i++) {
let plugin = plugins[i];
let newState = (plugin.name == testPluginName ? SpecialPowers.Ci.nsIPluginTag.STATE_CLICKTOPLAY :
SpecialPowers.Ci.nsIPluginTag.STATE_DISABLED);
if (plugin.enabledState != newState) {
let oldState = plugin.enabledState;
setTestPluginEnabledState(newState, plugin.name);
SimpleTest.registerCleanupFunction(function() {
if (plugin.enabledState != oldState)
setTestPluginEnabledState(oldState, plugin.name);
});
}
}
// we have disabled all the plugins except for 1 which is click to play and hidden. The
// navigator.plugins list should have only one entry and it should be the dummy plugin.
isnot(navigator.plugins.length, 0, "navigator.plugins should not be empty");
SimpleTest.finish();
});
}
</script>
</body>

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

@ -1,49 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window title="Basic Plugin Tests"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<title>Plugin Idle Hang Test</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript" src="hang_test.js" />
<script type="application/javascript" src="plugin-utils.js"></script>
<script type="application/javascript">
getTestPlugin().enabledState = Ci.nsIPluginTag.STATE_ENABLED;
</script>
<body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
SimpleTest.expectChildProcessCrash();
async function runTests() {
// Default plugin hang timeout is too high for mochitests
var prefs = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefBranch);
var timeoutPref = "dom.ipc.plugins.timeoutSecs";
prefs.setIntPref(timeoutPref, 5);
var os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
os.addObserver(testObserver, "plugin-crashed", true);
testObserver.idleHang = true;
document.addEventListener("PluginCrashed", onPluginCrashed, false);
var pluginElement = document.getElementById("plugin1");
await SimpleTest.promiseWaitForCondition(() => pluginElement.hang !== undefined,
"Waited too long for plugin to activate");
try {
pluginElement.hang(false);
} catch (e) {
}
}
]]>
</script>
</window>

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

@ -1,123 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Test re-parentinging an instance's DOM node</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="plugin-utils.js"></script>
</head>
<body onload="begin()">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
const MAX_CHECK_PLUGIN_STOPPED_ATTEMPTS = 50;
var numCheckPluginStoppedAttempts = 0;
var exceptionThrown = false;
var p = null;
var d1 = null;
var d2 = null;
var destroyed = false;
function begin() {
runTests(function() {
// Callback when finished - set plugin to windowed and repeat the tests
info("Repeating tests with wmode=window");
p.setAttribute("wmode", "window");
d1.appendChild(p);
// Forces the plugin to be respawned
// eslint-disable-next-line no-self-assign
p.src = p.src;
destroyed = false;
exceptionThrown = false;
runTests(function() {
SimpleTest.finish();
});
});
}
function checkPluginStopped(callback, param) {
if (numCheckPluginStoppedAttempts < MAX_CHECK_PLUGIN_STOPPED_ATTEMPTS &&
!destroyed) {
++numCheckPluginStoppedAttempts;
SimpleTest.executeSoon(function() {
checkPluginStopped(callback, param);
});
} else {
info("Number of check plugin stopped attempts: " +
numCheckPluginStoppedAttempts);
callback(param);
}
}
function runTests(callback) {
p = document.getElementById("plugin1");
d1 = document.getElementById("div1");
d2 = document.getElementById("div2");
// First tests involve moving the instance from one div to another.
p.startWatchingInstanceCount();
p.callOnDestroy(function() {
destroyed = true;
});
try {
d1.removeChild(p);
} catch (e) {
exceptionThrown = true;
}
is(exceptionThrown, false, "Testing for exception after removeChild.");
try {
d2.appendChild(p);
} catch (e) {
exceptionThrown = true;
}
is(exceptionThrown, false, "Testing for exception after appendChild.");
is(destroyed, false, "No instances should have been destroyed at this point.");
is(p.getInstanceCount(), 0, "No new instances should have been created at this point.");
// Wait for the event loop to spin and ensure the plugin still wasn't touched
SimpleTest.executeSoon(function() {
is(destroyed, false, "No instances should have been destroyed at this point.");
is(p.getInstanceCount(), 0, "No new instances should have been created at this point.");
d2.removeChild(p);
checkPluginStopped(continueTestsAfterPluginDestruction, callback);
});
}
function continueTestsAfterPluginDestruction(callback) {
d2.appendChild(p);
SimpleTest.executeSoon(function() {
try {
is(p.getInstanceCount(), 1, "One new instance should have been created at this point.");
} catch (e) {
exceptionThrown = true;
}
is(exceptionThrown, false, "Testing for exception getting instance count from plugin.");
p.stopWatchingInstanceCount();
callback.apply(null);
});
}
</script>
<p id="display"></p>
<div id="div1">
<!-- This embed has to have a "src" attribute. Part of this test involves seeing if we
properly restart plugins that have been added back to a document without a change
in URL. Not re-loading an object when the URL hasn't changed is a shortcut used for
some object types. Without a URL, this won't be tested. -->
<embed id="plugin1" src="loremipsum.txt" type="application/x-test" width="200" height="200"></embed>
</div>
<div id="div2">
</div>
</body>
</html>

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

@ -1,50 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Test removing an instance's DOM node</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="startTest()">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
const MAX_ATTEMPTS = 50;
var attempts = 0;
var destroyed = false;
function onDestroy() {
destroyed = true;
}
function checkPluginAlreadyDestroyed() {
// We may need to retry a few times until the plugin stop event makes
// its way through the event queue.
if (attempts < MAX_ATTEMPTS && !destroyed) {
++attempts;
SimpleTest.executeSoon(checkPluginAlreadyDestroyed);
} else {
info("Number of retry attempts: " + attempts);
is(destroyed, true, "Plugin instance should have been destroyed.");
SimpleTest.finish();
}
}
function startTest() {
var p1 = document.getElementById("plugin1");
var d1 = document.getElementById("div1");
p1.callOnDestroy(onDestroy);
d1.removeChild(p1);
SimpleTest.executeSoon(checkPluginAlreadyDestroyed);
}
</script>
<p id="display"></p>
<div id="div1">
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
</div>
</body>
</html>

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

@ -1,61 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Test removing an instance's DOM node</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="startTest()">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
const MAX_ATTEMPTS = 50;
var attempts = 0;
var destroyed = false;
function onDestroy() {
destroyed = true;
}
function checkPluginAlreadyDestroyed() {
// We may need to retry a few times until the plugin stop event makes
// its way through the event queue.
if (attempts < MAX_ATTEMPTS && !destroyed) {
++attempts;
SimpleTest.executeSoon(checkPluginAlreadyDestroyed);
} else {
info("Number of retry attempts: " + attempts);
is(destroyed, true, "Plugin instance should have been destroyed.");
SimpleTest.finish();
}
}
function startTest() {
var p1 = document.getElementById("plugin1");
var d1 = document.getElementById("div1");
p1.callOnDestroy(onDestroy);
// Get two parent check events to run.
d1.removeChild(p1);
d1.appendChild(p1);
d1.removeChild(p1);
SimpleTest.executeSoon(checkPluginAlreadyDestroyed);
}
</script>
<p id="display"></p>
<div id="div1">
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
</div>
<div id="div2">
<div id="div3">
<embed id="plugin2" type="application/x-test" width="200" height="200"></embed>
</div>
</div>
</body>
</html>

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

@ -1,53 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Test removing an instance's DOM node</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="startTest()">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
const MAX_ATTEMPTS = 50;
var attempts = 0;
var destroyed = false;
function onDestroy() {
destroyed = true;
}
function checkPluginAlreadyDestroyed() {
// We may need to retry a few times until the plugin stop event makes
// its way through the event queue.
if (attempts < MAX_ATTEMPTS && !destroyed) {
++attempts;
SimpleTest.executeSoon(checkPluginAlreadyDestroyed);
} else {
info("Number of retry attempts: " + attempts);
is(destroyed, true, "Plugin instance should have been destroyed.");
SimpleTest.finish();
}
}
function startTest() {
var p1 = document.getElementById("plugin1");
var d1 = document.getElementById("div1");
var d2 = document.getElementById("div2");
p1.callOnDestroy(onDestroy);
d1.removeChild(d2);
SimpleTest.executeSoon(checkPluginAlreadyDestroyed);
}
</script>
<p id="display"></p>
<div id="div1">
<div id="div2">
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
</div<
</div>
</body>
</html>

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

@ -1,33 +0,0 @@
<head>
<title>Plugin instantiation</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<body onload="mainLoaded()">
<iframe id="iframe1" src="about:blank" width="600" height="600"></iframe>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
var iframe = document.getElementById("iframe1");
function mainLoaded() {
var p = iframe.contentDocument.createElement("embed");
p.setAttribute("id", "plugin1");
p.setAttribute("type", "application/x-test");
p.setAttribute("width", "400");
p.setAttribute("height", "400");
p.setAttribute("drawmode", "solid");
p.setAttribute("color", "FF00FFFF");
iframe.contentDocument.body.appendChild(p);
// Plugin instantiation happens asynchronously
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
ok(p.setColor !== undefined, "Dynamic plugin instantiation.");
SimpleTest.finish();
});
});
}
</script>

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

@ -2,20 +2,16 @@
<head>
<title>Test mixed case mimetype for plugins</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script>
SimpleTest.expectAssertions(0, 1);
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
function frameLoaded() {
var contentDocument = document.getElementById("testframe").contentDocument;
ok(contentDocument.body.innerHTML.length > 0, "Frame content shouldn't be empty.");
ok(contentDocument.plugins.length > 0, "Frame content should have a plugin.");
var plugin = contentDocument.plugins[0];
is(plugin.type.toLowerCase(), "application/x-second-test", "Should have loaded the second test plugin.");
ok(contentDocument.images.length > 0, "Frame content should have an image.");
SimpleTest.finish();
}
</script>

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

@ -1,24 +0,0 @@
<head>
<title>NPNV*NPObject accessibility tests</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<body onload="runTests()">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
function runTests() {
var p1 = document.getElementById("plugin1");
var p2 = document.getElementById("plugin2");
var o = p1.getObjectValue();
ok(p1.checkObjectValue(o), "Plugin objects passed to the same instance are identical.");
ok(!p2.checkObjectValue(o), "Plugin objects passed to another instance are double-wrapped.");
SimpleTest.finish();
}
</script>
<embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
<embed id="plugin2" type="application/x-test" width="400" height="400"></embed>

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

@ -1,36 +0,0 @@
<head>
<title>NPN_GetURL called from NPP_Destroy</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css">
<body onload="runTest()">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
function runTest() {
var p = document.getElementById("plugin1");
var destroyed = false;
p.callOnDestroy(function() {
destroyed = true;
ok(!p.streamTest("loremipsum.txt", false, null, null,
function(r, t) {
ok(false, "get-during-destroy should have failed");
}, null, true), "NPN_GetURLNotify should fail during NPP_Destroy");
});
document.body.removeChild(p);
setTimeout(function() {
ok(destroyed, "callback was fired as expected");
SimpleTest.finish();
}, 1000);
}
</script>
<p id="display"></p>
<embed id="plugin1" type="application/x-test"></embed>

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

@ -1,33 +0,0 @@
<html>
<head>
<title>NPN_Timer Tests</title>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
</head>
<body onload="runTests()">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
function pluginTimerTestFinish(result) {
ok(result, "timer tests completed");
SimpleTest.finish();
}
function runTests() {
var plugin = document.getElementById("plugin1");
plugin.timerTest("pluginTimerTestFinish");
}
</script>
<p id="display"></p>
<embed id="plugin1" type="application/x-test" width="400" height="100">
</embed>
</body>
</html>

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

@ -1,29 +0,0 @@
<head>
<title>NPNV*NPObject accessibility tests</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<body onload="runTests()">
<script class="testbody" type="application/javascript">
dump("lastScript\n");
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
function runTests() {
ok(
document.getElementById("plugin1").pluginFoundElement,
"plugin1.pluginFoundElement (NPNVPluginElementNPObject) - " +
document.getElementById("plugin1").pluginFoundElement
);
ok(
window.pluginFoundWindow,
"window.pluginFoundWindow (NPNVWindowNPObject) - " +
window.pluginFoundWindow
);
SimpleTest.finish();
}
</script>
<embed id="plugin1" type="application/x-test" width="400" height="400"></embed>

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

@ -1,30 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window title="Basic Plugin Tests"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript" src="plugin-utils.js"></script>
<script type="application/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>
<body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
<embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
async function runTests() {
var pluginElement = document.getElementById("plugin1");
await SimpleTest.promiseWaitForCondition(() => pluginElement.identifierToStringTest !== undefined,
"Waited too long for plugin to activate");
ok(pluginElement.identifierToStringTest('foo') == "foo", "identifierToStringTest failed");
SimpleTest.finish();
}
]]>
</script>
</window>

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

@ -1,32 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Test whether windowless plugins receive correct visible/invisible notifications.</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<body>
<script type="text/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>
<p id="display"></p>
<embed id="theplugin" type="application/x-test"></embed>
<script type="application/javascript">
function MyFunc(arg) {
is(arg, "hi", "Argument passed to constructor function");
this.localProp = "local";
}
MyFunc.prototype.protoProp = "t";
var theplugin = document.getElementById("theplugin");
ok(theplugin.constructObject(Array) instanceof Array, "Constructed Array");
var o = theplugin.constructObject(MyFunc, "hi");
ok(o instanceof MyFunc, "Constructed MyFunc");
is(o.localProp, "local", "this property correct");
is(o.protoProp, "t", "prototype property correct");
</script>

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

@ -1,66 +0,0 @@
<html>
<head>
<title>NPN_Invoke Tests</title>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<script class="testbody" type="application/javascript">
// //
// This test exercises NP identifiers by querying the reflector to make sure
// that identifiers are translated to values correctly.
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
var testsRun = 0;
function doTest() {
SpecialPowers.gc();
var reflector = document.getElementById("subframe").contentDocument.getElementById("plugin1").getReflector();
var i, prop, randomnumber;
for (i = 0; i < 20; ++i) {
randomnumber = Math.floor(Math.random() * 1001);
prop = "prop" + randomnumber;
is(reflector[prop], prop, "Property " + prop);
}
for (i = -10; i < 0; ++i) {
is(reflector[i], String(i), "Property " + i);
prop = "prop" + i;
is(reflector[prop], prop, "Property " + prop);
}
for (i = 0; i < 10; ++i) {
is(reflector[i], i, "Property " + i);
prop = "prop" + i;
is(reflector[prop], prop, "Property " + prop);
}
is(reflector.a, "a", "Property .a");
is(reflector.a, "a", "Property ['a']");
reflector = null;
SpecialPowers.gc();
++testsRun;
if (testsRun == 3) {
SimpleTest.finish();
} else {
document.getElementById("subframe").contentWindow.location.reload(true);
}
}
</script>
<iframe id="subframe" src="npruntime_identifiers_subpage.html" onload="doTest()"></iframe>
</body>
</html>

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

@ -1,102 +0,0 @@
<html>
<head>
<title>NPN_Evaluate Tests</title>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
</head>
<body onload="runTests()">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
// global test function
function testMe(arg) {
var result = arg + arg;
for (var i = 1; i < arguments.length; i++) {
result += arguments[i] + arguments[i];
}
return result;
}
// //
// This test exercises NPN_Evaluate using the test plugin's
// npnEvaluateTest method. This method calls NPN_Evaluate on
// a string argument passed to it, and returns the eval result.
// The array below drives the tests; each array member has two
// members: the first is a string to eval, and the second is
// the expected result of the eval.
//
function runTests() {
var tests = [
["3", 3],
["3 + 3", 6],
["'3'", "3"],
["function test() { return 3; } test();", 3],
["testMe(3)", 6],
["testMe(new Object(3))", 6],
// eslint-disable-next-line no-new-object
["new Object(3)", new Object(3)],
["new Array(1, 2, 3, 4)", [1, 2, 3, 4]],
["document.getElementById('display')",
document.getElementById("display")],
["encodeURI('a = b')", "a%20=%20b"],
["document.getElementById('testdiv').innerHTML = 'Hello world!'",
"Hello world!"],
["function test2() { var x = {a: '1', b: '2'}; return x; } test2();",
{a: "1", b: "2"}],
["(function() { var ret; try { win = window.open(); win.document.writeln('wibble'); ret = 'no error' } catch(e) { ret = e.name; } win.close(); return ret; })()", "no error"],
];
var plugin = document.getElementById("plugin1");
// Test calling NPN_Evaluate from within plugin code.
for (var test of tests) {
var expected = test[1];
var result = plugin.npnEvaluateTest(test[0]);
// serialize the two values for easy comparison
var json_expected = JSON.stringify(expected);
var json_result = JSON.stringify(result);
if (typeof(result) == "function")
json_result = result.toString();
if (typeof(expected) == "function")
json_expected = expected.toString();
is(json_result, json_expected,
"npnEvaluateTest returned an unexpected value");
is(typeof(result), typeof(expected),
"npnEvaluateTest return value was of unexpected type");
var success = (json_result == json_expected &&
typeof(result) == typeof(expected));
$("verbose").appendChild(
createEl("span", null, (success ? "pass" : "fail") + ": eval(" + test[0] + ")"));
$("verbose").appendChild(
createEl("span", null, " == " + json_result + "(" +
typeof(result) + "), expected " + json_expected + "(" +
typeof(expected) + ")"));
$("verbose").appendChild(
createEl("br")
);
}
is(document.getElementById("testdiv").innerHTML, "Hello world!",
"innerHTML not set correctly via NPN_Evaluate");
SimpleTest.finish();
}
</script>
<p id="display"></p>
<embed id="plugin1" type="application/x-test" width="400" height="100">
</embed>
<div id="verbose">
</div>
<div id="testdiv">
</div>
</body>
</html>

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

@ -1,163 +0,0 @@
<html>
<head>
<title>NPN_Invoke Tests</title>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
</head>
<body onload="runTests()">
<script class="testbody" type="application/javascript">
// //
// This test exercises NPN_Invoke by calling the plugin's npnInvokeTest
// method, which in turn invokes a script method with 1 or more parameters,
// and then compares the return vale with an expected value. This is good
// for verifying various NPVariant values and types moving between
// the browser and the plugin.
//
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
// This function returns all the arguments passed to it, either as a
// single variable (in the caes of 1 argument), or as an array.
function returnArgs() {
if (arguments.length == 1)
return arguments[0];
var arr = [];
for (var i = 0; i < arguments.length; i++) {
arr.push(arguments[i]);
}
return arr;
}
// Same as above but explicitly expects two arguments.
function returnTwoArgs(arg1, arg2) {
return [arg1, arg2];
}
// some objects and arrays used in the tests...
var obj = {"key1": "string", "key2": 0, "key3": true, "key4": undefined,
"key5": null, "key6": -551235.12552, "key7": false};
var arr = ["string", 0, true, false, undefined, null, -1, 55512.1252];
var obj2 = {"key1": "string", "key2": 0, "key3": true, "key4": undefined,
"key5": null, "key6": -551235.12552, "key7": false, "array": arr};
var arr2 = ["string", false, undefined, null, -1, 55512.1252,
{"a": "apple", "b": true, "c": undefined}];
// //
// A list of tests to run. Each member of the main array contains
// two members: the first contains the arguments passed to npnInvokeTest,
// and the second is the expected result.
//
var tests = [
// numeric values
[["returnArgs", 0, 0], true],
[["returnArgs", 1, 1], true],
[["returnArgs", 32768, 32768], true],
[["returnArgs", -32768, -32768], true],
[["returnArgs", 2147483648, 2147483648], true],
[["returnArgs", -2147483648, -2147483648], true],
[["returnArgs", 1.0, 1.0], true],
[["returnArgs", 1.592786, 1.592786], true],
[["returnArgs", 1.592786837, 1.592786837], true],
[["returnArgs", -1.592786, -1.592786], true],
[["returnArgs", -1.592786837, -1.592786837], true],
[["returnArgs", 15235.592786, 15235.592786], true],
// null, void, bool
[["returnArgs", null, null], true],
[["returnArgs", undefined, undefined], true],
[["returnArgs", undefined, null], false],
[["returnArgs", null, undefined], false],
[["returnArgs", 0, undefined], false],
[["returnArgs", 0, null], false],
[["returnArgs", 0, false], false],
[["returnArgs", 1, true], false],
[["returnArgs", true, true], true],
[["returnArgs", false, false], true],
// strings
[["returnArgs", "", ""], true],
[["returnArgs", "test", "test"], true],
[["returnArgs", "test", "testing"], false],
[["returnArgs", "test\n", "test\n"], true],
[["returnArgs", "test\nline2", "test\nline2"], true],
[["returnArgs", "test\nline2", "testline2"], false],
[["returnArgs", "test\u000aline2", "test\u000aline2"], true],
[["returnArgs", "test\u0020line2", "test line2"], true],
[["returnArgs", "test line2", "test\u0020line2"], true],
// objects and arrays
[["returnArgs", obj, obj], true],
[["returnArgs", arr, arr], true],
[["returnArgs", obj2, obj2], true],
[["returnArgs", arr2, arr2], true],
// multiple arguments
[["returnArgs", [0, 1, 2], 0, 1, 2], true],
[["returnArgs", [5, "a", true, false, null],
5, "a", true, false, null], true],
[["returnArgs", [-1500.583, "test string\n",
[5, 10, 15, 20], {"a": 1, "b": 2}],
-1500.583, "test string\n", [5, 10, 15, 20], {"a": 1, "b": 2}], true],
[["returnArgs", [undefined, 0, null, "yes"],
undefined, 0, null, "yes"], true],
[["returnArgs", [0, undefined, null, "yes"],
0, undefined, null, "yes"], true],
// too many/too few args
[["returnTwoArgs", ["a", "b"], "a", "b", "c"], true],
[["returnTwoArgs", ["a", undefined], "a"], true],
[["returnTwoArgs", [undefined, undefined]], true],
];
function runTests() {
var plugin = document.getElementById("plugin1");
var result;
for (var test of tests) {
switch (test[0].length) {
case 2:
result = plugin.npnInvokeTest(test[0][0], test[0][1]);
break;
case 3:
result = plugin.npnInvokeTest(test[0][0], test[0][1], test[0][2]);
break;
case 4:
result = plugin.npnInvokeTest(test[0][0], test[0][1], test[0][2],
test[0][3]);
break;
case 5:
result = plugin.npnInvokeTest(test[0][0], test[0][1], test[0][2],
test[0][3], test[0][4]);
break;
case 6:
result = plugin.npnInvokeTest(test[0][0], test[0][1], test[0][2],
test[0][3], test[0][4], test[0][5]);
break;
case 7:
result = plugin.npnInvokeTest(test[0][0], test[0][1], test[0][2],
test[0][3], test[0][4], test[0][5], test[0][6]);
break;
default:
is(false, "bad number of test arguments");
}
is(result, test[1], "npnInvokeTestFailed: " + plugin.getError());
$("verbose").appendChild(
createEl("span", null, ((result == test[1] ? "pass" : "fail") + ": " + test[0])));
if (result != test[1])
$("verbose").appendChild(createEl("span", null, (" " + plugin.getError())));
$("verbose").appendChild(createEl("br"));
}
SimpleTest.finish();
}
</script>
<p id="display"></p>
<embed id="plugin1" type="application/x-test" width="400" height="100">
</embed>
<div id="verbose">
</div>
</body>
</html>

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

@ -1,157 +0,0 @@
<html>
<head>
<title>NPN_Invoke_Default Tests</title>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
</head>
<body onload="runTests()">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
// global test function
function testMe(arg) {
var result = arg + arg;
for (var i = 1; i < arguments.length; i++) {
result += arguments[i] + arguments[i];
}
return result;
}
// //
// This test exercises NPN_InvokeDefault using the test plugin's
// npnInvokeDefaultTest method. This method invokes an object
// with a single parameter, and returns the result of the invocation.
// The test list below is used to drive the tests. Each member of the
// array contains three members: the object to invoke, an argument to
// invoke it with, and the expected result of the invocation.
//
var tests = [
// Number object
["Number", 3, 3],
["Number", "3", 3],
["Number", "0x20", 32],
["Number", "three", Number.NaN],
["Number", "1e+3", 1000],
["Number", 5.6612, 5.6612],
// Array object
["Array", 3, Array(3)],
// Boolean object
["Boolean", 0, false],
["Boolean", null, false],
["Boolean", "", false],
["Boolean", false, false],
["Boolean", true, true],
["Boolean", "true", true],
["Boolean", "false", true],
/* eslint-disable no-new-wrappers */
["Boolean", new Boolean(false), true],
["Boolean", { "value": false }, true],
// Function object
["Function", "return 3", Function("return 3")],
["Function", "window.alert('test')", Function("window.alert('test')")],
// Object object
["Object", undefined, Object()],
["Object", null, Object()],
["Object", true, new Boolean(true)],
["Object", Boolean(), new Boolean(false)],
["Object", "a string", new String("a string")],
["Object", 3.14, new Number(3.14)],
/* eslint-enable no-new-wrappers */
["Object", { "key1": "test", "key2": 15 }, { "key1": "test", "key2": 15 }],
["Object", [1, 3, 5, 7, 9, 11, 13, 17], [1, 3, 5, 7, 9, 11, 13, 17]],
// RegExp object
["RegExp", "...", RegExp("...")],
// String object
["String", "testing", "testing"],
["String", "test\u0020me", "test me"],
["String", "314", "314"],
["String", "true", "true"],
["String", "null", "null"],
["String", "2 + 2", String("2 + 2")],
["String", ""],
// global functions
["testMe", 3, 6],
["testMe", "string", [1, 2], "stringstring1,21,2"],
["testMe", "me", "meme"],
["testMe", undefined, Number.NaN],
["testMe", [1, 2], "1,21,2"],
["testMe", 3, 4, 14],
["isNaN", "junk", true],
["parseInt", "156", 156],
["encodeURI", "a = b", "a%20=%20b"],
];
function runTests() {
var plugin = document.getElementById("plugin1");
// Test calling NPN_InvokeDefault from within plugin code.
for (var test of tests) {
var result;
var expected = test[test.length - 1];
switch (test.length) {
case 2:
result = plugin.npnInvokeDefaultTest(test[0]);
break;
case 3:
result = plugin.npnInvokeDefaultTest(test[0], test[1]);
break;
case 4:
result = plugin.npnInvokeDefaultTest(test[0], test[1], test[2]);
break;
}
// serialize the two values for easy
var json_expected = JSON.stringify(expected);
var json_result = JSON.stringify(result);
if (typeof(result) == "function")
json_result = result.toString();
if (typeof(test[2]) == "function")
json_expected = expected.toString();
is(json_result, json_expected,
"npnInvokeDefault returned an unexpected value");
is(typeof(result), typeof(expected),
"npnInvokeDefaultTest return value was of unexpected type");
var success = (json_result == json_expected &&
typeof(result) == typeof(expected));
$("verbose").appendChild(
createEl("span", null, ((success ? "pass" : "fail") + ": " + test[0] + "(")));
for (var i = 1; i < test.length - 1; i++) {
$("verbose").appendChild(
createEl("span", null, (JSON.stringify(test[i]) + (i < test.length - 2 ? "," : ""))));
}
$("verbose").appendChild(
createEl("span", null, (") == " + json_result + "(" +
typeof(result) + "), expected " + json_expected + "(" +
typeof(expected) + ")")));
$("verbose").appendChild(createEl("br"));
}
let testObject = plugin.getInvokeDefaultObject();
// Test calling the invokedefault method of plugin-defined object
is(testObject(), "Test Plug-in",
"calling NPN_InvokeDefault on plugin-defined Object doesn't work");
is(testObject(1), "Test Plug-in;1",
"calling NPN_InvokeDefault on plugin-defined Object doesn't work");
is(testObject("test"), "Test Plug-in;test",
"calling NPN_InvokeDefault on plugin-defined Object doesn't work");
is(testObject(undefined, -1, null), "Test Plug-in;undefined;-1;null",
"calling NPN_InvokeDefault on plugin-defined Object doesn't work");
SimpleTest.finish();
}
</script>
<p id="display"></p>
<embed id="plugin1" type="application/x-test" width="400" height="100">
</embed>
<div id="verbose">
</div>
</body>
</html>

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

@ -1,513 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Plugin instantiation</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/SpecialPowers.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<meta charset="utf-8">
<body onload="onLoad()">
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
// This can go away once embed also is on WebIDL
let OBJLC = SpecialPowers.Ci.nsIObjectLoadingContent;
// Use string modes in this test to make the test easier to read/debug.
// nsIObjectLoadingContent refers to this as "type", but I am using "mode"
// in the test to avoid confusing with content-type.
let prettyModes = {};
prettyModes[OBJLC.TYPE_LOADING] = "loading";
prettyModes[OBJLC.TYPE_IMAGE] = "image";
prettyModes[OBJLC.TYPE_PLUGIN] = "plugin";
prettyModes[OBJLC.TYPE_DOCUMENT] = "document";
prettyModes[OBJLC.TYPE_NULL] = "none";
let body = document.body;
// A single-pixel white png
let testPNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3AoIFiETNqbNRQAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAACklEQVQIHWP4DwABAQEANl9ngAAAAABJRU5ErkJggg==";
// An empty, but valid, SVG
let testSVG = 'data:image/svg+xml,<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"></svg>';
// executeSoon wrapper to count pending callbacks
let pendingCalls = 0;
let afterPendingCalls = false;
function runWhenDone(func) {
if (!pendingCalls)
func();
else
afterPendingCalls = func;
}
function runSoon(func) {
pendingCalls++;
SimpleTest.executeSoon(function() {
func();
if (--pendingCalls < 1 && afterPendingCalls)
afterPendingCalls();
});
}
function src(obj, state, uri) {
// If we have a running plugin, src changing should always throw it out,
// even if it causes us to load the same plugin again.
if (uri && runningPlugin(obj, state)) {
if (!state.oldPlugins)
state.oldPlugins = [];
try {
state.oldPlugins.push(obj.getObjectValue());
} catch (e) {
ok(false, "Running plugin but cannot call getObjectValue?");
}
}
var srcattr;
if (state.tagName == "object")
srcattr = "data";
else if (state.tagName == "embed")
srcattr = "src";
else
ok(false, "Internal test fail: Why are we setting the src of an applet");
// Plugins should always go away immediately on src/data change
state.initialPlugin = false;
if (uri === null) {
removeAttr(obj, srcattr);
// TODO Bug 767631 - we don't trigger loadObject on UnsetAttr :(
forceReload(obj, state);
} else {
setAttr(obj, srcattr, uri);
}
}
// We have to be careful not to reach past the nsObjectLoadingContent
// prototype to touch generic element attributes, as this will try to
// spawn the plugin, breaking our ability to test for that.
function getAttr(obj, attr) {
return document.body.constructor.prototype.getAttribute.call(obj, attr);
}
function setAttr(obj, attr, val) {
return document.body.constructor.prototype.setAttribute.call(obj, attr, val);
}
function hasAttr(obj, attr) {
return document.body.constructor.prototype.hasAttribute.call(obj, attr);
}
function removeAttr(obj, attr) {
return document.body.constructor.prototype.removeAttribute.call(obj, attr);
}
function setDisplayed(obj, display) {
if (display)
removeAttr(obj, "style");
else
setAttr(obj, "style", "display: none;");
}
function displayed(obj) {
// Hacky, but that's all we use style for.
return !hasAttr(obj, "style");
}
function actualType(obj, state) {
return state.getActualType.call(obj);
}
function getMode(obj, state) {
return prettyModes[state.getDisplayedType.call(obj)];
}
function runningPlugin(obj, state) {
return state.getHasRunningPlugin.call(obj);
}
// TODO this is hacky and might hide some failures, but is needed until
// Bug 767635 lands -- which itself will probably mean tweaking this test.
function forceReload(obj, state) {
let attr;
if (state.tagName == "object")
attr = "data";
else if (state.tagName == "embed")
attr = "src";
if (attr && hasAttr(obj, attr)) {
src(obj, state, getAttr(obj, attr));
} else if (body.contains(obj)) {
body.appendChild(obj);
} else {
// Out of document nodes without data attributes simply can't be
// reloaded currently. Bug 767635
}
}
// Make a list of combinations of sub-lists, e.g.:
// [ [a, b], [c, d] ]
// ->
// [ [a, c], [a, d], [b, c], [b, d] ]
function eachList() {
let all = [];
if (!arguments.length)
return all;
let list = Array.prototype.slice.call(arguments, 0);
for (let c of list[0]) {
if (list.length > 1) {
for (let x of eachList.apply(this, list.slice(1))) {
all.push((c.length ? [c] : []).concat(x));
}
} else if (c.length) {
all.push([c]);
}
}
return all;
}
let states = {
svg(obj, state) {
removeAttr(obj, "type");
src(obj, state, testSVG);
state.noChannel = false;
state.expectedType = "image/svg";
// SVGs are actually image-like subdocuments
state.expectedMode = "document";
},
image(obj, state) {
removeAttr(obj, "type");
src(obj, state, testPNG);
state.noChannel = false;
state.expectedMode = "image";
state.expectedType = "image/png";
},
plugin(obj, state) {
removeAttr(obj, "type");
src(obj, state, "data:application/x-test,foo");
state.noChannel = false;
state.expectedType = "application/x-test";
state.expectedMode = "plugin";
},
pluginExtension(obj, state) {
src(obj, state, "./fake_plugin.tst");
state.expectedMode = "plugin";
state.pluginExtension = true;
state.noChannel = false;
},
document(obj, state) {
removeAttr(obj, "type");
src(obj, state, "data:text/plain,I am a document");
state.noChannel = false;
state.expectedType = "text/plain";
state.expectedMode = "document";
},
fallback(obj, state) {
removeAttr(obj, "type");
state.expectedType = "application/x-unknown";
state.expectedMode = "none";
state.noChannel = true;
src(obj, state, null);
},
addToDoc(obj, state) {
body.appendChild(obj);
},
removeFromDoc(obj, state) {
if (body.contains(obj))
body.removeChild(obj);
},
// Set the proper type
setType(obj, state) {
if (state.expectedType) {
state.badType = false;
setAttr(obj, "type", state.expectedType);
forceReload(obj, state);
}
},
// Set an improper type
setWrongType(obj, state) {
// This should break no-channel-plugins but nothing else
state.badType = true;
setAttr(obj, "type", "application/x-unknown");
forceReload(obj, state);
},
// Set a plugin type
setPluginType(obj, state) {
// If an object/embed has a type set to a plugin type, it should not
// use the channel type.
state.badType = false;
setAttr(obj, "type", "application/x-test");
state.expectedType = "application/x-test";
state.expectedMode = "plugin";
forceReload(obj, state);
},
noChannel(obj, state) {
src(obj, state, null);
state.noChannel = true;
state.pluginExtension = false;
},
displayNone(obj, state) {
setDisplayed(obj, false);
},
displayInherit(obj, state) {
setDisplayed(obj, true);
},
};
// eslint-disable-next-line complexity
function testObject(obj, state) {
// If our test combination both sets noChannel but no explicit type
// it shouldn't load ever.
let expectedMode = state.expectedMode;
let actualMode = getMode(obj, state);
if (state.noChannel && !getAttr(obj, "type")) {
// Some combinations of test both set no type and no channel. This is
// worth testing with the various combinations, but shouldn't load.
expectedMode = "none";
}
// Embed tags should always try to load a plugin by type or extension
// before falling back to opening a channel. See bug 803159
if (state.tagName == "embed" &&
(getAttr(obj, "type") == "application/x-test" || state.pluginExtension)) {
state.noChannel = true;
}
// with state.loading, unless we're loading with no channel, these types
// should still be in loading state pending a channel.
if (state.loading && (expectedMode == "image" || expectedMode == "document" ||
(expectedMode == "plugin" && !state.initialPlugin && !state.noChannel))) {
expectedMode = "loading";
}
// With the exception of plugins with a proper type, nothing should
// load without a channel
if (state.noChannel && (expectedMode != "plugin" || state.badType) &&
body.contains(obj)) {
expectedMode = "none";
}
// embed tags should reject documents, except for SVG images which
// render as such
if (state.tagName == "embed" && expectedMode == "document" &&
actualType(obj, state) != "image/svg+xml") {
expectedMode = "none";
}
// Embeds with a plugin type should skip opening a channel prior to
// loading, taking only type into account.
if (state.tagName == "embed" && getAttr(obj, "type") == "application/x-test" &&
body.contains(obj)) {
expectedMode = "plugin";
}
if (!body.contains(obj)
&& (!state.loading || expectedMode != "image")
&& (!state.initialPlugin || expectedMode != "plugin")) {
// Images are handled by nsIImageLoadingContent so we dont track
// their state change as they're detached and reattached. All other
// types switch to state "loading", and are completely unloaded
expectedMode = "loading";
}
is(actualMode, expectedMode, "check loaded mode");
// If we're a plugin, check that we spawned successfully. state.loading
// is set if we haven't had an event loop since applying state, in which
// case the plugin would not have stopped yet if it was initially a
// plugin.
let shouldBeSpawnable = expectedMode == "plugin" && displayed(obj);
let shouldSpawn = shouldBeSpawnable && (!state.loading || state.initialPlugin);
let didSpawn = runningPlugin(obj, state);
is(didSpawn, !!shouldSpawn, "check plugin spawned is " + !!shouldSpawn);
// If we are a plugin, scripting should work. If we're not spawned we
// should spawn synchronously.
let scripted = false;
try {
obj.getObjectValue();
scripted = true;
} catch (e) {}
is(scripted, shouldBeSpawnable, "check plugin scriptability");
// If this tag previously had other spawned plugins, make sure it
// respawned between then and now
if (state.oldPlugins && didSpawn) {
let didRespawn = false;
for (let oldp of state.oldPlugins) {
// If this returns false or throws, it's not the same plugin
try {
didRespawn = !obj.checkObjectValue(oldp);
} catch (e) {
didRespawn = true;
}
}
is(didRespawn, true, "Plugin should have re-spawned since old state (" + state.oldPlugins.length + ")");
}
}
let total = 0;
let test_modes = {
// Just apply from_state then to_state
"immediate": function(obj, from_state, to_state, state) {
for (let from of from_state)
states[from](obj, state);
for (let to of to_state)
states[to](obj, state);
// We don't spin the event loop between applying to_state and
// running tests, so some types are still loading
state.loading = true;
info("[" + (++total) + "] Testing [ " + from_state + " ] -> [ " + to_state + " ] / " + state.tagName + " / immediate");
testObject(obj, state);
if (body.contains(obj))
body.removeChild(obj);
},
// Apply states, spin event loop, run tests.
"cycle": function(obj, from_state, to_state, state) {
for (let from of from_state)
states[from](obj, state);
for (let to of to_state)
states[to](obj, state);
// Because re-appending to the document creates a script blocker, but
// plugins spawn asynchronously, we need to return to the event loop
// twice to ensure the plugin has been given a chance to lazily spawn.
runSoon(function() {
runSoon(function() {
info("[" + (++total) + "] Testing [ " + from_state + " ] -> [ " + to_state + " ] / " + state.tagName + " / cycle");
testObject(obj, state);
if (body.contains(obj))
body.removeChild(obj);
});
});
},
// Apply initial state, spin event loop, apply final state, spin event
// loop again.
"cycleboth": function(obj, from_state, to_state, state) {
for (let from of from_state) {
states[from](obj, state);
}
runSoon(function() {
for (let to of to_state) {
states[to](obj, state);
}
// Because re-appending to the document creates a script blocker,
// but plugins spawn asynchronously, we need to return to the event
// loop twice to ensure the plugin has been given a chance to lazily
// spawn.
runSoon(function() {
runSoon(function() {
info("[" + (++total) + "] Testing [ " + from_state + " ] -> [ " + to_state + " ] / " + state.tagName + " / cycleboth");
testObject(obj, state);
if (body.contains(obj))
body.removeChild(obj);
});
});
});
},
// Apply initial state, spin event loop, apply later state, test
// immediately
"cyclefirst": function(obj, from_state, to_state, state) {
for (let from of from_state) {
states[from](obj, state);
}
runSoon(function() {
state.initialPlugin = runningPlugin(obj, state);
for (let to of to_state) {
states[to](obj, state);
}
info("[" + (++total) + "] Testing [ " + from_state + " ] -> [ " + to_state + " ] / " + state.tagName + " / cyclefirst");
// We don't spin the event loop between applying to_state and
// running tests, so some types are still loading
state.loading = true;
testObject(obj, state);
if (body.contains(obj))
body.removeChild(obj);
});
},
};
function test(testdat) {
// FIXME bug 1291854: Change back to lets when the test is fixed.
for (var from_state of testdat.from_states) {
for (var to_state of testdat.to_states) {
for (var mode of testdat.test_modes) {
for (var type of testdat.tag_types) {
runSoon(function() {
let obj = document.createElement(type);
obj.width = 1; obj.height = 1;
let state = {};
state.noChannel = true;
state.tagName = type;
// Part of the test checks whether a plugin spawned or not,
// but touching the object prototype will attempt to
// synchronously spawn a plugin! We use this terrible hack to
// get a privileged getter for the attributes we want to touch
// prior to applying any attributes.
// TODO when embed goes away we wont need to check for
// QueryInterface any longer.
var lookup_on = obj.QueryInterface ? obj.QueryInterface(OBJLC) : obj;
state.getDisplayedType = SpecialPowers.do_lookupGetter(lookup_on, "displayedType");
state.getHasRunningPlugin = SpecialPowers.do_lookupGetter(lookup_on, "hasRunningPlugin");
state.getActualType = SpecialPowers.do_lookupGetter(lookup_on, "actualType");
test_modes[mode](obj, from_state, to_state, state);
});
}
}
}
}
}
function onLoad() {
// Generic tests
test({
"tag_types": [ "embed", "object" ],
// In all three modes
"test_modes": [ "immediate", "cycle", "cyclefirst", "cycleboth" ],
// Starting from a blank tag in and out of the document, a loading
// plugin, and no-channel plugin (initial types only really have
// odd cases with plugins)
"from_states": [
[ "addToDoc" ],
[ "plugin" ],
[ "plugin", "addToDoc" ],
[ "plugin", "noChannel", "setType", "addToDoc" ],
[],
],
// To various combinations of loaded objects
"to_states": eachList(
[ "svg", "image", "plugin", "document", "" ],
[ "setType", "setWrongType", "setPluginType", "" ],
[ "noChannel", "" ],
[ "displayNone", "displayInherit", "" ]
)});
// Special case test for embed tags with plugin-by-extension
// TODO object tags should be tested here too -- they have slightly
// different behavior, but waiting on a file load requires a loaded
// event handler and wont work with just our event loop spinning.
test({
"tag_types": [ "embed" ],
"test_modes": [ "immediate", "cyclefirst", "cycle", "cycleboth" ],
"from_states": eachList(
[ "svg", "plugin", "image", "document" ],
[ "addToDoc" ]
),
// Set extension along with valid ty
"to_states": [
[ "pluginExtension" ],
]});
// Test plugin add/remove from document with adding/removing frame, with
// and without a channel.
test({
"tag_types": [ "embed", "object" ], // Ideally we'd test object too, but this gets exponentially long.
"test_modes": [ "immediate", "cyclefirst", "cycle" ],
"from_states": [ [ "displayNone", "plugin", "addToDoc" ],
[ "displayNone", "plugin", "noChannel", "addToDoc" ],
[ "plugin", "noChannel", "addToDoc" ],
[ "plugin", "noChannel" ] ],
"to_states": eachList(
[ "displayNone", "" ],
[ "removeFromDoc" ],
[ "image", "displayNone", "" ],
[ "image", "displayNone", "" ],
[ "addToDoc" ],
[ "displayInherit" ]
)});
runWhenDone(() => SimpleTest.finish());
}
</script>

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

@ -1,122 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for windowless plugin invalidation and expose events in clips</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<style>
div#container {
position: relative;
height: 30px;
background: blue;
}
div#clip {
overflow:hidden;
position:absolute;
left: 10.3px;
top: 9.7px;
width: 10px;
height: 0px;
background: red;
}
embed {
position:absolute;
}
embed#paint-waiter {
top: 0px;
left: 0px;
width: 1px;
height: 0px;
}
embed#clipped {
left: -5.3px;
top: -4.7px;
width: 20px;
height: 20px;
}
</style>
</head>
<body onload="initialize()">
<script type="application/javascript" src="plugin-utils.js"></script>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
var paint_waiter;
var clip;
var clipped;
function initialize() {
paint_waiter = document.getElementById("paint-waiter");
clip = document.getElementById("clip");
clipped = document.getElementById("clipped");
waitForPaint(show);
}
function show() {
paintCountIs(clipped, 0, "fully clipped plugin not painted");
clip.style.height = "10px";
// Capturing an image (as in a reftest) would force a repaint and use
// different paths for the image surface, so instead check the plugin's
// paint count.
waitForPaint(invalidate);
}
function invalidate() {
paintCountIs(clipped, 1, "partially clipped plugin painted once");
clipped.setColor("FF00FF00"); // plugin invalidates
waitForPaint(done);
}
function done() {
paintCountIs(clipped, 2, "painted after invalidate");
SimpleTest.finish();
}
function waitForPaint(func) {
paint_waiter.last_paint_count = paint_waiter.getPaintCount();
// Ensure the waiter has had a style change, so that this will
// change its size and cause a paint.
paint_waiter.style.backgroundColor = paint_waiter.style.backgroundColor == "blue" ? "yellow" : "blue";
// eslint-disable-next-line no-unused-vars
var flush = paint_waiter.offsetHeight;
paint_waiter.style.height = "1px";
waitForPaintHelper(func);
}
function waitForPaintHelper(func) {
if (paint_waiter.getPaintCount() != paint_waiter.last_paint_count) {
// hide the paint waiter
paint_waiter.style.height = "0px";
setTimeout(func, 0);
return;
}
setTimeout(function() { waitForPaintHelper(func); }, 1000);
}
</script>
<p id="display"></p>
<div id="container">
<embed id="paint-waiter" type="application/x-test"/>
<div id="clip">
<embed id="clipped" type="application/x-test"
drawmode="solid" color="FF808080"/>
</div>
</div>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>

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

@ -0,0 +1,80 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test that plugins reject focus</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<div id="content">
<object id="obj_elt" type="application/x-shockwave-flash"></object>
<object tabindex='0' id="obj_elt_with_idx" type="application/x-shockwave-flash"></object>
<embed id="embed_elt" type="application/x-shockwave-flash"></embed>
</div>
<script type="application/javascript">
var objElt = document.getElementById('obj_elt');
var objEltWithIdx = document.getElementById('obj_elt_with_idx');
var embedElt = document.getElementById('embed_elt');
function checkHasFocus(expected, typeOfElts, elt) {
ok((document.activeElement == elt) == expected,
typeOfElts + " element should " + (expected ? "" : "not ") + "accept focus");
}
function checkNoneHasFocus(typeOfElts) {
checkHasFocus(false, typeOfElts + " <object>", objElt);
checkHasFocus(false, typeOfElts + " <object> with tabindex", objEltWithIdx);
checkHasFocus(false, typeOfElts + " <embed>", embedElt);
}
function checkFocusable(expected, typeOfElts, elt) {
elt.focus();
checkHasFocus(expected, typeOfElts, elt);
}
// As plugins, object and embed elements are not given focus
ok(objElt != null, "object element should exist");
ok(objEltWithIdx != null, "object element with tabindex should exist");
ok(embedElt != null, "embed element should exist");
// As plugins, obj/embed_elt can not take focus
checkNoneHasFocus("plugin");
// Switch obj/embed_elt attributes from plugin to image
objElt.data = "large-pic.jpg";
objElt.width = 100;
objElt.height = 100;
objElt.type = "image/jpg";
objEltWithIdx.data = "large-pic.jpg";
objEltWithIdx.width = 100;
objEltWithIdx.height = 100;
objEltWithIdx.type = "image/jpg";
embedElt.src = "large-pic.jpg";
embedElt.width = 100;
embedElt.height = 100;
embedElt.type = "image/jpg";
// As images, obj/embed_elt can take focus as image
// object image elements require a tabindex to accept focus.
// embed elements must be reparented before new type is recognized.
checkFocusable(false, "<object> image", objElt);
checkFocusable(true, "<object> image with tabindex", objEltWithIdx);
checkFocusable(false, "<embed> plugin with image attribs before reparenting", embedElt);
embedElt.parentNode.appendChild(embedElt);
checkFocusable(true, "<embed> image", embedElt);
// Switch obj/embed_elt attributes from image to plugin
objElt.type = "application/x-shockwave-flash";
embedElt.type = "application/x-shockwave-flash";
// embed elements must be reparented before new type is recognized.
checkFocusable(true, "<embed> image with plugin attribs", embedElt);
embedElt.parentNode.appendChild(embedElt);
checkNoneHasFocus("plugin");
</script>
</body>
</html>

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

@ -1,32 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta><charset="utf-8"/>
<title>Test Modifying Plugin click-to-play Flag</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
</head>
<body>
<script class="testbody" type="application/javascript">
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
var pluginHost = Cc["@mozilla.org/plugin/host;1"]
.getService(Ci.nsIPluginHost);
var testPlugin = getTestPlugin();
var secondTestPlugin = getTestPlugin("Second Test Plug-in");
ok(testPlugin, "Should have Test Plug-in");
ok(secondTestPlugin, "Should have Second Test Plug-in");
// make sure both start off as click-to-play
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_CLICKTOPLAY);
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in");
testPlugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
is(pluginHost.getStateForType("application/x-test"), Ci.nsIPluginTag.STATE_ENABLED, "click-to-play should be off for Test Plug-in now");
is(pluginHost.getStateForType("application/x-second-test"), Ci.nsIPluginTag.STATE_CLICKTOPLAY, "click-to-play should still be on for the Second Test Plug-in");
testPlugin.enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY;
is(pluginHost.getStateForType("application/x-test"), Ci.nsIPluginTag.STATE_CLICKTOPLAY, "click-to-play should be on for Test Plug-in now");
</script>
</body>
</html>

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

@ -1,174 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=517078
Tests for plugin stream error conditions.
-->
<head>
<title>NPAPI Stream Error Tests</title>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
</head>
<body onload="startTests()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=517078">
Mozilla Bug 517078</a> - Plugin Stream Error Tests
<p id="display"></p>
<div id="content" style="display: none">
</div>
<div id="test">
<script class="testbody" type="text/javascript">
// //
// These tests verify that nothing "bad" happens when a plugin returns an
// error from one of the NPP_ stream functions. "Bad" is defined here
// as the plugin being terminated, or NPP_ stream functions being
// called inappropriately by the browser after the plugin has returned
// a stream error.
//
function $(id) { return document.getElementById(id); }
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
var tests = [
{
"src": "loremipsum.txt",
"streammode": "normal",
"functiontofail": "npp_newstream",
"failurecode": "1",
"frame": "testframe",
},
{
"src": "loremipsum.txt",
"streammode": "normal",
"functiontofail": "npp_newstream",
"failurecode": "3",
"frame": "testframe",
},
{
"src": "loremipsum.txt",
"streammode": "normal",
"functiontofail": "npp_newstream",
"failurecode": "5",
"frame": "testframe",
},
{
"geturl": "loremipsum.txt",
"streammode": "normal",
"functiontofail": "npp_newstream",
"failurecode": "1",
"frame": "testframe",
},
{
"src": "loremipsum.txt",
"streammode": "normal",
"functiontofail": "npp_write",
"frame": "testframe",
},
{
"src": "loremipsum.txt",
"streammode": "asfile",
"functiontofail": "npp_write",
"frame": "testframe",
},
{
"src": "loremipsum.txt",
"streammode": "normal",
"functiontofail": "npp_destroystream",
"failurecode": "1",
"frame": "testframe",
},
];
function iframeonload(evt) {
// We have to use SpecialPowers because nptest.cpp prepends
// data: whichs makes the frame cross origin with the including page.
var wrappedDoc = SpecialPowers.wrap(evt.target).contentDocument;
var contentLength = wrappedDoc.body.innerHTML.length;
var plugin = gTestWindow.document.getElementById("embedtest");
var functionToFail = plugin.getAttribute("functiontofail");
if (contentLength > 0) {
is(wrappedDoc.body.innerHTML, "pass",
"test frame has unexpected content");
setTimeout(function() {
// This verifies that the plugin hasn't been unloaded, and that
// no calls to NPP_ functions have been made unexpectedly.
is(plugin.getError(), "pass", "plugin reported an error");
gTestWindow.close();
setTimeout(runNextTest, 10);
}, functionToFail == "npp_newstream" ? 500 : 10);
}
}
var index = 0;
var gTestWindow;
function runNextTest() {
if (index == tests.length * 2) {
SimpleTest.finish();
return;
}
gTestWindow = window.open("plugin_window.html",
"",
"width=620,height=320");
}
function continueTest() {
// We run each test as an embed and an object, as their initial stream
// handling differs.
var tag = index % 2 ? "embed" : "object";
var test = tests[Math.floor(index / 2)];
var p = gTestWindow.document.createElement("p");
p.textContent = "Plugin Stream Test " + Number(index);
gTestWindow.document.getElementById("test").appendChild(p);
if (test.frame) {
var iframe = gTestWindow.document.createElement("iframe");
iframe.name = test.frame;
iframe.onload = iframeonload;
gTestWindow.document.getElementById("test").appendChild(iframe);
}
var plugin = gTestWindow.document.createElement(tag);
plugin.setAttribute("id", "embedtest");
plugin.setAttribute("style", "width: 400px; height: 100px;");
plugin.setAttribute("type", "application/x-test");
for (var name in test) {
if (tag == "embed") {
plugin.setAttribute(name, test[name]);
} else if (name == "src") {
plugin.setAttribute("data", test[name]);
} else {
var param = document.createElement("param");
param.name = name;
param.value = test[name];
plugin.appendChild(param);
}
}
gTestWindow.document.getElementById("test").appendChild(plugin);
gTestWindow.document.getElementById("test")
.appendChild(document.createElement("br"));
index++;
}
function startTests() {
SpecialPowers.pushPrefEnv({"set": [
["security.data_uri.block_toplevel_data_uri_navigations", false],
]}, runNextTest);
}
</script>
</div>
</body>
</html>

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

@ -1,33 +0,0 @@
<html>
<head>
<title>NPAPI NPN_PostURL NPStream Test</title>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript"
src="pluginstream.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<script type="text/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<iframe id="testframe" name="testframe" onload="frameLoaded()"></iframe>
<!--
- In this test, a stream is sent to the plugin via NPP_NewStream,
- NP_NORMAL. When the stream is destroyed, the plugin posts the
- stream content to post.sjs via NPN_PostURL, with a frame specified
- to display the post's response. Post.sjs just reflects
- the body of the post back in the HTTP response, so the original
- stream content should end up being displayed in the frame.
-->
<embed src="loremipsum.txt" streammode="normal"
frame="testframe" posturl="post.sjs" postmode="frame"
id="embedtest" style="width: 400px; height: 100px;"
type="application/x-test"></embed>
</body>
</html>

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

@ -1,31 +0,0 @@
<html>
<head>
<title>NPAPI NPN_PostURL NPStream Test</title>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript"
src="pluginstream.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<script type="text/javascript">
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<iframe id="testframe" name="testframe" onload="frameLoaded()"></iframe>
<!--
- Same as test_pluginstream_post.html, except NULL is passed to NPN_PostURL
- as the frame parameter, so the HTTP response to the post is passed to the
- plugin via NPP_NewStream. Once this stream is received, it's displayed
- in a frame in the browser via a call to NPN_GetURL.
-->
<embed src="loremipsum.txt" streammode="normal"
frame="testframe" posturl="post.sjs" postmode="stream"
id="embedtest" style="width: 400px; height: 100px;"
type="application/x-test"></embed>
</body>
</html>

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

@ -1,53 +0,0 @@
<head>
<title>Do plugin stream requests send the Referer header correctly?</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
<body onload="runTests()">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
var pending = 3;
function testDone() {
--pending;
if (0 == pending)
SimpleTest.finish();
}
function runTests() {
var p = document.getElementById("plugin1");
var p2 = document.getElementById("plugin2");
ok(p.streamTest("plugin-stream-referer.sjs", false, null, null,
function(r, t) {
is(r, 0, "GET plugin-stream-referer.sjs");
is(t, "Referer found: " + window.location,
"GET Referer correct");
testDone();
}, null, true), "referer GET");
ok(p.streamTest("plugin-stream-referer.sjs", true, "Dummy Data", null,
function(r, t) {
is(r, 0, "POST plugin-stream-referer.sjs");
is(t, "No Referer found", "POST Referer absent");
testDone();
}, null, true), "referer POST");
ok(p2.streamTest("plugin-stream-referer.sjs", false, null, null,
function(r, t) {
is(r, 0, "GET plugin-stream-referer.sjs (2)");
var expectedreferer = String(window.location).replace("test_pluginstream_referer.html", "loremipsum.xtest");
is(t, "Referer found: " + expectedreferer,
"GET Referer correct with plugin src");
testDone();
}, null, true), "referer GET (2)");
}
</script>
<p id="display"></p>
<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
<embed id="plugin2" type="application/x-test" src="loremipsum.xtest" width="200" height="200"></embed>

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше