Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "addon-sdk"]
path = addon-sdk
url = https://github.com/mozilla/addon-sdk.git
[submodule "translations"]
path = translations
url = https://git.torproject.org/translation.git
Expand Down
1 change: 0 additions & 1 deletion addon-sdk
Submodule addon-sdk deleted from 12f7d5
19 changes: 17 additions & 2 deletions install-dev-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ if type apt-get >/dev/null ; then
# In Debian, `python-` is assumed to be python 2.7, no need to specify - dkg
$SUDO_SHIM apt-get install libxml2-dev libxml2-utils libxslt1-dev \
python-dev $BROWSERS zip sqlite3 python-pip libcurl4-openssl-dev xvfb \
libssl-dev git $CHROMEDRIVER
libssl-dev git curl $CHROMEDRIVER
if ! type geckodriver >/dev/null; then
curl -LO "https://github.com/mozilla/geckodriver/releases/download/v0.16.1/geckodriver-v0.16.1-linux64.tar.gz"
tar -zxvf "geckodriver-v0.16.1-linux64.tar.gz"
rm -f "geckodriver-v0.16.1-linux64.tar.gz"
$SUDO_SHIM mv geckodriver /usr/bin/geckodriver
$SUDO_SHIM chown root /usr/bin/geckodriver
$SUDO_SHIM chmod 755 /usr/bin/geckodriver
fi
elif type brew >/dev/null ; then
brew list python &>/dev/null || brew install python
brew install libxml2 gnu-sed chromedriver
Expand All @@ -42,9 +50,16 @@ elif type dnf >/dev/null ; then
rm -f "chromedriver_linux$ARCH.zip"
$SUDO_SHIM mv chromedriver /usr/bin/chromedriver
$SUDO_SHIM chown root /usr/bin/chromedriver
$SUDO_SHIM chmod +x /usr/bin/chromedriver
$SUDO_SHIM chmod 755 /usr/bin/chromedriver
fi
if ! type geckodriver >/dev/null; then
curl -LO "https://github.com/mozilla/geckodriver/releases/download/v0.16.1/geckodriver-v0.16.1-macos.tar.gz"
tar -zxvf "geckodriver-v0.16.1-macos.tar.gz"
rm -f "geckodriver-v0.16.1-macos.tar.gz"
$SUDO_SHIM mv geckodriver /usr/bin/geckodriver
$SUDO_SHIM chown root /usr/bin/geckodriver
$SUDO_SHIM chmod 755 /usr/bin/geckodriver
fi
# This is needed for Firefox on some systems. See here for more information:
# https://github.com/EFForg/https-everywhere/pull/5584#issuecomment-238655443
if [ ! -f /var/lib/dbus/machine-id ]; then
Expand Down
2 changes: 1 addition & 1 deletion test/chromium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ else
./makecrx.sh
echo "running tests"
CRX_NAME="`ls -tr pkg/*.crx | tail -1`"
$XVFB_RUN python2.7 test/chromium/script.py $CRX_NAME
$XVFB_RUN python2.7 test/script.py Chrome $CRX_NAME
fi
73 changes: 0 additions & 73 deletions test/chromium/script.py

This file was deleted.

29 changes: 4 additions & 25 deletions test/firefox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ fi

source utils/mktemp.sh

# dummy Jetpack addon that contains tests
TEST_ADDON_PATH=./test/firefox/

# We'll create a Firefox profile here and install HTTPS Everywhere into it.
PROFILE_DIRECTORY="$(mktemp -d)"
trap 'rm -r "$PROFILE_DIRECTORY"' EXIT
Expand All @@ -38,10 +35,6 @@ die() {
exit 1
}

if [ ! -f "addon-sdk/bin/activate" ]; then
die "Addon SDK not available. Run git submodule update."
fi

if [ ! -d "$HTTPSE_INSTALL_DIRECTORY" ]; then
die "Firefox profile does not have HTTPS Everywhere installed"
fi
Expand All @@ -51,17 +44,6 @@ if [ -z "$XVFB_RUN" -a -n "$(which xvfb-run)" ]; then
XVFB_RUN=xvfb-run
fi

# Activate the Firefox Addon SDK.
pushd addon-sdk
source bin/activate
popd

if ! type cfx > /dev/null; then
die "Addon SDK failed to activiate."
fi

pushd $TEST_ADDON_PATH

# If you just want to run Firefox with the latest code:
if [ "$1" == "--justrun" ]; then
echo "running firefox"
Expand All @@ -73,14 +55,11 @@ if [ "$1" == "--justrun" ]; then
fi
else
echo "running tests"

PATH=/home/user/geckodriver:$PATH
if [ -n "$FIREFOX" ]; then
$XVFB_RUN cfx test -b $FIREFOX --profiledir="$PROFILE_DIRECTORY" --verbose
$XVFB_RUN python2.7 test/script.py Firefox "$PROFILE_DIRECTORY" $FIREFOX
else
$XVFB_RUN cfx test --profiledir="$PROFILE_DIRECTORY" --verbose
$XVFB_RUN python2.7 test/script.py Firefox "$PROFILE_DIRECTORY"
fi
fi

popd

shasum=$(openssl sha -sha256 "$XPI_NAME")
echo -e "Git commit `git rev-parse HEAD`\n$shasum"
Empty file removed test/firefox/lib/main.js
Empty file.
9 changes: 0 additions & 9 deletions test/firefox/package.json

This file was deleted.

38 changes: 0 additions & 38 deletions test/firefox/test/test-httpse-installed.js

This file was deleted.

12 changes: 0 additions & 12 deletions test/firefox/test/test-main.js

This file was deleted.

7 changes: 0 additions & 7 deletions test/firefox/test_profile_skeleton/extensions.ini

This file was deleted.

97 changes: 97 additions & 0 deletions test/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env python2.7
#
# Run Selenium tests for HTTPS Everywhere
#
# This script may be executed as `python script.py [directory of CRX]`
#
# The script is compatible with Python 2. Python 3 is not tested.
# Selenium, WebDriver and Google Chrome (or Chromium) must be installed
# in order for the script to run successfully. A desktop version
# of linux is required for the script to run correctly as well.
# Otherwise, use pyvirtualdisplay.

import sys, os, platform, time
from selenium import webdriver
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'


if sys.argv[1] == "Chrome":
chromeOps = webdriver.ChromeOptions()
chromeOps.add_extension(sys.argv[2])
if os.getuid() == 0:
chromeOps.add_argument("--no-sandbox")

# Find the path to chromedriver
chromedriver_path = "chromedriver"
if sys.platform.startswith("linux"):
if 'Ubuntu' in platform.linux_distribution():
chromedriver_path = "/usr/lib/chromium-browser/chromedriver"
elif 'debian' in platform.linux_distribution():
#Debian is lowercase when platform.linux_distribution() is used.
#This is not a mistake.
chromedriver_path = "/usr/lib/chromium/chromedriver"

try:
# First argument is optional, if not specified will search path.
driver = webdriver.Chrome(chromedriver_path, chrome_options=chromeOps)
except WebDriverException as e:
error = e.__str__()

if "executable needs to be in PATH" in e.__str__():
print "ChromeDriver isn't installed. Check test/chromium/README.md " \
"for instructions on how to install ChromeDriver"

sys.exit(2)
else:
raise e

if sys.argv[1] == "Firefox":
fp = webdriver.FirefoxProfile(sys.argv[2])
try:
if len(sys.argv) == 4:
binary = FirefoxBinary(sys.argv[3])
driver = webdriver.Firefox(fp, firefox_binary=binary, log_path=os.devnull)
else:
driver = webdriver.Firefox(fp, log_path=os.devnull)
except WebDriverException as e:
error = e.__str__()

if "executable needs to be in PATH" in e.__str__():
print "GeckoDriver isn't installed. Check test/firefox/README.md " \
"for instructions on how to install GeckoDriver"

sys.exit(2)
else:
raise e

# Allow the extension time to load
time.sleep(1)

print ''

driver.get('http://freerangekitten.com')

test_failed = False
if driver.current_url.startswith('https'):
print bcolors.OKGREEN + sys.argv[1] + ": HTTP to HTTPS redirection successful" + bcolors.ENDC
elif driver.current_url.startswith('http'):
print bcolors.FAIL + sys.argv[1] + ": HTTP to HTTPS redirection failed" + bcolors.ENDC
test_failed = True

print ''

driver.quit()

if test_failed:
sys.exit(1)