Changeset 241011 in webkit


Ignore:
Timestamp:
Feb 5, 2019 10:54:43 PM (5 years ago)
Author:
Nikita Vasilyev
Message:

Web Inspector: Styles: PropertiesChanged shouldn't fire when old and new text are both empty
https://bugs.webkit.org/show_bug.cgi?id=194318

Reviewed by Devin Rousso.

Source/WebInspectorUI:

Previously, WI.CSSStyleDeclaration.Event.PropertiesChanged fired when
old text and new text were empty strings.

  • UserInterface/Models/CSSStyleDeclaration.js:

LayoutTests:

Fix the flaky test on Debug.

  • inspector/css/modify-css-property-race-expected.txt:
  • inspector/css/modify-css-property-race.html:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r241010 r241011  
     12019-02-05  Nikita Vasilyev  <nvasilyev@apple.com>
     2
     3        Web Inspector: Styles: PropertiesChanged shouldn't fire when old and new text are both empty
     4        https://bugs.webkit.org/show_bug.cgi?id=194318
     5
     6        Reviewed by Devin Rousso.
     7
     8        Fix the flaky test on Debug.
     9
     10        * inspector/css/modify-css-property-race-expected.txt:
     11        * inspector/css/modify-css-property-race.html:
     12
    1132019-02-05  Megan Gardner  <megan_gardner@apple.com>
    214
  • trunk/LayoutTests/inspector/css/modify-css-property-race-expected.txt

    r240989 r241011  
    44== Running test suite: ModifyCSSProperty
    55-- Running test case: ModifyCSSPropertyRace.ChangeInlineStyle
    6 PASS: Height should be greater than 42px.
    7 PASS: Height should be greater than 42px.
    8 PASS: Height should be 10px.
    9 PASS: CSSStyleDeclaration text should update.
    10 PASS: Height should be greater or equal 10px.
     6PASS: Height should have increased from 10px.
     7PASS: Height should have increased from 11px.
     8PASS: Height should be 100px or more.
     9PASS: Height should be 101px or more.
    1110
  • trunk/LayoutTests/inspector/css/modify-css-property-race.html

    r240989 r241011  
    88function expand() {
    99    let element = document.getElementById("x");
    10     let initialHeight = parseInt(element.style.height);
    1110    let i = 0;
    1211
    1312    let loop = () => {
    1413        ++i;
    15         let height = initialHeight + i;
     14        let height = parseInt(element.style.height) + 1;
    1615        element.style.height = height + "px";
    1716        TestPage.dispatchEventToFrontend("TestPage-styleChanged", height + "px");
     
    6463            let updateCount = 0;
    6564
    66             function styleDecorationUpdated(event) {
    67                 if (!updateCount) {
    68                     let valueNumber = parseInt(getProperty("height").rawValue);
    69                     InspectorTest.expectGreaterThan(valueNumber, 42, "Height should be greater than 42px.");
    70                 } else if (updateCount === 1) {
    71                     let valueNumber = parseInt(getProperty("height").rawValue);
    72                     InspectorTest.expectGreaterThan(valueNumber, 42, "Height should be greater than 42px.");
    73                     getProperty("height").rawValue = "10px";
    74                 } else if (updateCount === 2) {
    75                     InspectorTest.expectEqual(getProperty("height").rawValue, "10px", "Height should be 10px.");
    76                     InspectorTest.expectEqual(getInlineStyleDeclaration().text, "height: 10px;", "CSSStyleDeclaration text should update.");
    77                 } else {
    78                     let valueNumber = parseInt(getProperty("height").rawValue);
    79                     InspectorTest.expectGreaterThanOrEqual(valueNumber, 10, "Height should be greater or equal 10px.");
     65            function styleDecorationUpdated() {
     66                ++updateCount;
     67                let heightNumber = parseInt(getProperty("height").rawValue);
     68
     69                if (updateCount === 1)
     70                    InspectorTest.expectGreaterThan(heightNumber, 10, "Height should have increased from 10px.");
     71                else if (updateCount === 2) {
     72                    InspectorTest.expectGreaterThan(heightNumber, 11, "Height should have increased from 11px.");
     73                    getProperty("height").rawValue = "100px";
     74                } else if (updateCount === 3)
     75                    InspectorTest.expectGreaterThanOrEqual(heightNumber, 100, "Height should be 100px or more.");
     76                else {
     77                    InspectorTest.expectGreaterThanOrEqual(heightNumber, 101, "Height should be 101px or more.");
    8078
    8179                    InspectorTest.evaluateInPage("stopExpanding()");
     
    8381                    resolve();
    8482                }
    85                 ++updateCount;
    8683            }
    8784
    88             WI.CSSStyleDeclaration.addEventListener(WI.CSSStyleDeclaration.Event.PropertiesChanged, styleDecorationUpdated);
     85            let style = getInlineStyleDeclaration();
     86            style.addEventListener(WI.CSSStyleDeclaration.Event.PropertiesChanged, styleDecorationUpdated);
    8987        }
    9088    });
     
    113111<body onload="runTest()">
    114112    <p>Testing that changes to "style" attribute made from page's JavaScript are ignored when there's a pending change made via Web Inspector.</p>
    115     <div id="x" style="height: 42px"></div>
     113    <div id="x" style="height: 10px"></div>
    116114</body>
    117115</html>
  • trunk/LayoutTests/inspector/css/modify-css-property.html

    r240946 r241011  
    118118            let styleDeclaration = getInlineStyleDeclaration();
    119119
    120             styleDeclaration.awaitEvent(WI.CSSStyleDeclaration.Event.PropertiesChanged).then((event) => {
     120            WI.CSSStyleDeclaration.awaitEvent(WI.CSSStyleDeclaration.Event.PropertiesChanged).then((event) => {
    121121                InspectorTest.expectThat(!styleDeclaration.locked, `Style declaration is unlocked.`);
    122122                InspectorTest.expectEqual(getProperty("width").rawValue, "200px", `"width" property value should update to "200px".`);
  • trunk/Source/WebInspectorUI/ChangeLog

    r241004 r241011  
     12019-02-05  Nikita Vasilyev  <nvasilyev@apple.com>
     2
     3        Web Inspector: Styles: PropertiesChanged shouldn't fire when old and new text are both empty
     4        https://bugs.webkit.org/show_bug.cgi?id=194318
     5
     6        Reviewed by Devin Rousso.
     7
     8        Previously, WI.CSSStyleDeclaration.Event.PropertiesChanged fired when
     9        old text and new text were empty strings.
     10
     11        * UserInterface/Models/CSSStyleDeclaration.js:
     12
    1132019-02-05  Devin Rousso  <drousso@apple.com>
    214
  • trunk/Source/WebInspectorUI/UserInterface/Models/CSSStyleDeclaration.js

    r240946 r241011  
    174174            return;
    175175
    176         // Don't fire the event if there is text and it hasn't changed.
    177         if (oldText && this._text && oldText === this._text)
     176        // Don't fire the event if text hasn't changed. However, it should still fire for Computed style declarations
     177        // because it never has text.
     178        if (oldText === this._text && this._type !== WI.CSSStyleDeclaration.Type.Computed)
    178179            return;
    179180
Note: See TracChangeset for help on using the changeset viewer.