forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DevTools: Don't remove CSS semi colons that might be meaningful
The CSS formatter tries to remove all duplicate semi colons. But if there is a syntax error in the CSS, it might incorrectly remove semicolons that would become meaningful. Bug: 908243 Change-Id: I1757d432bfd8b4688e7179bb7937d85e8bea8da2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1381552 Reviewed-by: Erik Luo <luoe@chromium.org> Commit-Queue: Joel Einbinder <einbinder@chromium.org> Cr-Commit-Position: refs/heads/master@{#642173}
- Loading branch information
1 parent
63563c2
commit c56204a
Showing
3 changed files
with
78 additions
and
16 deletions.
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
41 changes: 41 additions & 0 deletions
41
...arty/blink/web_tests/http/tests/devtools/elements/styles/styles-format-style-expected.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Tests that css properties are correctly formatted by the styles sidebar. | ||
|
||
Raw CSS: color: red; | ||
New CSS: | ||
color: red; | ||
|
||
|
||
Raw CSS: color: red;;; | ||
New CSS: | ||
color: red; | ||
|
||
|
||
Raw CSS: color: red;;;color: blue | ||
New CSS: | ||
color: red; | ||
color: blue; | ||
|
||
|
||
Raw CSS: color: var(-);margin: 0;padding:0 | ||
New CSS: | ||
color: var(-);margin: 0;padding:0 | ||
|
||
|
||
Raw CSS: color: red;/* a comment */;color: blue | ||
New CSS: | ||
color: red;/* a comment */ | ||
color: blue; | ||
|
||
|
||
Raw CSS: :; color: red; color: blue | ||
New CSS: :; | ||
color: red; | ||
color: blue; | ||
|
||
|
||
Raw CSS: color: red;/* a comment;;; */ :; color: blue; | ||
New CSS: | ||
color: red;/* a comment;;; */ :; | ||
color: blue; | ||
|
||
|
25 changes: 25 additions & 0 deletions
25
third_party/blink/web_tests/http/tests/devtools/elements/styles/styles-format-style.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
(async function() { | ||
TestRunner.addResult(`Tests that css properties are correctly formatted by the styles sidebar.`); | ||
await TestRunner.showPanel('elements'); | ||
const tokenizerFactory = await self.runtime.extension(TextUtils.TokenizerFactory).instance(); | ||
|
||
testText('color: red;'); | ||
testText('color: red;;;'); | ||
testText('color: red;;;color: blue'); | ||
testText('color: var(-);margin: 0;padding:0'); | ||
testText('color: red;/* a comment */;color: blue'); | ||
testText(`:; color: red; color: blue`); | ||
testText('color: red;/* a comment;;; */ :; color: blue;') | ||
TestRunner.completeTest(); | ||
|
||
function testText(cssText) { | ||
TestRunner.addResult(`\nRaw CSS: ${cssText}`); | ||
const newText = SDK.CSSProperty._formatStyle(cssText, ' ','', tokenizerFactory); | ||
TestRunner.addResult(`New CSS: ${newText}`); | ||
} | ||
|
||
})(); |