blob: 1d02212eca7e117c8a1cdf2d4c1c96f4c27c8ea9 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../resources/js-test-pre.js"></script>
<script>
window.jsTestIsAsync = true;
description(
'Test transforming youtube flash plugin to youtube iFrame based player. &lt;<a href="rdar://problem/11201356"> rdar://problem/11201356</a>&gt;'
);
function checkEmbeddedYouTubeVideoInsideIframe()
{
normalEmbedInIframe = document.getElementById('test-iframe').contentDocument.getElementById('normal-embed');
normalEmbedInIframeShadowRoot = internals.shadowRoot(normalEmbedInIframe);
shouldBe('internals.shadowPseudoId(normalEmbedInIframeShadowRoot.firstChild)', '"-webkit-plugin-replacement"');
shouldBe('normalEmbedInIframeShadowRoot.firstChild.firstChild.tagName', '"IFRAME"');
document.body.removeChild(document.getElementById("test-container"));
finishJSTest();
}
function testEmbedYouTubeVideoInsideIframe()
{
var markup = [
'<body>',
'<p>Normal Embed:<br><embed id="normal-embed" src="http://www.youtube.com/v/N0gb9v4LI4o" type="application/x-shockwave-flash" width="425" height="350"></p>',
'<script>',
'window.setTimeout(window.parent.checkEmbeddedYouTubeVideoInsideIframe, 0);',
'</' + 'script>',
'</body>',
];
var iframe = document.getElementById('test-iframe');
iframe.srcdoc = markup.join("");
}
function Test()
{
setTimeout(function() {
normalEmbed = document.getElementById('normal-embed');
elinkEmbed = document.getElementById('elink-embed');
objectEmbed = document.getElementById('object-embed');
objectNoEmbed = document.getElementById('object-no-embed');
// Test we don't change any embed/object tag to iframe.
shouldBe('normalEmbed.tagName', '"EMBED"');
shouldBe('elinkEmbed.tagName', '"EMBED"');
shouldBe('objectEmbed.tagName', '"EMBED"');
shouldBe('objectNoEmbed.tagName', '"OBJECT"');
// Test we don't see those shadow iframes in DOM.
shouldBe('document.querySelectorAll("iframe").length', '1');
// Test we have the shadow root and the iframe player.
normalEmbedShadowRoot = internals.shadowRoot(normalEmbed);
shouldBe('internals.shadowPseudoId(normalEmbedShadowRoot.firstChild)', '"-webkit-plugin-replacement"');
shouldBe('normalEmbedShadowRoot.firstChild.firstChild.tagName', '"IFRAME"');
objectEmbedShadowRoot = internals.shadowRoot(objectEmbed);
shouldBe('internals.shadowPseudoId(objectEmbedShadowRoot.firstChild)', '"-webkit-plugin-replacement"');
shouldBe('objectEmbedShadowRoot.firstChild.firstChild.tagName', '"IFRAME"');
objectNoEmbedShadowRoot = internals.shadowRoot(objectNoEmbed);
shouldBe('internals.shadowPseudoId(objectNoEmbedShadowRoot.firstChild)', '"-webkit-plugin-replacement"');
shouldBe('objectNoEmbedShadowRoot.firstChild.firstChild.tagName', '"IFRAME"');
testEmbedYouTubeVideoInsideIframe();
}, 0);
}
</script>
</head>
<body onLoad="Test()">
<p id="description"></p>
<div id="console"></div>
<div id="test-container">
<p>Normal Embed:<br><embed id="normal-embed" src="http://www.youtube.com/v/N0gb9v4LI4o" type="application/x-shockwave-flash" width="425" height="350"></p>
<p>E-link Embed:<br><embed id="elink-embed" src="http://www.youtube.com/e/N0gb9v4LI4o" type="application/x-shockwave-flash" width="425" height="350"></p>
<p>Object with embed:<br>
<object width="425" height="350">
<param name="movie" value="http://www.youtube.com/v/N0gb9v4LI4o?version=3&amp;hl=en_US"></param>
<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed id="object-embed" src="http://www.youtube.com/v/N0gb9v4LI4o?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="425" height="350" allowscriptaccess="always" allowfullscreen="true"></embed>
</object>
</p>
<p>Object without embed:<br><object id="object-no-embed" width="425" height="350" type="application/x-shockwave-flash" data="http://www.youtube.com/v/N0gb9v4LI4o?version=3&amp;hl=en_US"></object>
<p>Embed inside iframe:<br>
<iframe width="300" height="200" id="test-iframe"></iframe>
</div>
<script src="../../../../resources/js-test-post.js"></script>
</body>
</html>