Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(457)

Side by Side Diff: third_party/WebKit/LayoutTests/inspector/uisourcecode-revisions.html

Issue 2588503002: DevTools: Cache the original content on UISourceCode (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script> 3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script src="../http/tests/inspector/sources-test.js"></script> 4 <script src="../http/tests/inspector/sources-test.js"></script>
5 <script> 5 <script>
6 function test() 6 function test()
7 { 7 {
8 var mockProjectId = 0; 8 var mockProjectId = 0;
9 function createMockProject() 9 function createMockProject()
10 { 10 {
11 var workspace = new Workspace.Workspace(); 11 var workspace = new Workspace.Workspace();
12 var project = new Bindings.ContentProviderBasedProject(workspace, "mockP roject:" + (++mockProjectId)); 12 var project = new Bindings.ContentProviderBasedProject(workspace, "mockP roject:" + (++mockProjectId));
13 project.requestFileContent = function(uri, callback) 13 project.requestFileContent = function(uri, callback)
14 { 14 {
15 callback("<script content>"); 15 callback("<script content>");
16 } 16 }
17 project.setFileContent = function(uri, newContent, callback) 17 project.setFileContent = function(uri, newContent, callback)
18 { 18 {
19 } 19 }
20 return project; 20 return project;
21 } 21 }
22 22
23 function dumpUISourceCodeWithRevisions(uiSourceCode) 23 function dumpUISourceCodeWithRevisions(uiSourceCode)
24 { 24 {
25 var content = uiSourceCode._content; 25 var content = uiSourceCode._content;
26 var revisionsString = ""; 26 var revisionsString = "";
27 for (var i = 0; i < uiSourceCode.history.length; ++i) { 27 for (var i = 0; i < uiSourceCode.history.length; ++i) {
28 var revision = uiSourceCode.history[i]; 28 var revision = uiSourceCode.history[i];
29 if (i !== 0) 29 if (i !== 0)
30 revisionsString += ", "; 30 revisionsString += ", ";
31 revisionsString += "'" + revision.content + "'"; 31 revisionsString += "'" + revision.content + "'";
32 } 32 }
33 InspectorTest.addResult("UISourceCode content: " + content); 33 InspectorTest.addResult("UISourceCode content: " + content);
34 InspectorTest.addResult(" revisions: " + revisionsString); 34 InspectorTest.addResult(" revisions: " + revisionsString);
35 } 35 }
36 36
37 InspectorTest.runTestSuite([ 37 InspectorTest.runTestSuite([
38 function testAddRevisionsRevertToOriginal(next) 38 function testAddRevisionsRevertToOriginal(next)
39 { 39 {
40 var uiSourceCode = new Workspace.UISourceCode(createMockProject(), " url", Common.resourceTypes.Script); 40 var uiSourceCode = new Workspace.UISourceCode(createMockProject(), " url", Common.resourceTypes.Script);
41 uiSourceCode.setWorkingCopy("content1"); 41 uiSourceCode.requestContent().then( () => {
einbinder 2016/12/16 23:43:00 We need to signal our intention to use this uiSour
42 uiSourceCode.setWorkingCopy("content2"); 42 uiSourceCode.setWorkingCopy("content1");
43 uiSourceCode.commitWorkingCopy(function() { }); 43 uiSourceCode.setWorkingCopy("content2");
44 uiSourceCode.commitWorkingCopy(function() { });
44 45
45 InspectorTest.addResult("First revision added."); 46 InspectorTest.addResult("First revision added.");
46 dumpUISourceCodeWithRevisions(uiSourceCode); 47 dumpUISourceCodeWithRevisions(uiSourceCode);
47 uiSourceCode.setWorkingCopy("content3"); 48 uiSourceCode.setWorkingCopy("content3");
48 uiSourceCode.setWorkingCopy("content4"); 49 uiSourceCode.setWorkingCopy("content4");
49 uiSourceCode.commitWorkingCopy(function() { }); 50 uiSourceCode.commitWorkingCopy(function() { });
50 51
51 InspectorTest.addResult("Second revision added."); 52 InspectorTest.addResult("Second revision added.");
52 dumpUISourceCodeWithRevisions(uiSourceCode); 53 dumpUISourceCodeWithRevisions(uiSourceCode);
53 uiSourceCode.revertToOriginal().then(onReverted); 54 uiSourceCode.revertToOriginal().then(onReverted);
54 55
55 function onReverted() 56 function onReverted()
56 { 57 {
57 InspectorTest.addResult("Reverted to original."); 58 InspectorTest.addResult("Reverted to original.");
58 dumpUISourceCodeWithRevisions(uiSourceCode); 59 dumpUISourceCodeWithRevisions(uiSourceCode);
59 next(); 60 next();
60 } 61 }
62 });
61 }, 63 },
62 64
63 function testAddRevisionsRevertAndClearHistory(next) 65 function testAddRevisionsRevertAndClearHistory(next)
64 { 66 {
65 var uiSourceCode = new Workspace.UISourceCode(createMockProject(), " url2", Common.resourceTypes.Script); 67 var uiSourceCode = new Workspace.UISourceCode(createMockProject(), " url2", Common.resourceTypes.Script);
68 uiSourceCode.requestContent().then( () => {
69 uiSourceCode.setWorkingCopy("content1");
70 uiSourceCode.setWorkingCopy("content2");
71 uiSourceCode.commitWorkingCopy(function() { });
66 72
67 uiSourceCode.setWorkingCopy("content1"); 73 InspectorTest.addResult("First revision added.");
68 uiSourceCode.setWorkingCopy("content2"); 74 dumpUISourceCodeWithRevisions(uiSourceCode);
69 uiSourceCode.commitWorkingCopy(function() { }); 75 uiSourceCode.setWorkingCopy("content3");
76 uiSourceCode.setWorkingCopy("content4");
77 uiSourceCode.commitWorkingCopy(function() { });
70 78
71 InspectorTest.addResult("First revision added."); 79 InspectorTest.addResult("Second revision added.");
72 dumpUISourceCodeWithRevisions(uiSourceCode); 80 dumpUISourceCodeWithRevisions(uiSourceCode);
73 uiSourceCode.setWorkingCopy("content3"); 81 uiSourceCode.revertAndClearHistory(revertedAndClearedHistory);
74 uiSourceCode.setWorkingCopy("content4");
75 uiSourceCode.commitWorkingCopy(function() { });
76 82
77 InspectorTest.addResult("Second revision added."); 83 function revertedAndClearedHistory()
78 dumpUISourceCodeWithRevisions(uiSourceCode); 84 {
79 uiSourceCode.revertAndClearHistory(revertedAndClearedHistory); 85 InspectorTest.addResult("Reverted and cleared history.");
80 86 dumpUISourceCodeWithRevisions(uiSourceCode);
81 function revertedAndClearedHistory() 87 next();
82 { 88 }
83 InspectorTest.addResult("Reverted and cleared history."); 89 });
84 dumpUISourceCodeWithRevisions(uiSourceCode);
85 next();
86 }
87 }, 90 },
88 91
89 function testAddRevisionsRevertToPrevious(next) 92 function testAddRevisionsRevertToPrevious(next)
90 { 93 {
91 var uiSourceCode = new Workspace.UISourceCode(createMockProject(), " url3", Common.resourceTypes.Script); 94 var uiSourceCode = new Workspace.UISourceCode(createMockProject(), " url3", Common.resourceTypes.Script);
95 uiSourceCode.requestContent().then( () => {
96 uiSourceCode.setWorkingCopy("content1");
97 uiSourceCode.setWorkingCopy("content2");
98 uiSourceCode.commitWorkingCopy(function() { });
92 99
93 uiSourceCode.setWorkingCopy("content1"); 100 InspectorTest.addResult("First revision added.");
94 uiSourceCode.setWorkingCopy("content2"); 101 dumpUISourceCodeWithRevisions(uiSourceCode);
95 uiSourceCode.commitWorkingCopy(function() { }); 102 uiSourceCode.setWorkingCopy("content3");
103 uiSourceCode.setWorkingCopy("content4");
104 uiSourceCode.commitWorkingCopy(function() { });
96 105
97 InspectorTest.addResult("First revision added."); 106 InspectorTest.addResult("Second revision added.");
98 dumpUISourceCodeWithRevisions(uiSourceCode); 107 dumpUISourceCodeWithRevisions(uiSourceCode);
99 uiSourceCode.setWorkingCopy("content3"); 108 uiSourceCode.history[0].revertToThis().then(onReverted);
100 uiSourceCode.setWorkingCopy("content4");
101 uiSourceCode.commitWorkingCopy(function() { });
102 109
103 InspectorTest.addResult("Second revision added."); 110 function onReverted()
104 dumpUISourceCodeWithRevisions(uiSourceCode); 111 {
105 uiSourceCode.history[0].revertToThis().then(onReverted); 112 InspectorTest.addResult("Reverted to previous revision.");
106 113 dumpUISourceCodeWithRevisions(uiSourceCode);
107 function onReverted() 114 next();
108 { 115 }
109 InspectorTest.addResult("Reverted to previous revision."); 116 });
110 dumpUISourceCodeWithRevisions(uiSourceCode);
111 next();
112 }
113 }, 117 },
114 118
115 function testRequestContentAddRevisionsRevertToOriginal(next) 119 function testRequestContentAddRevisionsRevertToOriginal(next)
116 { 120 {
117 var uiSourceCode = new Workspace.UISourceCode(createMockProject(), " url4", Common.resourceTypes.Script); 121 var uiSourceCode = new Workspace.UISourceCode(createMockProject(), " url4", Common.resourceTypes.Script);
118 uiSourceCode.requestContent().then(contentReceived); 122 uiSourceCode.requestContent().then(contentReceived);
119 123
120 function contentReceived() 124 function contentReceived()
121 { 125 {
122 InspectorTest.addResult("Content requested."); 126 InspectorTest.addResult("Content requested.");
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 }, 213 },
210 ]); 214 ]);
211 } 215 }
212 </script> 216 </script>
213 </head> 217 </head>
214 <body onload="runTest()"> 218 <body onload="runTest()">
215 <p>Tests revision support in UISourceCode.</p> 219 <p>Tests revision support in UISourceCode.</p>
216 <a href="https://bugs.webkit.org/show_bug.cgi?id=97669">Bug 97669</a> 220 <a href="https://bugs.webkit.org/show_bug.cgi?id=97669">Bug 97669</a>
217 </body> 221 </body>
218 </html> 222 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698