Эх сурвалжийг харах

Ban the _request method on pw objects to prevent deep recursion

George S. Baugh 4 жил өмнө
parent
commit
ed39032949

+ 1 - 0
MANIFEST.SKIP

@@ -16,3 +16,4 @@ api.json
 playwright_server
 generate_perl_modules.pl
 clean_generated_files.sh
+run_example

+ 2 - 0
README.md

@@ -62,6 +62,8 @@ then run `generate_api_json.sh` to get things working such that the build script
 
 Then run `generate_perl_modules.pl` to get the accessor classes built based off of the spec, and insert the spec JSON into the playwright_server binary.
 
+To make life simple, you can just run `run_example` in the TLD when debugging.
+
 ## Questions?
 Hop into the playwright slack, and check out the #playwright-perl channel therein.
 I'm watching that space and should be able to answer your questions.

+ 0 - 1
clean_generated_files.sh

@@ -1,7 +1,6 @@
 #!/bin/bash
 rm api.json; /bin/true
 rm bin/playwright_server; /bin/true
-rmdir bin; /bin/true
 for module in $(git ls-files -o --exclude-standard lib/Playwright)
 do
     rm $module; /bin/true

+ 2 - 0
example.pl

@@ -109,6 +109,8 @@ $page->select('#d-lo')->click();
 
 my $download = $handle->await( $promise );
 
+print "Download suggested filename\n";
+print $download->suggestedFilename()."\n";
 $download->saveAs('test2.jpg');
 
 # Fiddle with file inputs

+ 4 - 0
generate_perl_modules.pl

@@ -70,6 +70,9 @@ our %bogus_methods = (
     'evalOnSelectorAll' => '$$eval',
 );
 
+# Playwright methods we can't actually have work here
+our @banned = ('_request');
+
 my @modules;
 foreach my $class ( keys(%$spec), 'Mouse', 'Keyboard' ) {
     next if $class eq 'Playwright';
@@ -80,6 +83,7 @@ foreach my $class ( keys(%$spec), 'Mouse', 'Keyboard' ) {
 
     my $members = Playwright::Util::arr2hash($spec->{$class}{members},'name');
     foreach my $method ( ( keys( %$members ), 'on', 'evaluate', 'evaluateHandle' ) ) {
+        next if grep { $_ eq $method } @banned;
         my $renamed = $method;
         $method  = $bogus_methods{$method}     if exists $bogus_methods{$method};
         $renamed = $methods_to_rename{$method} if exists $methods_to_rename{$method};

+ 2 - 0
run_example

@@ -0,0 +1,2 @@
+#!/bin/sh
+./clean_generated_files.sh && ./generate_api_json.sh && ./generate_perl_modules.pl && PATH="$(pwd)/bin:$PATH" perl -Ilib example.pl; ./clean_generated_files.sh && perl -Ilib bin/reap_playwright_servers