Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / debugger / source-frame-count.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/debugger-test.js"></script>
5 <script src="resources/script1.js"></script>
6 <script src="resources/script2.js"></script>
7 <script src="resources/script3.js"></script>
8
9 <script>
10
11 function test()
12 {
13     InspectorTest.runDebuggerTestSuite([
14         function testSourceFramesCount(next)
15         {
16             var panel = WebInspector.panels.sources;
17             var select = panel._navigator._filesSelectElement;
18             var sourceFrameCount = 0;
19
20             InspectorTest.showScriptSource("source-frame-count.html", step2);
21
22             function step2()
23             {
24                 InspectorTest.showScriptSource("script1.js", step3);
25             }
26
27             function step3()
28             {
29                 InspectorTest.showScriptSource("script2.js", didShowScriptSources);
30             }
31
32             function didShowScriptSources()
33             {
34                 var alreadyShownURLs = {};
35                 function didCreateSourceFrame()
36                 {
37                     if (!alreadyShownURLs[this._uiSourceCode.originURL()])
38                         sourceFrameCount += 1;
39                     alreadyShownURLs[this._uiSourceCode.originURL()] = true;
40                 }
41                 InspectorTest.addSniffer(WebInspector.SourceFrame.prototype, "wasShown", didCreateSourceFrame, true);
42                 InspectorTest.reloadPage(didReload);
43             }
44
45             function didReload()
46             {
47                 InspectorTest.showScriptSource("script3.js", didShowScriptSourceAgain);
48             }
49
50             function didShowScriptSourceAgain()
51             {
52                 InspectorTest.assertTrue(panel._editorContainer.visibleView._uiSourceCode.originURL().indexOf("script3.js") !== -1);
53                 // There should be maximum 3 source frames shown:
54                 //  - first one is the first shown (first tab added)
55                 //  - second one is the last viewed ("script2.js")
56                 //  - third one is explicitly selected script3.js.
57                 InspectorTest.assertEquals(true, sourceFrameCount <= 3, "too many source frames created after page reload");
58                 next();
59             }
60         }
61     ]);
62 };
63
64 </script>
65
66 <script>
67 function secondInlinedScriptInPage()
68 {
69     return 0;
70 }
71 </script>
72
73 <script>
74 function thirdInlinedScriptInPage()
75 {
76     return 0;
77 }
78 </script>
79
80 <script>
81 function fourthInlinedScriptInPage()
82 {
83     return 0;
84 }
85 </script>
86
87 </head>
88
89 <body onload="runTest()">
90 <p>Tests that scripts panel does not create too many source frames.</p>
91
92 </body>
93 </html>