| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 | 3 |
| 4 <link rel="stylesheet" href="../styles/resources/styles-history.css"> | 4 <link rel="stylesheet" href="../styles/resources/styles-history.css"> |
| 5 | 5 |
| 6 <script src="../../../http/tests/inspector/inspector-test.js"></script> | 6 <script src="../../../http/tests/inspector/inspector-test.js"></script> |
| 7 <script src="../../../http/tests/inspector/elements-test.js"></script> | 7 <script src="../../../http/tests/inspector/elements-test.js"></script> |
| 8 <script src="../../../http/tests/inspector/resources-test.js"></script> | 8 <script src="../../../http/tests/inspector/resources-test.js"></script> |
| 9 <script src="../styles/styles-test.js"></script> | 9 <script src="../styles/styles-test.js"></script> |
| 10 <script> | 10 <script> |
| 11 | 11 |
| 12 function test() | 12 function test() |
| 13 { | 13 { |
| 14 InspectorTest.runAfterCachedResourcesProcessed(runTestSuite); | 14 InspectorTest.runAfterCachedResourcesProcessed(runTestSuite); |
| 15 | 15 |
| 16 var uiSourceCode; | 16 var uiSourceCode; |
| 17 | 17 |
| 18 function runTestSuite() | 18 function runTestSuite() |
| 19 { | 19 { |
| 20 InspectorTest.runTestSuite([ | 20 InspectorTest.runTestSuite([ |
| 21 function testSetUp(next) | 21 function testSetUp(next) |
| 22 { | 22 { |
| 23 function visitUISourceCodes(currentUISourceCode) | 23 function visitUISourceCodes(currentUISourceCode) |
| 24 { | 24 { |
| 25 if (currentUISourceCode.url().indexOf("styles-history.css")
=== -1) | 25 if (currentUISourceCode.url().indexOf("styles-history.css")
=== -1) |
| 26 return; | 26 return; |
| 27 uiSourceCode = currentUISourceCode; | 27 uiSourceCode = currentUISourceCode; |
| 28 next(); | 28 next(); |
| 29 } | 29 } |
| 30 WebInspector.workspace.uiSourceCodes().forEach(visitUISourceCode
s); | 30 Workspace.workspace.uiSourceCodes().forEach(visitUISourceCodes); |
| 31 }, | 31 }, |
| 32 | 32 |
| 33 function testSetResourceContentMinor(next) | 33 function testSetResourceContentMinor(next) |
| 34 { | 34 { |
| 35 InspectorTest.addSniffer(WebInspector.StyleFile.prototype, "_sty
leContentSet", styleUpdatedMinor); | 35 InspectorTest.addSniffer(Bindings.StyleFile.prototype, "_styleCo
ntentSet", styleUpdatedMinor); |
| 36 uiSourceCode.setWorkingCopy("body {\n margin: 15px;\n padding:
10px;\n}"); | 36 uiSourceCode.setWorkingCopy("body {\n margin: 15px;\n padding:
10px;\n}"); |
| 37 | 37 |
| 38 function styleUpdatedMinor() | 38 function styleUpdatedMinor() |
| 39 { | 39 { |
| 40 dumpHistory(next)(); | 40 dumpHistory(next)(); |
| 41 } | 41 } |
| 42 }, | 42 }, |
| 43 | 43 |
| 44 function testSetResourceContentMajor(next) | 44 function testSetResourceContentMajor(next) |
| 45 { | 45 { |
| 46 InspectorTest.addSniffer(WebInspector.StyleFile.prototype, "_sty
leContentSet", styleUpdatedMinor); | 46 InspectorTest.addSniffer(Bindings.StyleFile.prototype, "_styleCo
ntentSet", styleUpdatedMinor); |
| 47 uiSourceCode.setWorkingCopy("body {\n margin: 20px;\n padding:
10px;\n}"); | 47 uiSourceCode.setWorkingCopy("body {\n margin: 20px;\n padding:
10px;\n}"); |
| 48 | 48 |
| 49 function styleUpdatedMinor() | 49 function styleUpdatedMinor() |
| 50 { | 50 { |
| 51 InspectorTest.addSniffer(WebInspector.StyleFile.prototype, "
_styleContentSet", styleUpdatedMajor); | 51 InspectorTest.addSniffer(Bindings.StyleFile.prototype, "_sty
leContentSet", styleUpdatedMajor); |
| 52 uiSourceCode.commitWorkingCopy(function() { }); | 52 uiSourceCode.commitWorkingCopy(function() { }); |
| 53 | 53 |
| 54 function styleUpdatedMajor() | 54 function styleUpdatedMajor() |
| 55 { | 55 { |
| 56 dumpHistory(next)(); | 56 dumpHistory(next)(); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 }, | 59 }, |
| 60 | 60 |
| 61 function testSetContentViaModelMinor(next) | 61 function testSetContentViaModelMinor(next) |
| 62 { | 62 { |
| 63 styleSheetForResource(step1); | 63 styleSheetForResource(step1); |
| 64 | 64 |
| 65 function step1(style) | 65 function step1(style) |
| 66 { | 66 { |
| 67 var property = getLiveProperty(style, "margin"); | 67 var property = getLiveProperty(style, "margin"); |
| 68 property.setText("margin:25px;", false, true).then(dumpHisto
ry(next)); | 68 property.setText("margin:25px;", false, true).then(dumpHisto
ry(next)); |
| 69 } | 69 } |
| 70 }, | 70 }, |
| 71 | 71 |
| 72 function testSetContentViaModelMajor(next) | 72 function testSetContentViaModelMajor(next) |
| 73 { | 73 { |
| 74 styleSheetForResource(step1); | 74 styleSheetForResource(step1); |
| 75 | 75 |
| 76 function step1(style) | 76 function step1(style) |
| 77 { | 77 { |
| 78 var property = getLiveProperty(style, "margin"); | 78 var property = getLiveProperty(style, "margin"); |
| 79 InspectorTest.addSniffer(WebInspector.UISourceCode.prototype
, "addRevision", dumpHistory(next)); | 79 InspectorTest.addSniffer(Workspace.UISourceCode.prototype, "
addRevision", dumpHistory(next)); |
| 80 property.setText("margin:30px;", true, true); | 80 property.setText("margin:30px;", true, true); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 ]); | 83 ]); |
| 84 } | 84 } |
| 85 | 85 |
| 86 function styleSheetForResource(callback) | 86 function styleSheetForResource(callback) |
| 87 { | 87 { |
| 88 InspectorTest.nodeWithId("mainBody", onNodeSelected); | 88 InspectorTest.nodeWithId("mainBody", onNodeSelected); |
| 89 | 89 |
| 90 function onNodeSelected(node) | 90 function onNodeSelected(node) |
| 91 { | 91 { |
| 92 InspectorTest.CSSAgent.getMatchedStylesForNode(node.id, onMatchedSty
lesForNode); | 92 InspectorTest.CSSAgent.getMatchedStylesForNode(node.id, onMatchedSty
lesForNode); |
| 93 } | 93 } |
| 94 | 94 |
| 95 function onMatchedStylesForNode(error, inlineStyle, attributeStyle, matc
hedStyles) | 95 function onMatchedStylesForNode(error, inlineStyle, attributeStyle, matc
hedStyles) |
| 96 { | 96 { |
| 97 if (error) { | 97 if (error) { |
| 98 InspectorTest.addResult("error: " + error); | 98 InspectorTest.addResult("error: " + error); |
| 99 InspectorTest.completeTest(); | 99 InspectorTest.completeTest(); |
| 100 return; | 100 return; |
| 101 } | 101 } |
| 102 for (var i = 0; i < matchedStyles.length; ++i) { | 102 for (var i = 0; i < matchedStyles.length; ++i) { |
| 103 var rule = matchedStyles[i].rule; | 103 var rule = matchedStyles[i].rule; |
| 104 if (rule.origin !== "regular") | 104 if (rule.origin !== "regular") |
| 105 continue; | 105 continue; |
| 106 callback(new WebInspector.CSSStyleDeclaration(InspectorTest.cssM
odel, null, rule.style)); | 106 callback(new SDK.CSSStyleDeclaration(InspectorTest.cssModel, nul
l, rule.style)); |
| 107 return; | 107 return; |
| 108 } | 108 } |
| 109 InspectorTest.addResult("error: did not find any regular rule"); | 109 InspectorTest.addResult("error: did not find any regular rule"); |
| 110 InspectorTest.completeTest(); | 110 InspectorTest.completeTest(); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 function dumpHistory(next) | 114 function dumpHistory(next) |
| 115 { | 115 { |
| 116 function result() | 116 function result() |
| (...skipping 22 matching lines...) Expand all Loading... |
| 139 | 139 |
| 140 </script> | 140 </script> |
| 141 </head> | 141 </head> |
| 142 | 142 |
| 143 <body id="mainBody" onload="runTest()"> | 143 <body id="mainBody" onload="runTest()"> |
| 144 <p> | 144 <p> |
| 145 Tests resources panel history. | 145 Tests resources panel history. |
| 146 </p> | 146 </p> |
| 147 </body> | 147 </body> |
| 148 </html> | 148 </html> |
| OLD | NEW |