File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed
packages/rrweb/test/benchmark Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,17 @@ describe('benchmark: mutation observer', () => {
8989 return fs . readFileSync ( filePath , 'utf8' ) ;
9090 } ;
9191
92+ const addRecordingScript = async ( page : Page ) => {
93+ // const scriptUrl = `${getServerURL(server)}/rrweb-1.1.3.js`;
94+ const scriptUrl = `${ getServerURL ( server ) } /rrweb.umd.cjs` ;
95+ await page . evaluate ( ( url ) => {
96+ const scriptEl = document . createElement ( 'script' ) ;
97+ scriptEl . src = url ;
98+ document . head . append ( scriptEl ) ;
99+ } , scriptUrl ) ;
100+ await page . waitForFunction ( 'window.rrweb' ) ;
101+ } ;
102+
92103 for ( const suite of suites ) {
93104 it ( suite . title , async ( ) => {
94105 page = await browser . newPage ( ) ;
@@ -99,19 +110,12 @@ describe('benchmark: mutation observer', () => {
99110 const loadPage = async ( ) => {
100111 if ( 'html' in suite ) {
101112 await page . goto ( 'about:blank' ) ;
102- const code = fs
103- . readFileSync ( path . resolve ( __dirname , '../../dist/rrweb.umd.cjs' ) )
104- . toString ( ) ;
105- await page . setContent ( `<html>
106- <script>
107- ${ code . toString ( ) }
108- </script>
109- </html>` ) ;
110-
111113 await page . setContent ( getHtml . call ( this , suite . html ) ) ;
112114 } else {
113115 await page . goto ( suite . url ) ;
114116 }
117+
118+ await addRecordingScript ( page ) ;
115119 } ;
116120
117121 const getDuration = async ( ) : Promise < number > => {
You can’t perform that action at this time.
0 commit comments