Bug 194619

Summary: Web Inspector: Styles: valid values in style attributes are reported as unsupported property values
Product: WebKit Reporter: Nikita Vasilyev <nvasilyev>
Component: Web InspectorAssignee: Nikita Vasilyev <nvasilyev>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, hi, inspector-bugzilla-changes, joepeck, tsavell, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Bug Depends on: 194676    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
[Video] Bug
none
Patch
hi: review+, hi: commit-queue-
Patch
none
Patch
joepeck: review+
Patch none

Description Nikita Vasilyev 2019-02-13 15:43:32 PST
<rdar://problem/47917373>
Comment 1 Nikita Vasilyev 2019-02-13 16:49:37 PST
Created attachment 361965 [details]
Patch
Comment 2 Nikita Vasilyev 2019-02-13 17:13:37 PST
Created attachment 361971 [details]
[Video] Bug

The problem was mismatching text ranges, which caused all kind of data corruption bugs.
Comment 3 Nikita Vasilyev 2019-02-13 17:23:28 PST
Created attachment 361972 [details]
Patch

I removed unrelated code changes.
Comment 4 Devin Rousso 2019-02-13 17:53:07 PST
Comment on attachment 361972 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=361972&action=review

rs=me, please wait for EWS

> LayoutTests/inspector/css/modify-inline-style.html:7
> +    let nodeStyles = null;

Style: missing newline after.

> LayoutTests/inspector/css/modify-inline-style.html:11
> +        name: "AddPropertyAndEdit",

Please prefix the test case name with the test suite name.

    name: "ModifyInlineStyle.AddPropertyAndEdit",

> LayoutTests/inspector/css/modify-inline-style.html:27
> +            fontProperty.rawValue = "12px normal sans-serif!important";

Style: missing space before `!important`.

> LayoutTests/inspector/css/modify-inline-style.html:28
> +            let colorProperty = null;

Style: missing newline before.

> LayoutTests/inspector/css/modify-inline-style.html:30
> +            WI.CSSProperty.addEventListener(WI.CSSProperty.Event.Changed, function(event) {

NIT: just in case, you should remove this listener when the test case completes.
NIT: arrow function?

> LayoutTests/inspector/css/modify-inline-style.html:38
> +            fontProperty.awaitEvent(WI.CSSProperty.Event.Changed).then((event) => {

Please put the `.then(` on a new line.

> LayoutTests/inspector/css/modify-inline-style.html:56
> +            }).then(() => {
> +                resolve();
> +                return true;
> +            });

Rather than put `resolve()` inside a `.then(`, you can use it directly as the callback.

    .then(resolve, reject);

> Source/WebInspectorUI/ChangeLog:10
> +        the actual text of the payload â it has an extra empty line at the end.

non-ascii character :(

> Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js:539
> +        if (payload.range) {

In order to avoid retyping `payload.range` everywhere, you should pull it out into a variable (like all the other ones at the top of this function) and include a fallback value (an empty object).

> Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js:540
> +            // Last property of inline style has mismatching range.

If this is only supposed to happen for inline styles, we should assert inside the last `if` that `styleDeclaration.type === WI.CSSStyleDeclaration.Type.Inline`.  If not, please remove this comment (or make it more general).

> Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js:544
> +                let textLineCount = payload.text.lineCount;

You can just use `text`, since it has a fallback as well.

> Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js:547
> +                    payload.range.endColumn = payload.range.startColumn + payload.text.lastLine.length;

Ditto (>544).
Comment 5 Nikita Vasilyev 2019-02-13 19:04:32 PST
Comment on attachment 361972 [details]
Patch

Thanks for the review!

View in context: https://bugs.webkit.org/attachment.cgi?id=361972&action=review

>> LayoutTests/inspector/css/modify-inline-style.html:27
>> +            fontProperty.rawValue = "12px normal sans-serif!important";
> 
> Style: missing space before `!important`.

I think we should use all kind of code styles for test data. The no-space !important is used on medium.com.

>> Source/WebInspectorUI/ChangeLog:10
>> +        the actual text of the payload â it has an extra empty line at the end.
> 
> non-ascii character :(

Our review tools are bad :(
Comment 6 Nikita Vasilyev 2019-02-13 19:10:28 PST
Created attachment 361984 [details]
Patch
Comment 7 Nikita Vasilyev 2019-02-13 21:07:11 PST
Comment on attachment 361984 [details]
Patch

Unrelated test failures on Mac Debug. cq+
Comment 8 WebKit Commit Bot 2019-02-13 21:32:43 PST
Comment on attachment 361984 [details]
Patch

Clearing flags on attachment: 361984

Committed r241497: <https://trac.webkit.org/changeset/241497>
Comment 9 WebKit Commit Bot 2019-02-13 21:32:44 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 Truitt Savell 2019-02-14 09:55:09 PST
The new test inspector/css/modify-inline-style.html

added in https://trac.webkit.org/changeset/241497/webkit

is a constant timeout on Mac Release WK2.

History:
http://webkit-test-results.webkit.org/dashboards/flakiness_dashboard.html#showAllRuns=true&tests=inspector%2Fcss%2Fmodify-inline-style.html
Comment 11 WebKit Commit Bot 2019-02-14 14:50:36 PST
Re-opened since this is blocked by bug 194676
Comment 12 Nikita Vasilyev 2019-02-14 23:25:08 PST
Created attachment 362101 [details]
Patch
Comment 13 Nikita Vasilyev 2019-02-14 23:28:37 PST
Comment on attachment 362101 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=362101&action=review

> LayoutTests/inspector/css/modify-inline-style.html:85
> +                nodeStyles.addEventListener(WI.DOMNodeStyles.Event.NeedsRefresh, function(event) {
> +                    // Normally, this would get called from views if the styles sidebar is visible.
> +                    // This doesn't work in tests.
> +                    event.target.refresh();
> +                });

Joe and I investigated the problem. This fixed test timeouts on WK2. The rest of the patch is the same as the one that was rolled out.
Comment 14 Joseph Pecoraro 2019-02-15 13:52:17 PST
(In reply to Nikita Vasilyev from comment #13)
> Comment on attachment 362101 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=362101&action=review
> 
> > LayoutTests/inspector/css/modify-inline-style.html:85
> > +                nodeStyles.addEventListener(WI.DOMNodeStyles.Event.NeedsRefresh, function(event) {
> > +                    // Normally, this would get called from views if the styles sidebar is visible.
> > +                    // This doesn't work in tests.
> > +                    event.target.refresh();
> > +                });
> 
> Joe and I investigated the problem. This fixed test timeouts on WK2. The
> rest of the patch is the same as the one that was rolled out.

Yeah, I really think this is something all of the DOMNodeStyles tests might want to consider.

Maybe we should add a TestExtras.js that does something like this, because we are almost certainly going to forgot to do this in other tests!
Comment 15 Joseph Pecoraro 2019-02-15 14:01:32 PST
Comment on attachment 362101 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=362101&action=review

rs=me

>>> LayoutTests/inspector/css/modify-inline-style.html:85
>>> +                nodeStyles.addEventListener(WI.DOMNodeStyles.Event.NeedsRefresh, function(event) {
>>> +                    // Normally, this would get called from views if the styles sidebar is visible.
>>> +                    // This doesn't work in tests.
>>> +                    event.target.refresh();
>>> +                });
>> 
>> Joe and I investigated the problem. This fixed test timeouts on WK2. The rest of the patch is the same as the one that was rolled out.
> 
> Yeah, I really think this is something all of the DOMNodeStyles tests might want to consider.
> 
> Maybe we should add a TestExtras.js that does something like this, because we are almost certainly going to forgot to do this in other tests!

I think you should probably do something like this at the top level:

    WI.DOMNodeStyles.addEventListener(WI.DOMNodeStyles.Event.NeedsRefresh, (event) => {
        event.target.refresh();
    });

So that any DOMNodeStyles that needs a refresh will refresh. Let me know if that works.
Comment 16 Nikita Vasilyev 2019-02-15 14:10:42 PST
Created attachment 362157 [details]
Patch
Comment 17 Nikita Vasilyev 2019-02-15 14:11:16 PST
Yes, it worked.
Comment 18 WebKit Commit Bot 2019-02-15 15:44:20 PST
Comment on attachment 362157 [details]
Patch

Clearing flags on attachment: 362157

Committed r241623: <https://trac.webkit.org/changeset/241623>
Comment 19 WebKit Commit Bot 2019-02-15 15:44:22 PST
All reviewed patches have been landed.  Closing bug.
Comment 20 Nikita Vasilyev 2019-02-15 17:42:18 PST
*** Bug 194662 has been marked as a duplicate of this bug. ***