Web Inspector: Styles Redesign: Editing selector should not hide the rule
[WebKit-https.git] / LayoutTests / inspector / unit-tests / object-utilities.html
1 <!doctype html>
2 <html>
3 <head>
4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script>
5 <script>
6
7 function test()
8 {
9     let suite = InspectorTest.createSyncSuite("ObjectUtilities");
10
11     suite.addTestCase({
12         name: "Object.shallowEqual",
13         test() {
14             InspectorTest.expectThat(Object.shallowEqual({}, {}), "shallowEqual of empty object literals should be true.");
15             InspectorTest.expectThat(Object.shallowEqual([], []), "shallowEqual of empty array literals should be true.");
16             InspectorTest.expectThat(!Object.shallowEqual([], {}), "shallowEqual of empty array and object literals should be false.");
17
18             let obj1 = {a: 1, b: 2};
19             InspectorTest.expectThat(Object.shallowEqual(obj1, obj1), "shallowEqual of an object with itself should be true.");
20
21             let obj2 = {a: 1, b: 2};
22             InspectorTest.expectThat(Object.shallowEqual(obj1, obj2), "shallowEqual of equal objects should be true.");
23             InspectorTest.expectThat(Object.shallowEqual(obj2, obj1), "shallowEqual of equal objects should be true.");
24
25             let obj3 = {a: 1, b: 2, c: 3};
26             InspectorTest.expectThat(!Object.shallowEqual(obj1, obj3), "shallowEqual of unequal objects should be false.");
27             InspectorTest.expectThat(!Object.shallowEqual(obj3, obj1), "shallowEqual of unequal objects should be false.");
28
29             InspectorTest.expectThat(Object.shallowEqual({x: []}, {x: []}), "shallowEqual of objects with similar arrays at the same key should be true.");
30             InspectorTest.expectThat(Object.shallowEqual({x: new Array}, {x: new Array}), "shallowEqual of objects with similar arrays at the same key should be true.");
31             InspectorTest.expectThat(Object.shallowEqual({x: [1]}, {x: [1]}), "shallowEqual of objects with similar arrays at the same key should be true.");
32
33             InspectorTest.expectThat(!Object.shallowEqual({x: [1]}, {x: []}), "shallowEqual of objects with dissimilar arrays at the same key should be false.");
34             InspectorTest.expectThat(!Object.shallowEqual({x: new Array(1)}, {x: new Array}), "shallowEqual of objects with dissimilar arrays at the same key should be false.");
35
36             InspectorTest.expectThat(!Object.shallowEqual({}, null), "shallowEqual of an object and null should be false.");
37             InspectorTest.expectThat(!Object.shallowEqual({}, 1.23), "shallowEqual of an object and non-object should be false.");
38
39             let str = "abc";
40             InspectorTest.expectThat(!Object.shallowEqual(str, str), "shallowEqual of a non-object with itself should be false.");
41             InspectorTest.expectThat(!Object.shallowEqual("abc", "abc"), "shallowEqual of non-objects should be false.");
42
43             class A {};
44             class B {};
45             class C extends A {};
46
47             InspectorTest.expectThat(Object.shallowEqual(new A, new A), "shallowEqual of objects with equal constructors should be true.");
48             InspectorTest.expectThat(!Object.shallowEqual(new A, new B), "shallowEqual of objects with different constructors should be false.");
49             InspectorTest.expectThat(!Object.shallowEqual(new A, new C), "shallowEqual of objects with different constructors should be false.");
50
51             return true;
52         }
53     });
54
55     suite.runTestCasesAndFinish();
56 }
57 </script>
58 </head>
59 <body onLoad="runTest()">
60 </body>
61 </html>