Title: [228364] branches/safari-605-branch

Diff

Modified: branches/safari-605-branch/LayoutTests/ChangeLog (228363 => 228364)


--- branches/safari-605-branch/LayoutTests/ChangeLog	2018-02-10 06:25:46 UTC (rev 228363)
+++ branches/safari-605-branch/LayoutTests/ChangeLog	2018-02-10 06:25:50 UTC (rev 228364)
@@ -1,5 +1,20 @@
 2018-02-09  Jason Marcell  <jmarc...@apple.com>
 
+        Cherry-pick r228336. rdar://problem/37408902
+
+    2018-02-09  Matt Baker  <mattba...@apple.com>
+
+            Web Inspector: Object.shallowEqual always fails when comparing array property values
+            https://bugs.webkit.org/show_bug.cgi?id=182634
+            <rdar://problem/37374639>
+
+            Reviewed by Devin Rousso.
+
+            * inspector/unit-tests/object-utilities-expected.txt:
+            * inspector/unit-tests/object-utilities.html:
+
+2018-02-09  Jason Marcell  <jmarc...@apple.com>
+
         Cherry-pick r228241. rdar://problem/37408896
 
     2018-02-07  Youenn Fablet  <you...@apple.com>

Modified: branches/safari-605-branch/LayoutTests/inspector/unit-tests/object-utilities-expected.txt (228363 => 228364)


--- branches/safari-605-branch/LayoutTests/inspector/unit-tests/object-utilities-expected.txt	2018-02-10 06:25:46 UTC (rev 228363)
+++ branches/safari-605-branch/LayoutTests/inspector/unit-tests/object-utilities-expected.txt	2018-02-10 06:25:50 UTC (rev 228364)
@@ -9,6 +9,11 @@
 PASS: shallowEqual of equal objects should be true.
 PASS: shallowEqual of unequal objects should be false.
 PASS: shallowEqual of unequal objects should be false.
+PASS: shallowEqual of objects with similar arrays at the same key should be true.
+PASS: shallowEqual of objects with similar arrays at the same key should be true.
+PASS: shallowEqual of objects with similar arrays at the same key should be true.
+PASS: shallowEqual of objects with dissimilar arrays at the same key should be false.
+PASS: shallowEqual of objects with dissimilar arrays at the same key should be false.
 PASS: shallowEqual of an object and null should be false.
 PASS: shallowEqual of an object and non-object should be false.
 PASS: shallowEqual of a non-object with itself should be false.

Modified: branches/safari-605-branch/LayoutTests/inspector/unit-tests/object-utilities.html (228363 => 228364)


--- branches/safari-605-branch/LayoutTests/inspector/unit-tests/object-utilities.html	2018-02-10 06:25:46 UTC (rev 228363)
+++ branches/safari-605-branch/LayoutTests/inspector/unit-tests/object-utilities.html	2018-02-10 06:25:50 UTC (rev 228364)
@@ -26,6 +26,13 @@
             InspectorTest.expectThat(!Object.shallowEqual(obj1, obj3), "shallowEqual of unequal objects should be false.");
             InspectorTest.expectThat(!Object.shallowEqual(obj3, obj1), "shallowEqual of unequal objects should be false.");
 
+            InspectorTest.expectThat(Object.shallowEqual({x: []}, {x: []}), "shallowEqual of objects with similar arrays at the same key should be true.");
+            InspectorTest.expectThat(Object.shallowEqual({x: new Array}, {x: new Array}), "shallowEqual of objects with similar arrays at the same key should be true.");
+            InspectorTest.expectThat(Object.shallowEqual({x: [1]}, {x: [1]}), "shallowEqual of objects with similar arrays at the same key should be true.");
+
+            InspectorTest.expectThat(!Object.shallowEqual({x: [1]}, {x: []}), "shallowEqual of objects with dissimilar arrays at the same key should be false.");
+            InspectorTest.expectThat(!Object.shallowEqual({x: new Array(1)}, {x: new Array}), "shallowEqual of objects with dissimilar arrays at the same key should be false.");
+
             InspectorTest.expectThat(!Object.shallowEqual({}, null), "shallowEqual of an object and null should be false.");
             InspectorTest.expectThat(!Object.shallowEqual({}, 1.23), "shallowEqual of an object and non-object should be false.");
 

Modified: branches/safari-605-branch/Source/WebInspectorUI/ChangeLog (228363 => 228364)


--- branches/safari-605-branch/Source/WebInspectorUI/ChangeLog	2018-02-10 06:25:46 UTC (rev 228363)
+++ branches/safari-605-branch/Source/WebInspectorUI/ChangeLog	2018-02-10 06:25:50 UTC (rev 228364)
@@ -1,5 +1,24 @@
 2018-02-09  Jason Marcell  <jmarc...@apple.com>
 
+        Cherry-pick r228336. rdar://problem/37408902
+
+    2018-02-09  Matt Baker  <mattba...@apple.com>
+
+            Web Inspector: Object.shallowEqual always fails when comparing array property values
+            https://bugs.webkit.org/show_bug.cgi?id=182634
+            <rdar://problem/37374639>
+
+            Reviewed by Devin Rousso.
+
+            Object.shallowEqual should use Array.shallowEqual when comparing property
+            values, since strictly comparing objects/arrays is only true if both
+            operands reference the same Object.
+
+            * UserInterface/Base/Utilities.js:
+            (value):
+
+2018-02-09  Jason Marcell  <jmarc...@apple.com>
+
         Cherry-pick r228301. rdar://problem/37408879
 
     2018-02-08  Matt Baker  <mattba...@apple.com>

Modified: branches/safari-605-branch/Source/WebInspectorUI/UserInterface/Base/Utilities.js (228363 => 228364)


--- branches/safari-605-branch/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2018-02-10 06:25:46 UTC (rev 228363)
+++ branches/safari-605-branch/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2018-02-10 06:25:50 UTC (rev 228364)
@@ -49,37 +49,30 @@
     {
         // Checks if two objects have the same top-level properties.
 
-        // Only objects can proceed.
         if (!(a instanceof Object) || !(b instanceof Object))
             return false;
 
-        // Check for strict equality in case they are the same object.
         if (a === b)
             return true;
 
-        // Use an optimized version of shallowEqual for arrays.
-        if (Array.isArray(a) && Array.isArray(b))
-            return Array.shallowEqual(a, b);
+        if (Array.shallowEqual(a, b))
+            return true;
 
         if (a.constructor !== b.constructor)
             return false;
 
-        var aKeys = Object.keys(a);
-        var bKeys = Object.keys(b);
-
-        // Check that each object has the same number of keys.
+        let aKeys = Object.keys(a);
+        let bKeys = Object.keys(b);
         if (aKeys.length !== bKeys.length)
             return false;
 
-        // Check if all the keys and their values are equal.
-        for (var i = 0; i < aKeys.length; ++i) {
-            // Check that b has the same key as a.
-            if (!(aKeys[i] in b))
+        for (let aKey of aKeys) {
+            if (!(aKey in b))
                 return false;
 
-            // Check that the values are strict equal since this is only
-            // a shallow check, not a recursive one.
-            if (a[aKeys[i]] !== b[aKeys[i]])
+            let aValue = a[aKey];
+            let bValue = b[aKey];
+            if (aValue !== bValue && !Array.shallowEqual(aValue, bValue))
                 return false;
         }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to