aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/common/arrays.js
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-03-09 08:48:17 -0500
committerGitHub <noreply@github.com>2018-03-09 08:48:17 -0500
commit63ab4f73f18391f73bf6bacbbafeceddaaeac5bd (patch)
treea8ad7b9e7fbd108ddc7f7c846d7daad1020850c0 /tests/wpt/web-platform-tests/common/arrays.js
parent664efab4a33264c07d68013a0ac3585544556b72 (diff)
parentf3533538ea8a0c9491d26618cfbdb1527139d7de (diff)
downloadservo-63ab4f73f18391f73bf6bacbbafeceddaaeac5bd.tar.gz
servo-63ab4f73f18391f73bf6bacbbafeceddaaeac5bd.zip
Auto merge of #20253 - servo-wpt-sync:wpt_update_08-03-2018, r=jdm
Sync WPT with upstream (08-03-2018) Automated downstream sync of changes from upstream as of 08-03-2018. [no-wpt-sync] <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20253) <!-- Reviewable:end -->
Diffstat (limited to 'tests/wpt/web-platform-tests/common/arrays.js')
-rw-r--r--tests/wpt/web-platform-tests/common/arrays.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/wpt/web-platform-tests/common/arrays.js b/tests/wpt/web-platform-tests/common/arrays.js
new file mode 100644
index 00000000000..49431dd78ad
--- /dev/null
+++ b/tests/wpt/web-platform-tests/common/arrays.js
@@ -0,0 +1,16 @@
+// Returns true if the given arrays are equal. Optionally can pass an equality function.
+export function areArraysEqual(a, b, equalityFunction = (c, d) => { return c === d; }) {
+ try {
+ if (a.length !== b.length)
+ return false;
+
+ for (let i = 0; i < a.length; i++) {
+ if (!equalityFunction(a[i], b[i]))
+ return false;
+ }
+ } catch (ex) {
+ return false;
+ }
+
+ return true;
+}