content/base/test/test_bug453736.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/test/test_bug453736.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=453736
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 453736</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.13 +</head>
    1.14 +<body>
    1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=453736">Mozilla Bug 453736</a>
    1.16 +<p id="display"></p>
    1.17 +<div id="content" style="display: none">
    1.18 +</div>
    1.19 +<pre id="test">
    1.20 +<script type="application/javascript">
    1.21 +/** Test for Bug 453736 **/
    1.22 +SimpleTest.waitForExplicitFinish();
    1.23 +addLoadEvent(function() {
    1.24 +  const scriptCreationFuncs = [
    1.25 +    function() { return document.createElement("script"); },
    1.26 +    function() { return document.createElementNS("http://www.w3.org/2000/svg", "script"); }
    1.27 +  ];
    1.28 +
    1.29 +  const scriptContainers = ["div", "iframe", "noframes", "noembed"];
    1.30 +  for (var i = 0; i < scriptContainers.length; ++i) {
    1.31 +    for (var func of scriptCreationFuncs) {
    1.32 +      var cont = scriptContainers[i];
    1.33 +      var node = document.createElement(cont);
    1.34 +      document.body.appendChild(node);
    1.35 +      var s = func();
    1.36 +      s.setAttribute("type", "application/javascript");
    1.37 +      s.appendChild(document.createTextNode('window["'+cont+'ScriptRan"] = true'));
    1.38 +
    1.39 +      window[cont+"ScriptRan"] = false;
    1.40 +      node.appendChild(s);
    1.41 +      is(window[cont+"ScriptRan"], true,
    1.42 +         "Script created with " + func +" should run when inserting in <"+cont+">");
    1.43 +
    1.44 +      window[cont+"ScriptRan"] = false;
    1.45 +      document.body.appendChild(s);
    1.46 +      is(window[cont+"ScriptRan"], false,
    1.47 +         "Script created with " + func + " shouldn't run when moving out of <"+cont+">");
    1.48 +
    1.49 +      window[cont+"ScriptRan"] = false;
    1.50 +      document.body.appendChild(s.cloneNode(true));
    1.51 +      is(window[cont+"ScriptRan"], false,
    1.52 +         "Clone of script inside <" + cont + "> created with " + func + " shouldn't run");
    1.53 +    }
    1.54 +  }
    1.55 +
    1.56 +  SimpleTest.finish();
    1.57 +});
    1.58 +</script>
    1.59 +</pre>
    1.60 +</body>
    1.61 +</html>

mercurial