Bug 726734: Reload plugin instances when the src/data URL changes. r=jst

This commit is contained in:
Josh Aas 2012-03-23 08:33:15 -04:00
parent 29574f8e2e
commit c2fa9afffa
3 changed files with 44 additions and 2 deletions

View File

@ -1283,13 +1283,14 @@ nsObjectLoadingContent::LoadObject(nsIURI* aURI,
// Only do a URI equality check for things that aren't stopped plugins.
// This is because we still need to load again if the plugin has been stopped.
if (mType == eType_Document || mType == eType_Image || mInstanceOwner) {
if (mURI && aURI && !aForceLoad) {
if (mURI && aURI) {
bool equal;
nsresult rv = mURI->Equals(aURI, &equal);
if (NS_SUCCEEDED(rv) && equal) {
if (NS_SUCCEEDED(rv) && equal && !aForceLoad) {
// URI didn't change, do nothing
return NS_OK;
}
StopPluginInstance();
}
}

View File

@ -111,6 +111,7 @@ _MOCHITEST_FILES = \
test_instance_unparent3.html \
test_pluginstream_referer.html \
plugin-stream-referer.sjs \
test_src_url_change.html \
$(NULL)
# test_plugin_scroll_painting.html \ bug 596491

View File

@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<title>Test changing src attribute</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="runTests()">
<p id="display"></p>
<embed id="plugin1" src="about:blank" type="application/x-test" width="200" height="200"></embed>
<script type="application/javascript;version=1.8">
SimpleTest.waitForExplicitFinish();
var p = document.getElementById('plugin1');
var destroyed = false;
function onDestroy() {
destroyed = true;
}
function runTests() {
p.startWatchingInstanceCount();
p.callOnDestroy(onDestroy);
p.setAttribute("src", "loremipsum.txt");
is(destroyed, true, "Instance should have been destroyed.");
is(p.getInstanceCount(), 1, "One new instance should have been created.");
p.stopWatchingInstanceCount();
SimpleTest.finish();
}
</script>
</body>
</html>