LayoutTests:
Layout test for <rdar://problem/4214080> document.embeds:
embeds[0].Play() undefined at languageguide.org prevents audio playing
on mouseover
* fast/dom/object-embed-plugin-scripting-expected.txt: Added.
* fast/dom/object-embed-plugin-scripting.html: Added.
* fast/dom/resources/articles.m4a: Added.
WebCore:
Reviewed by darin.
- Fixed <rdar://problem/4214080> document.embeds: embeds[0].Play()
undefined at languageguide.org prevents audio playing on mouseover
- Layout test: fast/dom/object-embed-plugin-scripting.html
A common idiom the kids like to use these days for plugins is to nest
an <embed> inside an <object>, and assume that IE will honor the first,
Mozilla the second. We happen to honor both, but the rules dictate that
only the outer <object> gets a plugin/renderer. (A plugin is a
renderer.) This is a problem because sites ID us as Mozilla and
therefore attempt to script their plugins through the <embed>, which
has no plugin/renderer. The fix here is to have an <embed> return its
parent node's plugin/renderer when queried, if and only if it has no
renderer of its own and its parent node is an <object>. We may decide
to restrict this further in the future.
One happy consequence of this patch is that all the apple.com Quicktime
websites we had previously broken with TOT are now fixed.
* khtml/html/html_objectimpl.cpp:
(DOM::HTMLEmbedElementImpl::getEmbedInstance): The "if (!r)" clause
implements the logic I just described. The code below it I changed
just for style, to match the style in getObjectInstance().
(DOM::HTMLEmbedElementImpl::rendererIsNeeded): Assert that an <object>
parent has a renderer because we're going to use it later.
(DOM::HTMLObjectElementImpl::rendererIsNeeded): Changed to match style
of HTMLEmbedElementImpl counterpart.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@11873 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/fast/dom/object-embed-plugin-scripting-expected.txt b/LayoutTests/fast/dom/object-embed-plugin-scripting-expected.txt
new file mode 100644
index 0000000..d600515
--- /dev/null
+++ b/LayoutTests/fast/dom/object-embed-plugin-scripting-expected.txt
@@ -0,0 +1,17 @@
+This test checks for a regression against rdar://problem/4214080 document.embeds: embeds[0].Play() undefined at languageguide.org.
+
+Each test below states its expected outcome.
+
+plugin <object> with nested plugin <embed>: should have a plugin and does
+
+plugin <embed> netsted in plugin <object>: should have a plugin and does
+
+plugin <embed> nested in empty <object>: should have a plugin and does
+
+plugin <embed> nested in image <object>: should not have a plugin and does not
+
+plugin <embed> nested in empty <object> nested in plugin <object>: should not have a plugin and does not
+
+standalone plugin <embed>: should have a plugin and does
+
+
diff --git a/LayoutTests/fast/dom/object-embed-plugin-scripting.html b/LayoutTests/fast/dom/object-embed-plugin-scripting.html
new file mode 100644
index 0000000..95cbb0c
--- /dev/null
+++ b/LayoutTests/fast/dom/object-embed-plugin-scripting.html
@@ -0,0 +1,99 @@
+<html>
+<head>
+<script>
+function print(message)
+{
+ var paragraph = document.createElement("p");
+ paragraph.appendChild(document.createTextNode(message));
+ document.getElementById("console").appendChild(paragraph);
+}
+
+function test()
+{
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ }
+
+ print("plugin <object> with nested plugin <embed>: should have a plugin and does " + (document.getElementById('myO').Play ? "" : "not"));
+ print("plugin <embed> netsted in plugin <object>: should have a plugin and does " + (document.getElementById('myE').Play ? "" : "not"));
+ print("plugin <embed> nested in empty <object>: should have a plugin and does " + (document.getElementById('myE2').Play ? "" : "not"));
+ print("plugin <embed> nested in image <object>: should not have a plugin and does " + (document.getElementById('myE3').Play ? "" : "not"));
+ print("plugin <embed> nested in empty <object> nested in plugin <object>: should not have a plugin and does " + (document.getElementById('myE4').Play ? "" : "not"));
+ print("standalone plugin <embed>: should have a plugin and does " + (document.getElementById('myE5').Play ? "" : "not"));
+}
+</script>
+</head>
+<body onload="test()">
+<p>This test checks for a regression against <i>rdar://problem/4214080 document.embeds: embeds[0].Play() undefined at languageguide.org</i>.</p>
+<p>Each test below states its expected outcome.</p>
+<hr>
+<div id="console"></div>
+
+<OBJECT
+ id="myO"
+ classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
+ width = 0 height = 0
+ >
+ <PARAM name="src" value="resources/articles.m4a">
+ <PARAM name="autostart" value="false">
+
+ <EMBED
+ id="myE"
+ src="resources/articles.m4a"
+ autostart="false"
+ enablejavascript="true"
+ width = 0 height = 0
+ >
+ </EMBED>
+</OBJECT>
+
+<object>
+ <embed
+ id="myE2"
+ src="resources/articles.m4a"
+ autostart="false"
+ enablejavascript="true"
+ width = 0 height = 0
+ >
+</object>
+
+<object
+ data="resources/apple.gif"
+ type="image/gif"
+ width = 0 height = 0
+>
+ <embed
+ id="myE3"
+ src="resources/articles.m4a"
+ autostart="false"
+ enablejavascript="true"
+ width = 0 height = 0
+ >
+</object>
+
+<object
+ data="resources/apple.gif"
+ type="image/gif"
+ width = 0 height = 0
+>
+ <object>
+ <embed
+ id="myE4"
+ src="resources/articles.m4a"
+ autostart="false"
+ enablejavascript="true"
+ width = 0 height = 0
+ >
+ </object>
+</object>
+
+<embed
+ id="myE5"
+ src="resources/articles.m4a"
+ autostart="false"
+ enablejavascript="true"
+ width = 0 height = 0
+>
+
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/resources/articles.m4a b/LayoutTests/fast/dom/resources/articles.m4a
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/LayoutTests/fast/dom/resources/articles.m4a