From 461e9118f65d6b7d1a78026637e5c9825db5a5e3 Mon Sep 17 00:00:00 2001 From: Zach Ploskey Date: Sat, 13 Oct 2018 20:28:31 -0700 Subject: [PATCH 1/3] Support goto and waitForNavigation on frames Simple enough. Just move them to FrameBase. Upstream commit: https://github.com/GoogleChrome/puppeteer/commit/5acf953104a09d7d688d76eadced6a4eba75d5d1 --- src/FrameBase.re | 15 +++++++++++++++ src/Page.re | 15 --------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/FrameBase.re b/src/FrameBase.re index 27b2fc0..4402fd7 100644 --- a/src/FrameBase.re +++ b/src/FrameBase.re @@ -24,6 +24,12 @@ external makeTagOptions: tagOptions = ""; +[@bs.send] +external goto: + (t, string, ~options: Navigation.options=?, unit) => + Js.Promise.t(Js.null(Response.t)) = + ""; + [@bs.send] external selectOne: (t, ~selector: string) => Js.Promise.t(Js.Null.t(ElementHandle.t('a))) = @@ -54,6 +60,15 @@ external makeSelectorOptions: /* TODO: waitForFunction */ +[@bs.send] +external waitForNavigation: + (t, ~options: Navigation.options) => Js.Promise.t(Js.nullable(Response.t)) = + ""; + +let waitForNavigation = (page, ~options) => + waitForNavigation(page, ~options) + |> Js.Promise.(then_(response => response |> Js.toOption |> resolve)); + [@bs.send] external waitForSelector: (t, string, ~options: selectorOptions=?, unit) => Js.Promise.t(unit) = diff --git a/src/Page.re b/src/Page.re index ce9ec5d..53ca1c4 100644 --- a/src/Page.re +++ b/src/Page.re @@ -180,12 +180,6 @@ external goForward: Js.Promise.t(Js.null(Response.t)) = ""; -[@bs.send] -external goto: - (t, string, ~options: Navigation.options=?, unit) => - Js.Promise.t(Js.null(Response.t)) = - ""; - [@bs.send] external isClosed: t => bool = ""; /** The page's virtual keyboard. */ @@ -343,15 +337,6 @@ external setViewport: (t, ~viewport: viewport) => Js.Promise.t(unit) = ""; [@bs.get] external tracing: t => Tracing.t = ""; -[@bs.send] -external waitForNavigation: - (t, ~options: Navigation.options) => Js.Promise.t(Js.nullable(Response.t)) = - ""; - -let waitForNavigation = (page, ~options) => - waitForNavigation(page, ~options) - |> Js.Promise.(then_(response => response |> Js.toOption |> resolve)); - module WaitForRequest = { [@bs.deriving abstract] type options = { From 5191636e1bbc8e03310b28fa76516f5d1b176534 Mon Sep 17 00:00:00 2001 From: Zach Ploskey Date: Sat, 13 Oct 2018 20:43:51 -0700 Subject: [PATCH 2/3] Add Browser.target() See: https://github.com/GoogleChrome/puppeteer/commit/4e48dfc7a195331ab1ff987d98290a6ab060a353 --- src/Browser.re | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Browser.re b/src/Browser.re index 77faee6..3954abc 100644 --- a/src/Browser.re +++ b/src/Browser.re @@ -22,6 +22,8 @@ external createIncognitoBrowserContext: t => Js.Promise.t(BrowserContext.t) = [@bs.send] [@bs.return nullable] external process: t => option(Node.Process.t) = ""; +[@bs.send] external target: t => Target.t = ""; + [@bs.send] external targets: t => array(Target.t) = ""; [@bs.send] external userAgent: t => Js.Promise.t(string) = ""; From 12ad378ec49b90b61bb7bde511e04ca286d25e31 Mon Sep 17 00:00:00 2001 From: Zach Ploskey Date: Sat, 13 Oct 2018 20:50:42 -0700 Subject: [PATCH 3/3] Add Response.frame() See: https://github.com/GoogleChrome/puppeteer/commit/5acf953104a09d7d688d76eadced6a4eba75d5d1 --- src/Response.re | 7 +++++++ src/Types.re | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/Response.re b/src/Response.re index a632a4e..fc9eb4e 100644 --- a/src/Response.re +++ b/src/Response.re @@ -4,6 +4,13 @@ type t = Types.response; [@bs.send] external buffer: t => Js.Promise.t(Node.Buffer.t) = ""; +/** + * The frame that initiated the response. Will be null if navigating to + * error pages. + */ +[@bs.send] +external frame: t => Js.Null.t(Types.frame) = ""; + /** If the response was served from the disk cache or memory cache. */ [@bs.send] external fromCache: t => bool = ""; diff --git a/src/Types.re b/src/Types.re index 93d33cc..54b5a92 100644 --- a/src/Types.re +++ b/src/Types.re @@ -10,6 +10,8 @@ type request; type response; +type frame; + type frameBase; type target;