From 7f44edba5c44fc723907d71ec191ae298834ad06 Mon Sep 17 00:00:00 2001 From: Mikhail Losev Date: Wed, 12 Jul 2023 20:53:27 +0800 Subject: [PATCH] add pageNavigationEvent for Safari (#2923) --- src/client/index.ts | 3 +++ test/client/fixtures/page-navigation-watch-test.js | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/client/index.ts b/src/client/index.ts index 412098f3a..bc8197c49 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -319,6 +319,9 @@ class Hammerhead { this.win.location.reload(); }); } + + if (browserUtils.isSafari || browserUtils.isIOS) + this.pageNavigationWatch.onNavigationTriggered(navigationUrl); } start (initSettings: HammerheadInitSettings, win: Window & typeof globalThis): void { diff --git a/test/client/fixtures/page-navigation-watch-test.js b/test/client/fixtures/page-navigation-watch-test.js index 7ae229ccf..4b0e9aa6d 100644 --- a/test/client/fixtures/page-navigation-watch-test.js +++ b/test/client/fixtures/page-navigation-watch-test.js @@ -516,3 +516,11 @@ test('the onNavigationTriggered function should not throw an error when receives }); }); +if (browserUtils.isSafari && browserUtils.isOS) { + test('Raise PAGE_NAVIGATION_TRIGGERED event for "hammerhead.navigateTo" function', function () { + return navigateIframe('window["%hammerhead%"].navigateTo("./index.html");') + .then(function (url) { + strictEqual(url, iframeLocation + 'index.html'); + }); + }); +}