Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / svg / custom / load-svgfragments-inserted-after-docload.html
1 <!DOCTYPE html>
2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
4 <svg></svg>
5 <script>
6 const svgNs = 'http://www.w3.org/2000/svg';
7
8 function makeImage(test) {
9   var image = document.createElementNS(svgNs, 'image');
10   image.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', 'resources/red-checker.png');
11   image.setAttribute('width', 10);
12   image.setAttribute('height', 10);
13   image.onload = test.step_func(function() {
14     assert_true(true);
15     setTimeout(function() { test.done(); }, 0);
16   });
17   return image;
18 }
19
20 function makeSvg(test) {
21   var svgRoot = document.createElementNS(svgNs, 'svg');
22   svgRoot.onload = test.unreached_func("SVG 'load' should not be fired after document 'load'");
23   return svgRoot;
24 }
25
26 function makeSvgWithImage(test) {
27   var svgRoot = makeSvg(test);
28   svgRoot.appendChild(makeImage(test));
29   return svgRoot;
30 }
31
32 var t0 = async_test("No 'load' event fired after document load for outer SVG root.");
33 var t1 = async_test("No 'load' event fired after document load for outer SVG root w/ image.");
34 var t2 = async_test("No 'load' event fired after document load for inner SVG root.");
35 var t3 = async_test("No 'load' event fired after document load for inner SVG root w/ image.");
36
37 window.onload = function() {
38   var parsedSvg = document.querySelector('svg');
39
40   t0.step(function() { document.body.appendChild(makeSvg(t0)); });
41   t1.step(function() { document.body.appendChild(makeSvgWithImage(t1)); });
42
43   t2.step(function() { parsedSvg.appendChild(makeSvg(t2)); });
44   t3.step(function() { parsedSvg.appendChild(makeSvgWithImage(t3)); });
45
46   setTimeout(function() {
47     t0.done();
48     t2.done();
49   }, 0);
50 };
51 </script>