| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../inspector-test.js"></script> | 3 <script src="../../inspector-test.js"></script> |
| 4 <script src="../../debugger-test.js"></script> | 4 <script src="../../debugger-test.js"></script> |
| 5 <script src="../../elements-test.js"></script> | 5 <script src="../../elements-test.js"></script> |
| 6 <script src="../../isolated-filesystem-test.js"></script> | 6 <script src="../../isolated-filesystem-test.js"></script> |
| 7 <style>#inspected { |
| 8 color: red; |
| 9 } |
| 10 /*# sourceURL=http://localhost:8000/inspector/elements/styles/foo.css */ |
| 11 </style> |
| 7 <script> | 12 <script> |
| 8 function loadStylesheet(line0, line1, line2) | 13 |
| 14 async function test() |
| 9 { | 15 { |
| 10 var styleText = "#inspected {\n color: red;\n}\n"; | 16 InspectorTest.markStep('testEditingRulesInElementsPanelDoesNotAddSourceURLTo
OriginalFile'); |
| 11 var styleElement = document.createElement("style"); | |
| 12 styleElement.type = "text/css"; | |
| 13 var sourceURL = "http://localhost:8000/inspector/elements/styles/foo.css"; | |
| 14 var stylesheetContent = styleText + "\n/*# sourceURL=" + sourceURL + " */"; | |
| 15 styleElement.textContent = stylesheetContent; | |
| 16 document.head.appendChild(styleElement); | |
| 17 } | |
| 18 | 17 |
| 19 function test() | 18 var uiSourceCode = await InspectorTest.waitForUISourceCode('foo.css'); |
| 20 { | 19 await uiSourceCode.requestContent(); |
| 21 InspectorTest.runTestSuite([ | 20 InspectorTest.addResult("Dumping uiSourceCode content:"); |
| 22 function testEditingRulesInElementsPanelDoesNotAddSourceURLToOriginalFil
e(next) | 21 InspectorTest.addResult(uiSourceCode.workingCopy()); |
| 23 { | 22 InspectorTest.selectNodeAndWaitForStyles("inspected", nodeSelected); |
| 24 var fileSystemPath = "file:///var/www"; | |
| 25 | 23 |
| 26 function dumpUISourceCodeContents() | 24 var uiSourceCode; |
| 27 { | |
| 28 InspectorTest.addResult("Dumping uiSourceCode content:"); | |
| 29 InspectorTest.addResult(uiSourceCode.workingCopy()); | |
| 30 } | |
| 31 | 25 |
| 32 InspectorTest.addResult("Adding file system."); | 26 function nodeSelected() |
| 33 var fs = new InspectorTest.TestFileSystem(fileSystemPath); | 27 { |
| 34 fs.root.addFile("foo.css", "#inspected {\n color: red;\n}\n"); | 28 InspectorTest.addResult("Dumping matched rules:"); |
| 35 InspectorTest.addResult("Adding file system mapping."); | 29 InspectorTest.dumpSelectedElementStyles(true); |
| 36 fs.addFileMapping("http://localhost:8000/inspector/elements/styles/"
, "/"); | 30 InspectorTest.addResult("Editing styles from elements panel:"); |
| 37 fs.reportCreated(fileSystemCreated); | 31 var treeElement = InspectorTest.getMatchedStylePropertyTreeItem("color")
; |
| 32 treeElement.startEditing(); |
| 33 treeElement.nameElement.textContent = "color"; |
| 34 treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Ente
r")); |
| 38 | 35 |
| 39 var uiSourceCode; | 36 // Commit editing. |
| 37 treeElement.valueElement.textContent = "green"; |
| 38 treeElement.valueElement.firstChild.select(); |
| 39 treeElement.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Ent
er")); |
| 40 uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingCopyC
ommitted, stylesEdited, this); |
| 41 } |
| 40 | 42 |
| 41 function fileSystemCreated() | 43 function stylesEdited() |
| 42 { | 44 { |
| 43 var fileSystemProjectId = Persistence.FileSystemWorkspaceBinding
.projectId(fileSystemPath); | 45 InspectorTest.addResult("Styles edited."); |
| 44 uiSourceCode = Workspace.workspace.uiSourceCode(fileSystemProjec
tId, "file:///var/www/foo.css"); | 46 InspectorTest.addResult("Dumping matched rules:"); |
| 45 InspectorTest.showUISourceCode(uiSourceCode, didShowScriptSource
); | 47 InspectorTest.dumpSelectedElementStyles(true); |
| 46 } | 48 InspectorTest.addResult("Dumping uiSourceCode content:"); |
| 47 | 49 InspectorTest.addResult(uiSourceCode.workingCopy()); |
| 48 function didShowScriptSource(sourceFrame) | 50 InspectorTest.completeTest(); |
| 49 { | 51 } |
| 50 dumpUISourceCodeContents(); | |
| 51 InspectorTest.addResult("Loading stylesheet with sourceURL:"); | |
| 52 InspectorTest.cssModel.addEventListener(SDK.CSSModel.Events.Styl
eSheetAdded, stylesheetLoaded); | |
| 53 InspectorTest.evaluateInPage("loadStylesheet()"); | |
| 54 } | |
| 55 | |
| 56 function stylesheetLoaded(event) | |
| 57 { | |
| 58 if (!event.data.sourceURL.includes("foo.css")) | |
| 59 return; | |
| 60 InspectorTest.cssModel.removeEventListener(SDK.CSSModel.Events.S
tyleSheetAdded, stylesheetLoaded); | |
| 61 InspectorTest.addResult("Stylesheet loaded."); | |
| 62 InspectorTest.selectNodeAndWaitForStyles("inspected", nodeSelect
ed); | |
| 63 } | |
| 64 | |
| 65 function nodeSelected() | |
| 66 { | |
| 67 InspectorTest.addResult("Dumping matched rules:"); | |
| 68 InspectorTest.dumpSelectedElementStyles(true); | |
| 69 InspectorTest.addResult("Editing styles from elements panel:"); | |
| 70 treeElement = InspectorTest.getMatchedStylePropertyTreeItem("col
or"); | |
| 71 treeElement.startEditing(); | |
| 72 treeElement.nameElement.textContent = "color"; | |
| 73 treeElement.nameElement.dispatchEvent(InspectorTest.createKeyEve
nt("Enter")); | |
| 74 | |
| 75 // Commit editing. | |
| 76 treeElement.valueElement.textContent = "green"; | |
| 77 treeElement.valueElement.firstChild.select(); | |
| 78 treeElement.valueElement.dispatchEvent(InspectorTest.createKeyEv
ent("Enter")); | |
| 79 uiSourceCode.addEventListener(Workspace.UISourceCode.Events.Work
ingCopyCommitted, stylesEdited, this); | |
| 80 } | |
| 81 | |
| 82 function stylesEdited() | |
| 83 { | |
| 84 InspectorTest.addResult("Styles edited."); | |
| 85 InspectorTest.addResult("Dumping matched rules:"); | |
| 86 InspectorTest.dumpSelectedElementStyles(true); | |
| 87 dumpUISourceCodeContents(); | |
| 88 InspectorTest.addResult("All done."); | |
| 89 next(); | |
| 90 } | |
| 91 } | |
| 92 ]); | |
| 93 }; | 52 }; |
| 94 </script> | 53 </script> |
| 95 </head> | 54 </head> |
| 96 <body onload="runTest()"> | 55 <body onload="runTest()"> |
| 97 <div id="inspected"></div> | 56 <div id="inspected"></div> |
| 98 <p>Tests file system project mappings.</p> | 57 <p>Tests file system project mappings.</p> |
| 99 </body> | 58 </body> |
| 100 </html> | 59 </html> |
| OLD | NEW |