Title: [209366] trunk
Revision
209366
Author
[email protected]
Date
2016-12-05 16:21:19 -0800 (Mon, 05 Dec 2016)

Log Message

Web Inspector: Object.shallowEqual([{}], [{}]) should return true
https://bugs.webkit.org/show_bug.cgi?id=165397

Reviewed by Brian Burg.

Source/WebInspectorUI:

* UserInterface/Base/Utilities.js:
(value):
Array.shallowEqual should compare array items using strict equivalence,
and on failure defer to Object.shallowEqual.

LayoutTests:

Added passing and failing inputs for TestHarness.prototype.expectShallowEqual.

* inspector/unit-tests/test-harness-expect-functions-expected.txt:
* inspector/unit-tests/test-harness-expect-functions.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (209365 => 209366)


--- trunk/LayoutTests/ChangeLog	2016-12-06 00:10:58 UTC (rev 209365)
+++ trunk/LayoutTests/ChangeLog	2016-12-06 00:21:19 UTC (rev 209366)
@@ -1,3 +1,15 @@
+2016-12-05  Matt Baker  <[email protected]>
+
+        Web Inspector: Object.shallowEqual([{}], [{}]) should return true
+        https://bugs.webkit.org/show_bug.cgi?id=165397
+
+        Reviewed by Brian Burg.
+
+        Added passing and failing inputs for TestHarness.prototype.expectShallowEqual.
+
+        * inspector/unit-tests/test-harness-expect-functions-expected.txt:
+        * inspector/unit-tests/test-harness-expect-functions.html:
+
 2016-12-05  Dean Jackson  <[email protected]>
 
         pointer lock needs to be feature detectable

Modified: trunk/LayoutTests/inspector/unit-tests/test-harness-expect-functions-expected.txt (209365 => 209366)


--- trunk/LayoutTests/inspector/unit-tests/test-harness-expect-functions-expected.txt	2016-12-06 00:10:58 UTC (rev 209365)
+++ trunk/LayoutTests/inspector/unit-tests/test-harness-expect-functions-expected.txt	2016-12-06 00:21:19 UTC (rev 209366)
@@ -170,6 +170,9 @@
 Expected to PASS
 PASS: expectShallowEqual({"a":1,"b":2}, {"a":1,"b":2})
 PASS: expectShallowEqual({}, {})
+PASS: expectShallowEqual([1,2], [1,2])
+PASS: expectShallowEqual([{"a":1},{"a":2}], [{"a":1},{"a":2}])
+PASS: expectShallowEqual([{}], [{}])
 PASS: expectShallowEqual([], [])
 Expected to FAIL
 FAIL: expectShallowEqual({"a":1,"b":2}, {"a":3,"b":4})
@@ -178,11 +181,23 @@
 FAIL: expectShallowEqual({}, [])
     Expected: []
     Actual: {}
+FAIL: expectShallowEqual([1,2], [3,4])
+    Expected: [3,4]
+    Actual: [1,2]
+FAIL: expectShallowEqual([{"a":1},{"a":2}], [{"a":3},{"a":4}])
+    Expected: [{"a":3},{"a":4}]
+    Actual: [{"a":1},{"a":2}]
+FAIL: expectShallowEqual([{"a":1},{"a":2}], [{"b":1},{"b":2}])
+    Expected: [{"b":1},{"b":2}]
+    Actual: [{"a":1},{"a":2}]
 
 -- Running test case: InspectorTest.expectNotShallowEqual
 Expected to PASS
 PASS: expectNotShallowEqual({"a":1,"b":2}, {"a":3,"b":4})
 PASS: expectNotShallowEqual({}, [])
+PASS: expectNotShallowEqual([1,2], [3,4])
+PASS: expectNotShallowEqual([{"a":1},{"a":2}], [{"a":3},{"a":4}])
+PASS: expectNotShallowEqual([{"a":1},{"a":2}], [{"b":1},{"b":2}])
 Expected to FAIL
 FAIL: expectNotShallowEqual({"a":1,"b":2}, {"a":1,"b":2})
     Expected: not {"a":1,"b":2}
@@ -190,6 +205,15 @@
 FAIL: expectNotShallowEqual({}, {})
     Expected: not {}
     Actual: {}
+FAIL: expectNotShallowEqual([1,2], [1,2])
+    Expected: not [1,2]
+    Actual: [1,2]
+FAIL: expectNotShallowEqual([{"a":1},{"a":2}], [{"a":1},{"a":2}])
+    Expected: not [{"a":1},{"a":2}]
+    Actual: [{"a":1},{"a":2}]
+FAIL: expectNotShallowEqual([{}], [{}])
+    Expected: not [{}]
+    Actual: [{}]
 FAIL: expectNotShallowEqual([], [])
     Expected: not []
     Actual: []

Modified: trunk/LayoutTests/inspector/unit-tests/test-harness-expect-functions.html (209365 => 209366)


--- trunk/LayoutTests/inspector/unit-tests/test-harness-expect-functions.html	2016-12-06 00:10:58 UTC (rev 209365)
+++ trunk/LayoutTests/inspector/unit-tests/test-harness-expect-functions.html	2016-12-06 00:21:19 UTC (rev 209366)
@@ -91,11 +91,17 @@
         passingInputs: [
             [{a: 1, b: 2}, {a: 1, b: 2}],
             [{}, {}],
+            [[1, 2], [1, 2]],
+            [[{a: 1}, {a: 2}], [{a: 1}, {a: 2}]],
+            [[{}], [{}]],
             [[], []],
         ],
         failingInputs: [
             [{a: 1, b: 2}, {a: 3, b: 4}],
             [{}, []],
+            [[1, 2], [3, 4]],
+            [[{a: 1}, {a: 2}], [{a: 3}, {a: 4}]],
+            [[{a: 1}, {a: 2}], [{b: 1}, {b: 2}]],
         ]
     };
     addTestCase(expectShallowEqualTestCase);

Modified: trunk/Source/WebInspectorUI/ChangeLog (209365 => 209366)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-12-06 00:10:58 UTC (rev 209365)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-12-06 00:21:19 UTC (rev 209366)
@@ -1,3 +1,15 @@
+2016-12-05  Matt Baker  <[email protected]>
+
+        Web Inspector: Object.shallowEqual([{}], [{}]) should return true
+        https://bugs.webkit.org/show_bug.cgi?id=165397
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Base/Utilities.js:
+        (value):
+        Array.shallowEqual should compare array items using strict equivalence,
+        and on failure defer to Object.shallowEqual.
+
 2016-12-05  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Remove legacy styles

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js (209365 => 209366)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2016-12-06 00:10:58 UTC (rev 209365)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2016-12-06 00:21:19 UTC (rev 209366)
@@ -447,8 +447,11 @@
         if (length !== b.length)
             return false;
 
-        for (var i = 0; i < length; ++i) {
-            if (a[i] !== b[i])
+        for (let i = 0; i < length; ++i) {
+            if (a[i] === b[i])
+                continue;
+
+            if (!Object.shallowEqual(a[i], b[i]))
                 return false;
         }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to