summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fledge/tentative/resources/worklet-helpers.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/fledge/tentative/resources/worklet-helpers.js')
-rw-r--r--testing/web-platform/tests/fledge/tentative/resources/worklet-helpers.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/testing/web-platform/tests/fledge/tentative/resources/worklet-helpers.js b/testing/web-platform/tests/fledge/tentative/resources/worklet-helpers.js
new file mode 100644
index 0000000000..2147a026ae
--- /dev/null
+++ b/testing/web-platform/tests/fledge/tentative/resources/worklet-helpers.js
@@ -0,0 +1,23 @@
+// This file contains helper methods that are appended to the start of bidder
+// and seller worklets.
+
+// Comparison function that checks if two arguments are the same.
+// Not intended for use on anything other than built-in types
+// (Arrays, objects, and primitive types).
+function deepEquals(a, b) {
+ if (typeof a !== typeof b)
+ return false;
+ if (typeof a !== 'object' || a === null || b === null)
+ return a === b;
+
+ let aKeys = Object.keys(a);
+ if (aKeys.length != Object.keys(b).length)
+ return false;
+ for (let key of aKeys) {
+ if (a.hasOwnProperty(key) != b.hasOwnProperty(key) ||
+ !deepEquals(a[key], b[key])) {
+ return false;
+ }
+ }
+ return true;
+}