GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Unverified Commit 4bb2be56 authored by boklm's avatar boklm
Browse files

Convert the https-everywhere tests to marionette

parent 4f432e56
......@@ -240,13 +240,14 @@ our @tests = (
},
{
name => 'https-everywhere',
type => 'mozmill',
type => 'marionette',
use_net => 1,
descr => 'Check that https everywhere is enabled and working',
},
{
name => 'https-everywhere-disabled',
type => 'mozmill',
marionette_test => 'https-everywhere',
type => 'marionette',
descr => 'Check that https everywhere is not doing anything when disabled',
use_net => 1,
pre => sub { toggle_https_everywhere($_[0], 0) },
......@@ -709,6 +710,7 @@ sub marionette_run {
my $result_file_txt = "$tbbinfos->{'results-dir'}/$test->{name}.txt";
#--log-unittest ./res.txt --log-html ./res.html
my $bin = $OSNAME eq 'cygwin' ? 'Scripts' : 'bin';
my $marionette_test = $test->{marionette_test} // $test->{name};
my $pypath = $ENV{PYTHONPATH};
$ENV{PYTHONPATH} //= '';
$ENV{PYTHONPATH} = winpath("$FindBin::Bin/marionette/tor_browser_tests/lib")
......@@ -718,7 +720,7 @@ sub marionette_run {
'--log-html', winpath($result_file_html),
'--binary', ffbin_path($tbbinfos, $test),
'--profile', winpath($tbbinfos->{ffprofiledir}),
winpath("$FindBin::Bin/marionette/tor_browser_tests/test_$test->{name}.py"));
winpath("$FindBin::Bin/marionette/tor_browser_tests/test_${marionette_test}.py"));
$ENV{PYTHONPATH} = $pypath;
my @txt_log = read_file($result_file_txt);
my $res_line = shift @txt_log;
......
from marionette_driver import By
from marionette_driver.errors import MarionetteException
from firefox_ui_harness import FirefoxTestCase
import testsuite
class Test(FirefoxTestCase):
def setUp(self):
FirefoxTestCase.setUp(self)
ts = testsuite.TestSuite()
self.ts = ts
self.PREF_ENABLE_HE = "extensions.https_everywhere.globalEnabled"
self.HTTP_URL = "http://www.freedomboxfoundation.org/thanks/"
self.HTTPS_URL = "https://www.freedomboxfoundation.org/thanks/"
def test_https_everywhere(self):
self.assertEqual(self.prefs.get_pref(self.PREF_ENABLE_HE), \
self.ts.t['test']['name'] == 'https-everywhere')
with self.marionette.using_context('content'):
self.marionette.navigate(self.HTTP_URL)
if self.ts.t['test']['name'] == 'https-everywhere':
self.assertEqual(self.marionette.get_url(), self.HTTPS_URL)
else:
self.assertEqual(self.marionette.get_url(), self.HTTP_URL)
// This test should be run with the https-everywhere extension disabled
"use strict";
var {expect} = require("../mozilla-mozmill-tests/lib/assertions");
var prefs = require("../mozilla-mozmill-tests/firefox/lib/prefs");
var common = require("../lib/common");
const PREF_ENABLE_HE = "extensions.https_everywhere.globalEnabled";
const HTTP_URL = "http://www.freedomboxfoundation.org/images/freedombox_large.png";
var setupModule = function(aModule) {
aModule.controller = mozmill.getBrowserController();
}
var testStartTBB = function() {
var prefSrv = prefs.preferences;
expect.equal(prefSrv.getPref(PREF_ENABLE_HE, true), false,
"https-everywhere is disabled");
common.load_page(controller, HTTP_URL);
expect.equal(controller.tabs.activeTab.URL, HTTP_URL,
"http URL has not been redirected to https");
}
"use strict";
var {expect} = require("../mozilla-mozmill-tests/lib/assertions");
var prefs = require("../mozilla-mozmill-tests/firefox/lib/prefs");
var common = require("../lib/common");
const PREF_ENABLE_HE = "extensions.https_everywhere.globalEnabled";
const HTTP_URL = "http://www.freedomboxfoundation.org/images/freedombox_large.png";
const HTTPS_URL = "https://www.freedomboxfoundation.org/images/freedombox_large.png";
var setupModule = function(aModule) {
aModule.controller = mozmill.getBrowserController();
}
var testStartTBB = function() {
var prefSrv = prefs.preferences;
expect.equal(prefSrv.getPref(PREF_ENABLE_HE, false), true,
"https-everywhere is enabled");
common.load_page(controller, HTTP_URL);
expect.equal(controller.tabs.activeTab.URL, HTTPS_URL,
"https-everywhere seems to work");
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment