From 625c7ebdda2ef0473ee8d593dd30a1d34d3ee54a Mon Sep 17 00:00:00 2001 From: Yaniv Efraim Date: Wed, 14 Mar 2018 22:07:48 +0200 Subject: [PATCH] feat(FrameManager): add type=module to addScriptTag (#2090) This patch adds a new "type" option to the `addScriptTag` method that allows adding "module" tags to the page. Fixes #2078 --- docs/api.md | 2 ++ lib/FrameManager.js | 16 ++++++++++------ test/assets/es6/.eslintrc | 5 +++++ test/assets/es6/es6import.js | 2 ++ test/assets/es6/es6module.js | 1 + test/assets/es6/es6pathimport.js | 2 ++ test/test.js | 20 ++++++++++++++++++++ 7 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 test/assets/es6/.eslintrc create mode 100644 test/assets/es6/es6import.js create mode 100644 test/assets/es6/es6module.js create mode 100644 test/assets/es6/es6pathimport.js diff --git a/docs/api.md b/docs/api.md index 1df45c5a7d2..08fe7062307 100644 --- a/docs/api.md +++ b/docs/api.md @@ -668,6 +668,7 @@ Shortcut for [page.mainFrame().$x(expression)](#frameexpression) - `url` <[string]> URL of a script to be added. - `path` <[string]> Path to the JavaScript file to be injected into frame. If `path` is a relative path, then it is resolved relative to [current working directory](https://nodejs.org/api/process.html#process_process_cwd). - `content` <[string]> Raw JavaScript content to be injected into frame. + - `type` <[string]> Script type. Use 'module' in order to load a Javascript ES6 module. See [script](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) for more details. - returns: <[Promise]<[ElementHandle]>> which resolves to the added tag when the script's onload fires or when the script content was injected into frame. Adds a `