Kaynağa Gözat

Add cache_status endpoint for html5 app cache status

For #113. Oddly, neither the latest FirefoxDriver nor ChromeDrivers seem
to support this endpoint on 2.44.0. Nevertheless, it's in, although I
don't know what even implements it.
Daniel Gempesaw 11 yıl önce
ebeveyn
işleme
09820da643

+ 6 - 1
lib/Selenium/Remote/Commands.pm

@@ -358,7 +358,12 @@ has '_cmds' => (
                 'method'             => 'DELETE',
                 'url'                => '/session/:sessionId/local_storage/key/:key',
                 'no_content_success' => 1
-            }
+            },
+            'cacheStatus' => {
+                'method'             => 'GET',
+                'url'                => 'session/:sessionId/application_cache/status',
+                'no_content_success' => 0
+            },
 
             # /session/:sessionId/local_storage
             # /session/:sessionId/local_storage/key/:key

+ 18 - 0
lib/Selenium/Remote/Driver.pm

@@ -2031,6 +2031,24 @@ sub get_active_element {
     }
 }
 
+=head2 cache_status
+
+ Description:
+    Get the status of the html5 application cache.
+
+ Usage:
+    print $driver->cache_status;
+
+ Output:
+    <number> - Status code for application cache: {UNCACHED = 0, IDLE = 1, CHECKING = 2, DOWNLOADING = 3, UPDATE_READY = 4, OBSOLETE = 5}
+
+=cut
+
+sub cache_status {
+    my ($self) = @_;
+    my $res = { 'command' => 'cacheStatus' };
+    return $self->_execute_command($res);
+}
 =head2 send_modifier
 
  Description:

+ 9 - 0
t/01-driver.t

@@ -450,6 +450,15 @@ STORAGE: {
     }
 }
 
+HTML5: {
+  SKIP: {
+        skip 'HTML5 Application Cache is not supported by firefox or chrome', 1 if 1;
+        $driver->get($website);
+        my $status = $driver->cache_status;
+        ok($status, 'we can get application cache status');
+    }
+}
+
 QUIT: {
     $ret = $driver->quit();
     ok((not defined $driver->{'session_id'}), 'Killed the remote session');

+ 0 - 1
t/03-spec-coverage.t

@@ -50,7 +50,6 @@ my $todo_list = {
    'GET session/:sessionId/session_storage/size'           => 1,
    'POST session/:sessionId/log'                           => 1,
    'GET session/:sessionId/log/types'                      => 1,
-   'GET session/:sessionId/application_cache/status'       => 1,
 };
 my @lines = split(/\n/, $data);
 my @methods;