Procházet zdrojové kódy

Reorganize Firefox Profile tests slightly

Daniel Gempesaw před 11 roky
rodič
revize
59203cd914
1 změnil soubory, kde provedl 24 přidání a 26 odebrání
  1. 24 26
      t/Firefox-Profile.t

+ 24 - 26
t/Firefox-Profile.t

@@ -69,9 +69,11 @@ CUSTOM_EXTENSION_LOADED: {
 
     ok(defined $driver, "made a driver without dying");
 
-    # the initial automatic homepage load found in the preference
-    # 'browser.startup.homepage' isn't blocking, so we need to wait
-    # until the page is loaded (when we can find elements)
+    # We don't have to `$driver->get` because our extension should do
+    # it for us. However, the initial automatic homepage load found in
+    # the preference 'browser.startup.homepage' isn't blocking, so we
+    # need to wait until the page is loaded (when we can find
+    # elements)
     $driver->set_implicit_wait_timeout(30000);
     $driver->find_element("h1", "tag_name");
     cmp_ok($driver->get_current_url, '=~', qr/localhost/i,
@@ -156,31 +158,27 @@ PREFERENCES: {
 
 CROAKING: {
     my $profile = Selenium::Remote::Driver::Firefox::Profile->new;
-    {
-        eval {
-            $profile->add_extension('t/00-load.t');
-        };
-        cmp_ok($@, '=~', qr/xpi format/i, "caught invalid extension filetype");
-    }
 
-    {
-        eval {
-            $profile->add_extension('t/www/invalid-extension.xpi');
-            my $test = $profile->_encode;
-        };
-        ok($@ =~ /install\.rdf/i, "caught invalid extension structure");
-    }
+    eval { $profile->add_extension('gibberish'); };
+    cmp_ok($@, '=~', qr/File not found/i, 'throws on missing file');
 
-    {
-        eval {
-            my %driver_args = %selenium_args;
-            $driver_args{firefox_profile} = 'clearly invalid';
-            my $croakingDriver = Selenium::Remote::Driver->new(
-                %driver_args
-            );
-        };
-        ok ($@ =~ /coercion.*failed/, "caught invalid extension in driver constructor");
-    }
+    eval { $profile->add_extension($FindBin::Bin . '/00-load.t'); };
+    cmp_ok($@, '=~', qr/xpi format/i, "caught invalid extension filetype");
+
+    eval {
+        $profile->add_extension($fixture_dir . 'invalid-extension.xpi') ;
+        $profile->_encode;
+    };
+    ok($@ =~ /install\.rdf/i, "caught invalid extension structure");
+
+    eval {
+        my %driver_args = %selenium_args;
+        $driver_args{firefox_profile} = 'clearly invalid';
+        my $croakingDriver = Selenium::Remote::Driver->new(
+            %driver_args
+        );
+    };
+    ok ($@ =~ /coercion.*failed/, "caught invalid extension in driver constructor");
 }
 
 done_testing;