Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / uisourcecode-revisions.html
blobf62f43b4f7ef6e3f5aaa7dfa583c8e230bcb9f14
1 <html>
2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script src="../http/tests/inspector/sources-test.js"></script>
5 <script>
6 function test()
8 function createMockProject()
10 var workspace = new WebInspector.Workspace();
11 var projectDelegate = new WebInspector.NetworkProjectDelegate(InspectorTest.mainTarget, workspace, "");
12 var project = workspace.addProject("projectId", projectDelegate);
13 project.requestFileContent = function(uri, callback)
15 callback("<script content>");
17 project.setFileContent = function(uri, newContent, callback)
20 project.fileMimeType = function(uri)
22 return "text/javascript";
25 return project;
28 function dumpUISourceCodeWithRevisions(uiSourceCode)
30 var content = uiSourceCode._content;
31 var revisionsString = "";
32 for (var i = 0; i < uiSourceCode.history.length; ++i) {
33 var revision = uiSourceCode.history[i];
34 if (i !== 0)
35 revisionsString += ", ";
36 revisionsString += "'" + revision.content + "'";
38 InspectorTest.addResult("UISourceCode content: " + content);
39 InspectorTest.addResult(" revisions: " + revisionsString);
42 InspectorTest.runTestSuite([
43 function testAddRevisionsRevertToOriginal(next)
45 var uiSourceCode = new WebInspector.UISourceCode(createMockProject(), "", "uri", "originURL", "url", WebInspector.resourceTypes.Script);
46 uiSourceCode.setWorkingCopy("content1");
47 uiSourceCode.setWorkingCopy("content2");
48 uiSourceCode.commitWorkingCopy(function() { });
50 InspectorTest.addResult("First revision added.");
51 dumpUISourceCodeWithRevisions(uiSourceCode);
52 uiSourceCode.setWorkingCopy("content3");
53 uiSourceCode.setWorkingCopy("content4");
54 uiSourceCode.commitWorkingCopy(function() { });
56 InspectorTest.addResult("Second revision added.");
57 dumpUISourceCodeWithRevisions(uiSourceCode);
58 uiSourceCode.revertToOriginal();
59 InspectorTest.addResult("Reverted to original.");
60 dumpUISourceCodeWithRevisions(uiSourceCode);
61 next();
64 function testAddRevisionsRevertAndClearHistory(next)
66 var uiSourceCode = new WebInspector.UISourceCode(createMockProject(), "", "uri2", "originURL2", "url2", WebInspector.resourceTypes.Script);
68 uiSourceCode.setWorkingCopy("content1");
69 uiSourceCode.setWorkingCopy("content2");
70 uiSourceCode.commitWorkingCopy(function() { });
72 InspectorTest.addResult("First revision added.");
73 dumpUISourceCodeWithRevisions(uiSourceCode);
74 uiSourceCode.setWorkingCopy("content3");
75 uiSourceCode.setWorkingCopy("content4");
76 uiSourceCode.commitWorkingCopy(function() { });
78 InspectorTest.addResult("Second revision added.");
79 dumpUISourceCodeWithRevisions(uiSourceCode);
80 uiSourceCode.revertAndClearHistory(revertedAndClearedHistory);
82 function revertedAndClearedHistory()
84 InspectorTest.addResult("Reverted and cleared history.");
85 dumpUISourceCodeWithRevisions(uiSourceCode);
86 next();
90 function testAddRevisionsRevertToPrevious(next)
92 var uiSourceCode = new WebInspector.UISourceCode(createMockProject(), "", "uri3", "originURL3", "url3", WebInspector.resourceTypes.Script);
94 uiSourceCode.setWorkingCopy("content1");
95 uiSourceCode.setWorkingCopy("content2");
96 uiSourceCode.commitWorkingCopy(function() { });
98 InspectorTest.addResult("First revision added.");
99 dumpUISourceCodeWithRevisions(uiSourceCode);
100 uiSourceCode.setWorkingCopy("content3");
101 uiSourceCode.setWorkingCopy("content4");
102 uiSourceCode.commitWorkingCopy(function() { });
104 InspectorTest.addResult("Second revision added.");
105 dumpUISourceCodeWithRevisions(uiSourceCode);
106 uiSourceCode.history[0].revertToThis();
107 InspectorTest.addResult("Reverted to previous revision.");
108 dumpUISourceCodeWithRevisions(uiSourceCode);
109 next();
112 function testRequestContentAddRevisionsRevertToOriginal(next)
114 var uiSourceCode = new WebInspector.UISourceCode(createMockProject(), "", "uri4", "originURL4", "url4", WebInspector.resourceTypes.Script);
115 uiSourceCode.requestContent(contentReceived);
117 function contentReceived()
119 InspectorTest.addResult("Content requested.");
120 dumpUISourceCodeWithRevisions(uiSourceCode);
121 uiSourceCode.setWorkingCopy("content1");
122 uiSourceCode.setWorkingCopy("content2");
123 uiSourceCode.commitWorkingCopy(function() { });
125 InspectorTest.addResult("First revision added.");
126 dumpUISourceCodeWithRevisions(uiSourceCode);
127 uiSourceCode.setWorkingCopy("content3");
128 uiSourceCode.setWorkingCopy("content4");
129 uiSourceCode.commitWorkingCopy(function() { });
131 InspectorTest.addResult("Second revision added.");
132 dumpUISourceCodeWithRevisions(uiSourceCode);
133 uiSourceCode.revertToOriginal();
134 InspectorTest.addResult("Reverted to original.");
135 dumpUISourceCodeWithRevisions(uiSourceCode);
136 next();
140 function testRequestContentAddRevisionsRevertAndClearHistory(next)
142 var uiSourceCode = new WebInspector.UISourceCode(createMockProject(), "", "uri5", "originURL5", "url5", WebInspector.resourceTypes.Script);
143 uiSourceCode.requestContent(contentReceived);
145 function contentReceived()
147 InspectorTest.addResult("Content requested.");
148 dumpUISourceCodeWithRevisions(uiSourceCode);
149 uiSourceCode.setWorkingCopy("content1");
150 uiSourceCode.setWorkingCopy("content2");
151 uiSourceCode.commitWorkingCopy(function() { });
153 InspectorTest.addResult("First revision added.");
154 dumpUISourceCodeWithRevisions(uiSourceCode);
155 uiSourceCode.setWorkingCopy("content3");
156 uiSourceCode.setWorkingCopy("content4");
157 uiSourceCode.commitWorkingCopy(function() { });
159 InspectorTest.addResult("Second revision added.");
160 dumpUISourceCodeWithRevisions(uiSourceCode);
161 uiSourceCode.revertAndClearHistory(revertedAndClearedHistory);
163 function revertedAndClearedHistory()
165 InspectorTest.addResult("Reverted and cleared history.");
166 dumpUISourceCodeWithRevisions(uiSourceCode);
167 next();
172 function testRequestContentAddRevisionsRevertToPrevious(next)
174 var uiSourceCode = new WebInspector.UISourceCode(createMockProject(), "", "uri6", "originURL6", "url6", WebInspector.resourceTypes.Script);
175 uiSourceCode.requestContent(contentReceived);
177 function contentReceived()
179 InspectorTest.addResult("Content requested.");
180 dumpUISourceCodeWithRevisions(uiSourceCode);
181 uiSourceCode.setWorkingCopy("content1");
182 uiSourceCode.setWorkingCopy("content2");
183 uiSourceCode.commitWorkingCopy(function() { });
185 InspectorTest.addResult("First revision added.");
186 dumpUISourceCodeWithRevisions(uiSourceCode);
187 uiSourceCode.setWorkingCopy("content3");
188 uiSourceCode.setWorkingCopy("content4");
189 uiSourceCode.commitWorkingCopy(function() { });
191 InspectorTest.addResult("Second revision added.");
192 dumpUISourceCodeWithRevisions(uiSourceCode);
193 uiSourceCode.history[0].revertToThis();
194 InspectorTest.addResult("Reverted to previous revision.");
195 dumpUISourceCodeWithRevisions(uiSourceCode);
196 next();
201 </script>
202 </head>
203 <body onload="runTest()">
204 <p>Tests revision support in UISourceCode.</p>
205 <a href="https://bugs.webkit.org/show_bug.cgi?id=97669">Bug 97669</a>
206 </body>
207 </html>