Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Web Inspector: [PARITY] Styles Redesign: Ability to modify style attr…
…ibutes https://bugs.webkit.org/show_bug.cgi?id=178328 <rdar://problem/35000990> Reviewed by Joseph Pecoraro. Source/WebInspectorUI: Before this patch, modifying a property of a style attribute duplicated the old property and appended the new one. This happened because WI.TextRange.prototype.resolveOffsets didn't resolve offsets correctly when text didn't end with a trailing new line. Since WI.TextRange.prototype.resolveOffsets is used elsewhere and this could be expected behavior, append a line break before resolving a range. * UserInterface/Models/CSSProperty.js: (WI.CSSProperty.prototype._updateOwnerStyleText): LayoutTests: Add tests for WI.TextRange.protopyte.resolveOffsets. * inspector/unit-tests/text-range-expected.txt: Added. * inspector/unit-tests/text-range.html: Added. Canonical link: https://commits.webkit.org/195173@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224210 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
5 changed files
with
126 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,16 @@ | ||
Testing that WI.TextRange works. | ||
|
||
|
||
== Running test suite: WI.TextRange | ||
-- Running test case: resolveOffsetsNoTrailingLineBreak | ||
PASS: startOffset should be 1. | ||
PASS: endOffset should be 0. | ||
|
||
-- Running test case: resolveOffsetsTrailingLineBreak | ||
PASS: startOffset should be 1. | ||
PASS: endOffset should be 14. | ||
|
||
-- Running test case: resolveOffsetsTwoTrailingLineBreaks | ||
PASS: startOffset should be 1. | ||
PASS: endOffset should be 14. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,76 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../../http/tests/inspector/resources/inspector-test.js"></script> | ||
<script> | ||
function test() { | ||
let suite = InspectorTest.createSyncSuite("WI.TextRange"); | ||
|
||
suite.addTestCase({ | ||
name: "resolveOffsetsNoTrailingLineBreak", | ||
description: "Ensure endOffset is zero when there's no trailing line break.", | ||
test() { | ||
let startLine = 1; | ||
let startColumn = 0; | ||
let endLine = 2; | ||
let endColumn = 0; | ||
let range = new WI.TextRange(startLine, startColumn, endLine, endColumn); | ||
|
||
let text = "\ncolor: blue;"; | ||
range.resolveOffsets(text); | ||
|
||
InspectorTest.expectEqual(range.startOffset, "\n".length, "startOffset should be 1."); | ||
InspectorTest.expectEqual(range.endOffset, 0, "endOffset should be 0."); | ||
|
||
return true; | ||
} | ||
}); | ||
|
||
suite.addTestCase({ | ||
name: "resolveOffsetsTrailingLineBreak", | ||
description: "Ensure endOffset is not zero when there's a trailing line break.", | ||
test() { | ||
let startLine = 1; | ||
let startColumn = 0; | ||
let endLine = 2; | ||
let endColumn = 0; | ||
let range = new WI.TextRange(startLine, startColumn, endLine, endColumn); | ||
|
||
let text = "\ncolor: blue;\n"; | ||
range.resolveOffsets(text); | ||
|
||
InspectorTest.expectEqual(range.startOffset, "\n".length, "startOffset should be 1."); | ||
InspectorTest.expectEqual(range.endOffset, text.length, "endOffset should be 14."); | ||
|
||
return true; | ||
} | ||
}); | ||
|
||
suite.addTestCase({ | ||
name: "resolveOffsetsTwoTrailingLineBreaks", | ||
description: "Ensure endOffset is not zero when there're two trailing line breaks.", | ||
test() { | ||
let startLine = 1; | ||
let startColumn = 0; | ||
let endLine = 2; | ||
let endColumn = 0; | ||
let range = new WI.TextRange(startLine, startColumn, endLine, endColumn); | ||
|
||
let text = "\ncolor: blue;\n\n"; | ||
range.resolveOffsets(text); | ||
|
||
InspectorTest.expectEqual(range.startOffset, "\n".length, "startOffset should be 1."); | ||
InspectorTest.expectEqual(range.endOffset, 14, "endOffset should be 14."); | ||
|
||
return true; | ||
} | ||
}); | ||
|
||
suite.runTestCasesAndFinish(); | ||
} | ||
</script> | ||
</head> | ||
<body onload="runTest()"> | ||
<p>Testing that WI.TextRange works.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters