Skip to content

Commit 3480349

Browse files
committed
Minor correction to how scripts evaluated on each new document are handled.
Fixed type in Frame.load_waiter that caused an exception Bump version
1 parent c610773 commit 3480349

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
setup(
1919
name="simplechrome",
20-
version="1.0.1",
20+
version="1.0.2",
2121
description=(
2222
"Headless chrome/chromium automation library"
2323
"(unofficial fork of pypuppeteer)"

simplechrome/frame_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ def remove_cb(x: Any) -> None:
859859
myself.remove_listener(Frame.Events.LifeCycleEvent, on_load)
860860

861861
fut.add_done_callback(remove_cb)
862-
self.on(Frame.Events.LifecycleEvent, on_load)
862+
self.on(Frame.Events.LifeCycleEvent, on_load)
863863
if timeout is not None:
864864
return asyncio.wait_for(fut, timeout=timeout, loop=loop)
865865
return fut

simplechrome/page.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ async def evaluate(
859859
raise PageError("No main frame.")
860860
return await frame.evaluate(pageFunction, *args, force_expr=force_expr)
861861

862-
async def evaluateOnNewDocument(self, pageFunction: str, *args: str) -> None:
862+
async def evaluateOnNewDocument(self, pageFunction: str, *args: str, raw=False) -> None:
863863
"""Add a JavaScript function to the document.
864864
865865
This function would be invoked in one of the following scenarios:
@@ -868,7 +868,10 @@ async def evaluateOnNewDocument(self, pageFunction: str, *args: str) -> None:
868868
* whenever the child frame is attached or navigated. Inthis case, the
869869
function is invoked in the context of the newly attached frame.
870870
"""
871-
source = helper.evaluationString(pageFunction, *args)
871+
if raw:
872+
source = pageFunction
873+
else:
874+
source = helper.evaluationString(pageFunction, *args)
872875
await self._client.send(
873876
"Page.addScriptToEvaluateOnNewDocument", {"source": source}
874877
)

0 commit comments

Comments
 (0)