From f7d1543aa321bf403768eac4b1032cff08d40225 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Mon, 18 Dec 2017 10:24:11 -0700 Subject: [PATCH] fixes for sorted window handler --- test/e2e/utils/SortedWindowHandler.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/test/e2e/utils/SortedWindowHandler.js b/test/e2e/utils/SortedWindowHandler.js index f57856814..cb8195978 100644 --- a/test/e2e/utils/SortedWindowHandler.js +++ b/test/e2e/utils/SortedWindowHandler.js @@ -25,8 +25,28 @@ class SortedWindowHandler { */ windowHandles(callback) { this.client.windowHandles((result) => { - this.handles = this.handles.filter((handle) => result.value.includes(handle)); - const remaining = result.value.filter((handle) => !this.handles.includes(handle)); + if (Array.isArray(result.value)) { + this.handles = this.handles.filter((handle) => { + for (let i = 0; i < result.value.length; i++) { + if (result.value[i] === handle) { + return true; + } + } + + return false; + }); + } else { + this.handles = []; + } + const remaining = result.value.filter((handle) => { + for (let i = 0; i < this.handles.length; i++) { + if (this.handles[i] === handle) { + return false; + } + } + + return true; + }); if (remaining.length === 1) { this.handles.push(remaining[0]); }