test_bug769117.html (2355B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=769117 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 769117</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 <script type="application/javascript"> 12 SimpleTest.waitForExplicitFinish(); 13 /** Test for Bug 769117 */ 14 "use strict"; 15 function onLoad () { 16 SpecialPowers.pushPrefEnv({"set": [["plugins.rewrite_youtube_embeds", true]]}, function() { 17 18 let test_urls = [{ 19 original: "https://mochitest.youtube.com/v/Xm5i5kbIXzc", 20 changed: "https://mochitest.youtube.com/embed/Xm5i5kbIXzc", 21 }, { 22 original: "https://example.com&@mochitest.youtube.com/v/lG7U3fuNw3A", 23 changed: "https://example.com&@mochitest.youtube.com/embed/lG7U3fuNw3A", 24 }]; 25 let static_iframe = document.getElementById("staticiframe"); 26 27 function testEmbed(embed, i) { 28 ok (embed, "Embed node exists"); 29 embed = SpecialPowers.wrap(embed); 30 is (embed.srcURI.spec, test_urls[i].changed, "Should have src uri of " + test_urls[i].changed); 31 } 32 33 function testStatic() { 34 info("Running static embed youtube rewrite test"); 35 iframe_doc = static_iframe.contentWindow.document; 36 testEmbed(iframe_doc.getElementById("testembed"), 0); 37 testEmbed(iframe_doc.getElementById("testobject"), 0); 38 testEmbed(iframe_doc.getElementById("testembed2"), 1); 39 testEmbed(iframe_doc.getElementById("testobject2"), 1); 40 SimpleTest.executeSoon(() => { 41 testEmbed(embed_dynamic, 0); 42 SimpleTest.finish(); 43 }); 44 } 45 46 info("Running dynamic embed youtube rewrite test"); 47 let embed_dynamic = document.createElement("embed"); 48 embed_dynamic.src = "https://mochitest.youtube.com/v/Xm5i5kbIXzc"; 49 embed_dynamic.type = "application/x-shockwave-flash"; 50 document.body.appendChild(embed_dynamic); 51 52 static_iframe.onload = testStatic; 53 static_iframe.src = "file_bug769117.html" 54 55 }); 56 } 57 </script> 58 </head> 59 <body onload="onLoad()"> 60 <iframe id="staticiframe"></iframe> 61 </body> 62 </html>