refactor app directory structure and add tests

This commit is contained in:
s2
2016-11-10 16:27:26 +01:00
parent 204834ce28
commit dd88218c0e
1844 changed files with 263520 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
/tests/reports/
/tests/screenshots/
/tests/*log

View File

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 825 B

View File

@@ -0,0 +1,23 @@
; This file is not used. If you modify it and want the application to use
; your modifications, move it under the browser/ subdirectory and start with
; the "-app /path/to/browser/application.ini" argument.
[App]
Vendor=Mozilla
Name=Firefox
RemotingName=firefox
Version=45.4.0
BuildID=20160905130425
SourceRepository=https://hg.mozilla.org/releases/mozilla-esr45
SourceStamp=1dc77ae31dc3ed2de5d156c2c1867098ccdebe9d
ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
[Gecko]
MinVersion=45.4.0
MaxVersion=45.4.0
[XRE]
EnableProfileMigrator=1
[Crash Reporter]
Enabled=1
ServerURL=https://crash-reports.mozilla.com/submit?id={ec8030f7-c20a-464f-9b0e-13a3a9e97384}&version=45.4.0&buildid=20160905130425

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
manifest components/components.manifest

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@@ -0,0 +1 @@
binary-component libbrowsercomps.so

Binary file not shown.

View File

@@ -0,0 +1,8 @@
; This Source Code Form is subject to the terms of the Mozilla Public
; License, v. 2.0. If a copy of the MPL was not distributed with this
; file, You can obtain one at http://mozilla.org/MPL/2.0/.
; This file is in the UTF-8 encoding
[Strings]
; LOCALIZATION NOTE (CrashReporterProductErrorText2): The %s is replaced with a string containing detailed information.
CrashReporterProductErrorText2=Firefox had a problem and crashed. We'll try to restore your tabs and windows when it restarts.\n\nUnfortunately the crash reporter is unable to submit a crash report.\n\nDetails: %s
CrashReporterDescriptionText2=Firefox had a problem and crashed. We'll try to restore your tabs and windows when it restarts.\n\nTo help us diagnose and fix the problem, you can send us a crash report.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

BIN
tests/firefox/crashreporter Executable file

Binary file not shown.

View File

@@ -0,0 +1,57 @@
; This Source Code Form is subject to the terms of the Mozilla Public
; License, v. 2.0. If a copy of the MPL was not distributed with this
; file, You can obtain one at http://mozilla.org/MPL/2.0/.
; This file is in the UTF-8 encoding
[Strings]
; LOCALIZATION NOTE (isRTL):
; Leave this entry empty unless your language requires right-to-left layout,
; for example like Arabic, Hebrew, Persian. If your language needs RTL, please
; use the untranslated English word "yes" as value
isRTL=
CrashReporterTitle=Crash Reporter
; LOCALIZATION NOTE (CrashReporterVendorTitle): %s is replaced with the vendor name. (i.e. "Mozilla")
CrashReporterVendorTitle=%s Crash Reporter
; LOCALIZATION NOTE (CrashReporterErrorText): %s is replaced with another string containing detailed information.
CrashReporterErrorText=The application had a problem and crashed.\n\nUnfortunately, the crash reporter is unable to submit a report for this crash.\n\nDetails: %s
; LOCALIZATION NOTE (CrashReporterProductErrorText2): The first %s is replaced with the product name (i.e. "Firefox"), the second is replaced with another string containing detailed information. These two substitutions can not be reordered!
CrashReporterProductErrorText2=%s had a problem and crashed.\n\nUnfortunately, the crash reporter is unable to submit a crash report.\n\nDetails: %s
CrashReporterSorry=We're Sorry
; LOCALIZATION NOTE (CrashReporterDescriptionText2): The %s is replaced with the product name.
CrashReporterDescriptionText2=%s had a problem and crashed.\n\nTo help us diagnose and fix the problem, you can send us a crash report.
CrashReporterDefault=This application is run after a crash to report the problem to the application vendor. It should not be run directly.
Details=Details…
ViewReportTitle=Report Contents
CommentGrayText=Add a comment (comments are publicly visible)
ExtraReportInfo=This report also contains technical information about the state of the application when it crashed.
; LOCALIZATION NOTE (CheckSendReport): The %s is replaced with the vendor name.
CheckSendReport=Tell %s about this crash so they can fix it
CheckIncludeURL=Include the address of the page I was on
CheckAllowEmail=Allow %s to contact me about this report
EmailGrayText=Enter your email address here
ReportPreSubmit2=Your crash report will be submitted before you quit or restart.
ReportDuringSubmit2=Submitting your report…
ReportSubmitSuccess=Report submitted successfully!
ReportSubmitFailed=There was a problem submitting your report.
ReportResubmit=Resending reports that previously failed to send…
; LOCALIZATION NOTE (Quit2): The %s is replaced with the product name.
Quit2=Quit %s
; LOCALIZATION NOTE (Restart): The %s is replaced with the product name.
Restart=Restart %s
Ok=OK
Close=Close
; LOCALIZATION NOTE (CrashID): The %s is replaced with the Crash ID from the server, which is a string like abc12345-6789-0abc-def1-23456abcdef1
CrashID=Crash ID: %s
; LOCALIZATION NOTE (CrashDetailsURL): The %s is replaced with a URL that the user can visit to view the crash details.
CrashDetailsURL=You can view details of this crash at %s
ErrorBadArguments=The application passed an invalid argument.
ErrorExtraFileExists=The application didn't leave an application data file.
ErrorExtraFileRead=Couldn't read the application data file.
ErrorExtraFileMove=Couldn't move application data file.
ErrorDumpFileExists=The application did not leave a crash dump file.
ErrorDumpFileMove=Couldn't move crash dump.
ErrorNoProductName=The application did not identify itself.
ErrorNoServerURL=The application did not specify a crash reporting server.
ErrorNoSettingsPath=Couldn't find the crash reporter's settings.
ErrorCreateDumpDir=Couldn't create pending dump directory.
; LOCALIZATION NOTE (ErrorEndOfLife): The %s is replaced with the product name.
ErrorEndOfLife=The version of %s you are using is no longer supported. Crash reports are no longer being accepted for this version. Please consider upgrading to a supported version.

View File

@@ -0,0 +1,5 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
pref("app.update.channel", "esr");

View File

@@ -0,0 +1,10 @@
libnspr4.so
libplc4.so
libplds4.so
libnssutil3.so
libnss3.so
libsmime3.so
libssl3.so
libmozsqlite3.so
liblgpllibs.so
libxul.so

BIN
tests/firefox/firefox Executable file

Binary file not shown.

BIN
tests/firefox/firefox-bin Executable file

Binary file not shown.

View File

@@ -0,0 +1,5 @@
Name: clearkey
Description: ClearKey Gecko Media Plugin
Version: 1
APIs: eme-decrypt-v8[org.w3.clearkey]
Libraries:

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

BIN
tests/firefox/libfreebl3.so Executable file

Binary file not shown.

BIN
tests/firefox/liblgpllibs.so Executable file

Binary file not shown.

BIN
tests/firefox/libmozsqlite3.so Executable file

Binary file not shown.

BIN
tests/firefox/libnspr4.so Executable file

Binary file not shown.

BIN
tests/firefox/libnss3.so Executable file

Binary file not shown.

BIN
tests/firefox/libnssckbi.so Executable file

Binary file not shown.

Binary file not shown.

BIN
tests/firefox/libnssdbm3.so Executable file

Binary file not shown.

BIN
tests/firefox/libnssutil3.so Executable file

Binary file not shown.

BIN
tests/firefox/libplc4.so Executable file

Binary file not shown.

BIN
tests/firefox/libplds4.so Executable file

Binary file not shown.

BIN
tests/firefox/libsmime3.so Executable file

Binary file not shown.

Binary file not shown.

BIN
tests/firefox/libsoftokn3.so Executable file

Binary file not shown.

BIN
tests/firefox/libssl3.so Executable file

Binary file not shown.

BIN
tests/firefox/libxul.so Executable file

Binary file not shown.

BIN
tests/firefox/omni.ja Normal file

Binary file not shown.

View File

@@ -0,0 +1,5 @@
[Build]
BuildID=20160905130425
Milestone=45.4.0
SourceStamp=1dc77ae31dc3ed2de5d156c2c1867098ccdebe9d
SourceRepository=https://hg.mozilla.org/releases/mozilla-esr45

BIN
tests/firefox/plugin-container Executable file

Binary file not shown.

64
tests/firefox/precomplete Normal file
View File

@@ -0,0 +1,64 @@
remove "webapprt/webapprt.ini"
remove "webapprt/omni.ja"
remove "webapprt-stub"
remove "updater.ini"
remove "updater"
remove "run-mozilla.sh"
remove "removed-files"
remove "precomplete"
remove "plugin-container"
remove "platform.ini"
remove "omni.ja"
remove "libxul.so"
remove "libssl3.so"
remove "libsoftokn3.so"
remove "libsoftokn3.chk"
remove "libsmime3.so"
remove "libplds4.so"
remove "libplc4.so"
remove "libnssutil3.so"
remove "libnssdbm3.so"
remove "libnssdbm3.chk"
remove "libnssckbi.so"
remove "libnss3.so"
remove "libnspr4.so"
remove "libmozsqlite3.so"
remove "liblgpllibs.so"
remove "libfreebl3.so"
remove "libfreebl3.chk"
remove "icons/updater.png"
remove "gmp-clearkey/0.1/libclearkey.so"
remove "gmp-clearkey/0.1/clearkey.info"
remove "firefox-bin"
remove "firefox"
remove "dependentlibs.list"
remove "crashreporter.ini"
remove "crashreporter"
remove "browser/omni.ja"
remove "browser/icons/mozicon128.png"
remove "browser/features/loop@mozilla.org.xpi"
remove "browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi"
remove "browser/crashreporter-override.ini"
remove "browser/components/libbrowsercomps.so"
remove "browser/components/components.manifest"
remove "browser/chrome/icons/default/default48.png"
remove "browser/chrome/icons/default/default32.png"
remove "browser/chrome/icons/default/default16.png"
remove "browser/chrome.manifest"
remove "browser/blocklist.xml"
remove "application.ini"
remove "Throbber-small.gif"
rmdir "webapprt/"
rmdir "icons/"
rmdir "gmp-clearkey/0.1/"
rmdir "gmp-clearkey/"
rmdir "defaults/pref/"
rmdir "defaults/"
rmdir "browser/icons/"
rmdir "browser/features/"
rmdir "browser/extensions/"
rmdir "browser/components/"
rmdir "browser/chrome/icons/default/"
rmdir "browser/chrome/icons/"
rmdir "browser/chrome/"
rmdir "browser/"

View File

@@ -0,0 +1,28 @@
distribution/extensions/testpilot@labs.mozilla.com.xpi
chrome/
#ifndef XP_MACOSX
chrome/icons/
chrome/icons/default/
#endif
chrome/overlayinfo/
components/
defaults/autoconfig/
defaults/profile/
defaults/profile/chrome/
defaults/profile/US/*
defaults/profile/extensions/
defaults/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/*
distribution/
distribution/extensions/
extensions/
extensions/inspector@mozilla.org/*
extensions/reporter@mozilla.org/*
extensions/talkback@mozilla.org/*
extensions/testpilot@labs.mozilla.com/*
extensions/{641d8d09-7dda-4850-8228-ac0ab65e2ac9}/*
extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/*
greprefs/
jssubloader/
modules/
searchplugins/*
webapprt/components/

362
tests/firefox/run-mozilla.sh Executable file
View File

@@ -0,0 +1,362 @@
#!/bin/sh
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
cmdname=`basename "$0"`
MOZ_DIST_BIN=`dirname "$0"`
MOZ_DEFAULT_NAME="./${cmdname}-bin"
MOZ_APPRUNNER_NAME="./mozilla-bin"
MOZ_PROGRAM=""
exitcode=1
#
##
## Functions
##
##########################################################################
moz_usage()
{
echo "Usage: ${cmdname} [options] [program]"
echo ""
echo " options:"
echo ""
echo " -g Run in debugger."
echo " --debug"
echo ""
echo " -d debugger Debugger to use."
echo " --debugger debugger"
echo ""
echo " -a debugger_args Arguments passed to [debugger]."
echo " --debugger-args debugger_args"
echo ""
echo " Examples:"
echo ""
echo " Run the mozilla-bin binary"
echo ""
echo " ${cmdname} mozilla-bin"
echo ""
echo " Debug the mozilla-bin binary in gdb"
echo ""
echo " ${cmdname} -g mozilla-bin -d gdb"
echo ""
echo " Run mozilla-bin under valgrind with arguments"
echo ""
echo " ${cmdname} -g -d valgrind -a '--tool=memcheck --leak-check=full' mozilla-bin"
echo ""
return 0
}
##########################################################################
moz_bail()
{
message=$1
echo
echo "$cmdname: $message"
echo
exit 1
}
##########################################################################
moz_test_binary()
{
binary=$1
if [ -f "$binary" ]
then
if [ -x "$binary" ]
then
return 1
fi
fi
return 0
}
##########################################################################
moz_get_debugger()
{
debuggers="ddd gdb dbx bdb native-gdb"
debugger="notfound"
done="no"
for d in $debuggers
do
moz_test_binary /bin/which
if [ $? -eq 1 ]
then
dpath=`which ${d}`
else
dpath=`LC_MESSAGES=C type ${d} | awk '{print $3;}' | sed -e 's/\.$//'`
fi
if [ -x "$dpath" ]
then
debugger=$dpath
break
fi
done
echo $debugger
return 0
}
##########################################################################
moz_run_program()
{
prog=$MOZ_PROGRAM
##
## Make sure the program is executable
##
if [ ! -x "$prog" ]
then
moz_bail "Cannot execute $prog."
fi
##
## Run the program
##
exec "$prog" ${1+"$@"}
exitcode=$?
}
##########################################################################
moz_debug_program()
{
prog=$MOZ_PROGRAM
##
## Make sure the program is executable
##
if [ ! -x "$prog" ]
then
moz_bail "Cannot execute $prog."
fi
if [ -n "$moz_debugger" ]
then
moz_test_binary /bin/which
if [ $? -eq 1 ]
then
debugger=`which $moz_debugger`
else
debugger=`LC_MESSAGES=C type $moz_debugger | awk '{print $3;}' | sed -e 's/\.$//'`
fi
else
debugger=`moz_get_debugger`
fi
if [ -x "$debugger" ]
then
# If you are not using ddd, gdb and know of a way to convey the arguments
# over to the prog then add that here- Gagan Saksena 03/15/00
case `basename $debugger` in
native-gdb) echo "$debugger $moz_debugger_args --args $prog" ${1+"$@"}
exec "$debugger" $moz_debugger_args --args "$prog" ${1+"$@"}
exitcode=$?
;;
gdb) echo "$debugger $moz_debugger_args --args $prog" ${1+"$@"}
exec "$debugger" $moz_debugger_args --args "$prog" ${1+"$@"}
exitcode=$?
;;
ddd) echo "$debugger $moz_debugger_args --gdb -- --args $prog" ${1+"$@"}
exec "$debugger" $moz_debugger_args --gdb -- --args "$prog" ${1+"$@"}
exitcode=$?
;;
*) echo "$debugger $moz_debugger_args $prog ${1+"$@"}"
exec $debugger $moz_debugger_args "$prog" ${1+"$@"}
exitcode=$?
;;
esac
else
moz_bail "Could not find a debugger on your system."
fi
}
##########################################################################
##
## Command line arg defaults
##
moz_debug=0
moz_debugger=""
moz_debugger_args=""
#
##
## Parse the command line
##
while [ $# -gt 0 ]
do
case $1 in
-g | --debug)
moz_debug=1
shift
;;
-d | --debugger)
moz_debugger=$2;
if [ "${moz_debugger}" != "" ]; then
shift 2
else
echo "-d requires an argument"
exit 1
fi
;;
-a | --debugger-args)
moz_debugger_args=$2;
if [ "${moz_debugger_args}" != "" ]; then
shift 2
else
echo "-a requires an argument"
exit 1
fi
;;
*)
break;
;;
esac
done
#
##
## Program name given in $1
##
if [ $# -gt 0 ]
then
MOZ_PROGRAM=$1
shift
fi
##
## Program not given, try to guess a default
##
if [ -z "$MOZ_PROGRAM" ]
then
##
## Try this script's name with '-bin' appended
##
if [ -x "$MOZ_DEFAULT_NAME" ]
then
MOZ_PROGRAM=$MOZ_DEFAULT_NAME
##
## Try mozilla-bin
##
elif [ -x "$MOZ_APPRUNNER_NAME" ]
then
MOZ_PROGRAM=$MOZ_APPRUNNER_NAME
fi
fi
#
#
##
## Make sure the program is executable
##
if [ ! -x "$MOZ_PROGRAM" ]
then
moz_bail "Cannot execute $MOZ_PROGRAM."
fi
#
##
## Set MOZILLA_FIVE_HOME
##
MOZILLA_FIVE_HOME=$MOZ_DIST_BIN
if [ -z "$MRE_HOME" ]; then
MRE_HOME=$MOZILLA_FIVE_HOME
fi
##
## Set LD_LIBRARY_PATH
##
## On Solaris we use $ORIGIN (set in RUNPATH) instead of LD_LIBRARY_PATH
## to locate shared libraries.
##
## When a shared library is a symbolic link, $ORIGIN will be replaced with
## the real path (i.e., what the symbolic link points to) by the runtime
## linker. For example, if dist/bin/libxul.so is a symbolic link to
## toolkit/library/libxul.so, $ORIGIN will be "toolkit/library" instead of "dist/bin".
## So the runtime linker will use "toolkit/library" NOT "dist/bin" to locate the
## other shared libraries that libxul.so depends on. This only happens
## when a user (developer) tries to start firefox, thunderbird, or seamonkey
## under dist/bin. To solve the problem, we should rely on LD_LIBRARY_PATH
## to locate shared libraries.
##
## Note:
## We test $MOZ_DIST_BIN/*.so. If any of them is a symbolic link,
## we need to set LD_LIBRARY_PATH.
##########################################################################
moz_should_set_ld_library_path()
{
[ `uname -s` != "SunOS" ] && return 0
for sharedlib in $MOZ_DIST_BIN/*.so
do
[ -h $sharedlib ] && return 0
done
return 1
}
if moz_should_set_ld_library_path
then
LD_LIBRARY_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARY_PATH:+":$LD_LIBRARY_PATH"}
fi
if [ -n "$LD_LIBRARYN32_PATH" ]
then
LD_LIBRARYN32_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARYN32_PATH:+":$LD_LIBRARYN32_PATH"}
fi
if [ -n "$LD_LIBRARYN64_PATH" ]
then
LD_LIBRARYN64_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARYN64_PATH:+":$LD_LIBRARYN64_PATH"}
fi
if [ -n "$LD_LIBRARY_PATH_64" ]; then
LD_LIBRARY_PATH_64=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARY_PATH_64:+":$LD_LIBRARY_PATH_64"}
fi
#
#
## Set SHLIB_PATH for HPUX
SHLIB_PATH=${MOZ_DIST_BIN}:${MRE_HOME}${SHLIB_PATH:+":$SHLIB_PATH"}
#
## Set LIBPATH for AIX
LIBPATH=${MOZ_DIST_BIN}:${MRE_HOME}${LIBPATH:+":$LIBPATH"}
#
## Set DYLD_LIBRARY_PATH for Mac OS X (Darwin)
DYLD_LIBRARY_PATH=${MOZ_DIST_BIN}:${MRE_HOME}${DYLD_LIBRARY_PATH:+":$DYLD_LIBRARY_PATH"}
#
## Solaris Xserver(Xsun) tuning - use shared memory transport if available
if [ "$XSUNTRANSPORT" = "" ]
then
XSUNTRANSPORT="shmem"
XSUNSMESIZE="512"
export XSUNTRANSPORT XSUNSMESIZE
fi
# Disable Gnome crash dialog
GNOME_DISABLE_CRASH_DIALOG=1
export GNOME_DISABLE_CRASH_DIALOG
if [ "$moz_debug" -eq 1 ]
then
echo "MOZILLA_FIVE_HOME=$MOZILLA_FIVE_HOME"
echo " LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
if [ -n "$LD_LIBRARYN32_PATH" ]
then
echo "LD_LIBRARYN32_PATH=$LD_LIBRARYN32_PATH"
fi
if [ -n "$LD_LIBRARYN64_PATH" ]
then
echo "LD_LIBRARYN64_PATH=$LD_LIBRARYN64_PATH"
fi
if [ -n "$LD_LIBRARY_PATH_64" ]; then
echo "LD_LIBRARY_PATH_64=$LD_LIBRARY_PATH_64"
fi
if [ -n "$DISPLAY" ]; then
echo "DISPLAY=$DISPLAY"
fi
if [ -n "$FONTCONFIG_PATH" ]; then
echo "FONTCONFIG_PATH=$FONTCONFIG_PATH"
fi
if [ -n "$MOZILLA_POSTSCRIPT_PRINTER_LIST" ]; then
echo "MOZILLA_POSTSCRIPT_PRINTER_LIST=$MOZILLA_POSTSCRIPT_PRINTER_LIST"
fi
echo "DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH"
echo " LIBRARY_PATH=$LIBRARY_PATH"
echo " SHLIB_PATH=$SHLIB_PATH"
echo " LIBPATH=$LIBPATH"
echo " ADDON_PATH=$ADDON_PATH"
echo " MOZ_PROGRAM=$MOZ_PROGRAM"
echo " MOZ_TOOLKIT=$MOZ_TOOLKIT"
echo " moz_debug=$moz_debug"
echo " moz_debugger=$moz_debugger"
echo "moz_debugger_args=$moz_debugger_args"
fi
#
export MOZILLA_FIVE_HOME LD_LIBRARY_PATH
export SHLIB_PATH LIBPATH LIBRARY_PATH ADDON_PATH DYLD_LIBRARY_PATH
if [ $moz_debug -eq 1 ]
then
moz_debug_program ${1+"$@"}
else
moz_run_program ${1+"$@"}
fi
exit $exitcode

View File

@@ -0,0 +1,5 @@
; If you modify this file updates may fail.
; Do not modify this file.
[Settings]
ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-esr

BIN
tests/firefox/updater Executable file

Binary file not shown.

View File

@@ -0,0 +1,9 @@
; This Source Code Form is subject to the terms of the Mozilla Public
; License, v. 2.0. If a copy of the MPL was not distributed with this
; file, You can obtain one at http://mozilla.org/MPL/2.0/.
; This file is in the UTF-8 encoding
; All strings must be less than 600 chars.
[Strings]
Title=Firefox Update
Info=Firefox is installing your updates and will start in a few moments…
MozillaMaintenanceDescription=The Mozilla Maintenance Service ensures that you have the latest and most secure version of Mozilla Firefox on your computer. Keeping Firefox up to date is very important for your online security, and Mozilla strongly recommends that you keep this service enabled.

BIN
tests/firefox/webapprt-stub Executable file

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,20 @@
[App]
ID=webapprt@mozilla.org
Vendor=Mozilla
; Note: the Windows stub executable sets nsXREAppData::name to the webapp
; origin, overriding the value below, to make the app runner treat webapps
; as distinct products, per bug 747409.
Name=Webapp Runtime
Version=45.4.0
BuildID=20160905130425
UAName=Firefox
[Gecko]
MinVersion=45.4.0
MaxVersion=45.4.0
[Crash Reporter]
Enabled=1
ServerURL=https://crash-reports.mozilla.com/submit?id=webapprt@mozilla.org&version=45.4.0&buildid=20160905130425

4
tests/index.js Normal file
View File

@@ -0,0 +1,4 @@
module.exports = (function(settings) {
settings.test_workers = false;
return settings;
})(require('./nightwatch.json'));

1
tests/nightwatch.js Normal file
View File

@@ -0,0 +1 @@
require('nightwatch/bin/runner.js');

38
tests/nightwatch.json Normal file
View File

@@ -0,0 +1,38 @@
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",
"selenium" : {
"start_process" : true,
"server_path" : "selenium/selenium-server-standalone-2.53.1.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4987,
"cli_args" : {
"webdriver.chrome.driver" : "",
"webdriver.ie.driver" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "file:///home/s2/Documents/Code/eclipse%20workspace/tasks/app/index.html",
"selenium_port" : 4987,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : true,
"path" : "screenshots"
},
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}

1
tests/node_modules/.bin/nightwatch generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../nightwatch/bin/nightwatch

21
tests/node_modules/nightwatch/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 Andrei Rusu <andrei.rusu@beatfactor.net>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

51
tests/node_modules/nightwatch/README.md generated vendored Normal file
View File

@@ -0,0 +1,51 @@
# Nightwatch
UI automated testing framework powered by [Node.js](http://nodejs.org/). It uses the [Selenium WebDriver API](https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol).
[![Build Status](https://travis-ci.org/nightwatchjs/nightwatch.svg?branch=master)](https://travis-ci.org/nightwatchjs/nightwatch) [![NPM version](https://badge.fury.io/js/nightwatch.png)](http://badge.fury.io/js/nightwatch) [![Coverage Status](https://coveralls.io/repos/nightwatchjs/nightwatch/badge.svg?branch=master&service=github)](https://coveralls.io/github/nightwatchjs/nightwatch?branch=master)
***
#### [Homepage](http://nightwatchjs.org) | [Developer Guide](http://nightwatchjs.org/guide) | [API Reference](http://nightwatchjs.org/api) | [Changelog](https://github.com/nightwatchjs/nightwatch/releases)
### Selenium WebDriver standalone server
Nightwatch works with the Selenium standalone server so the first thing you need to do is download the selenium server jar file `selenium-server-standalone-2.x.x.jar` from the Selenium releases page:
**https://selenium-release.storage.googleapis.com/index.html**
### Install Nightwatch
Install Node.js and then:
```sh
$ git clone https://github.com/nightwatchjs/nightwatch.git
$ cd nightwatch
$ npm install
```
### Run tests
The tests for Nightwatch are written using [Mocha](http://mochajs.org/) exports interface so they can also be run with Nightwatch itself.
To run the unit tests using mocha, do:
```sh
$ npm test
```
To run the unit tests using Nightwatch, do:
```sh
$ npm run unit-tests
```
To check test coverage, run the command:
```sh
$ npm run mocha-coverage
```
and then open the generate file _coverage.html_ in your browser.
### Discuss
The [Mailing List/Google Group](https://groups.google.com/forum/#!forum/nightwatchjs) is the most appropriate tool for Nightwatch related discussions. In addition, there is a [StackOverflow Nightwatch.js tag](http://stackoverflow.com/questions/tagged/nightwatch.js) at your disposal and [Twitter](https://twitter.com/nightwatchjs).
### Setup Guides
Browser specific setup and usage guides along with debugging instructions can be found on the [**Wiki**](https://github.com/nightwatchjs/nightwatch/wiki).

5
tests/node_modules/nightwatch/bin/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,5 @@
selenium-server-standalone-*
chromedriver
chromedriver-*
phantomjs
IEDriverServer_*

3
tests/node_modules/nightwatch/bin/nightwatch generated vendored Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env node
require('./runner.js');

116
tests/node_modules/nightwatch/bin/nightwatch.json generated vendored Normal file
View File

@@ -0,0 +1,116 @@
{
"src_folders" : ["./examples/tests"],
"output_folder" : "./examples/reports",
"custom_commands_path" : "./examples/custom-commands",
"page_objects_path" : "./examples/pages",
"custom_assertions_path" : "",
"globals_path" : "",
"live_output" : false,
"parallel_process_delay" : 10,
"disable_colors": false,
"test_workers" : false,
"selenium" : {
"start_process" : false,
"server_path" : "",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "",
"webdriver.ie.driver" : "",
"webdriver.firefox.profile" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_host" : "127.0.0.1",
"selenium_port" : 4444,
"silent" : true,
"disable_colors": false,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities" : {
"browserName" : "firefox",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
"saucelabs" : {
"selenium_host" : "ondemand.saucelabs.com",
"selenium_port" : 80,
"username" : "${SAUCE_USERNAME}",
"access_key" : "${SAUCE_ACCESS_KEY}",
"use_ssl" : false,
"silent" : true,
"output" : true,
"screenshots" : {
"enabled" : false,
"on_failure" : true,
"path" : ""
},
"desiredCapabilities": {
"name" : "test-example",
"browserName": "firefox"
},
"globals" : {
"myGlobal" : "some_sauce_global"
},
"selenium" : {
"start_process" : false
}
},
"phantomjs" : {
"desiredCapabilities" : {
"browserName" : "phantomjs",
"javascriptEnabled" : true,
"acceptSslCerts" : true,
"phantomjs.binary.path" : "/path/to/phantomjs"
}
},
"browserstack" : {
"selenium" : {
"start_process" : false
},
"selenium_host" : "hub.browserstack.com",
"selenium_port" : 80,
"silent" : true,
"desiredCapabilities": {
"name" : "test-example",
"browserName": "firefox",
"browserstack.user" : "...",
"browserstack.key" : "..."
}
},
"testingbot" : {
"selenium_host" : "hub.testingbot.com",
"selenium_port" : 80,
"apiKey" : "${TB_KEY}",
"apiSecret" : "${TB_SECRET}",
"silent" : true,
"output" : true,
"screenshots" : {
"enabled" : false,
"on_failure" : true,
"path" : ""
},
"desiredCapabilities": {
"name" : "test-example",
"browserName": "firefox"
},
"selenium" : {
"start_process" : false
}
}
}
}

16
tests/node_modules/nightwatch/bin/runner.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
/**
* Module dependencies
*/
var Logger = require('../lib/util/logger.js');
var Nightwatch = require('../lib/index.js');
var Utils = require('../lib/util/utils.js');
try {
Nightwatch.cli(function(argv) {
argv._source = argv['_'].slice(0);
Nightwatch.runner(argv);
});
} catch (ex) {
Utils.showStackTraceWithHeadline('There was an error while starting the test runner:\n', ex.stack + '\n', true);
process.exit(2);
}

2
tests/node_modules/nightwatch/examples/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,2 @@
reports
screens

View File

@@ -0,0 +1,18 @@
/**
* Simple example of custom command. This command will
* check if there's a onbeforeunload handler in the target web page
* and return the result
*/
/* global window */
module.exports.command = function(callback) {
var self = this;
this.execute(function() {
return window && typeof window.onbeforeunload === 'function';
}, [], function(result) {
callback.call(self, result.value);
});
return this;
};

8
tests/node_modules/nightwatch/examples/globals.json generated vendored Normal file
View File

@@ -0,0 +1,8 @@
{
"default" : {
"myGlobal" : 1
},
"test_env" : {
"myGlobal" : 2
}
}

View File

@@ -0,0 +1,55 @@
module.exports = {
// this controls whether to abort the test execution when an assertion failed and skip the rest
// it's being used in waitFor commands and expect assertions
abortOnAssertionFailure : true,
// this will overwrite the default polling interval (currently 500ms) for waitFor commands
// and expect assertions that use retry
waitForConditionPollInterval : 300,
// default timeout value in milliseconds for waitFor commands and implicit waitFor value for
// expect assertions
waitForConditionTimeout : 5000,
// this will cause waitFor commands on elements to throw an error if multiple
// elements are found using the given locate strategy and selector
throwOnMultipleElementsReturned : true,
// controls the timeout time for async hooks. Expects the done() callback to be invoked within this time
// or an error is thrown
asyncHookTimeout : 10000,
'default' : {
myGlobal : function() {
return 'I\'m a method';
}
},
'test_env' : {
myGlobal: 'test_global',
beforeEach : function() {
}
},
before : function(cb) {
cb();
},
beforeEach : function(browser, cb) {
cb();
},
after : function(cb) {
cb();
},
afterEach : function(browser, cb) {
cb();
},
reporter : function(results, cb) {
//console.log(results);
cb();
}
};

24
tests/node_modules/nightwatch/examples/mocha/github.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
describe('Github', function() {
it('Demo test GitHub', function (client) {
client
.url('https://github.com/nightwatchjs/nightwatch')
.waitForElementVisible('body', 1000)
.assert.title('nightwatchjs/nightwatch · GitHub')
.assert.visible('.container h1 strong a')
.assert.containsText('.container h1 strong a', 'nightwatch', 'Checking project title is set to nightwatch');
});
after(function(client, done) {
if (client.sessionId) {
client.end(function() {
done();
});
} else {
done();
}
});
});

View File

@@ -0,0 +1,38 @@
describe('Google demo test for Mocha', function() {
describe('for demo purposes', function() {
before(function(client, done) {
done();
});
after(function(client, done) {
if (client.sessionId) {
client.end(function() {
done();
});
} else {
done();
}
});
afterEach(function(client, done) {
done();
});
beforeEach(function(client, done) {
done();
});
it('uses BDD to run the Google simple test', function(client) {
client
.url('http://google.com')
.expect.element('body').to.be.present.before(1000);
client.setValue('input[type=text]', ['nightwatch', client.Keys.ENTER])
.pause(1000)
.assert.containsText('#main', 'Night Watch');
});
});
});

17
tests/node_modules/nightwatch/examples/pages/home.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
var searchCommands = {
submit: function() {
this.waitForElementVisible('@submitButton', 3000)
.click('@submitButton')
.api.pause(1000);
return this; // Return page object for chaining
}
};
module.exports = {
url: 'http://google.com',
commands: [searchCommands],
elements: {
searchBar: { selector: 'input[name=q]' },
submitButton: { selector: '[type=submit]' }
}
};

View File

@@ -0,0 +1,31 @@
var util = require('util');
var menuXpath = '//div[contains(@class, "hdtb-mitem")][contains(., %s)]';
var menuCommands = {
productIsSelected: function(product, callback) {
var self = this;
return this.getAttribute(product, 'class', function(result) {
var isSelected = result.value.indexOf('hdtb-msel') > -1;
callback.call(self, isSelected);
});
}
};
module.exports = {
elements: {
results: { selector: '#ires' }
},
sections: {
menu: {
selector: '#hdtb-msb',
commands: [menuCommands],
elements: {
web: { selector: util.format(menuXpath, 'Web'), locateStrategy: 'xpath' },
video: { selector: util.format(menuXpath, 'Video'), locateStrategy: 'xpath' },
images: { selector: util.format(menuXpath, 'Images'), locateStrategy: 'xpath' },
shopping: { selector: util.format(menuXpath, 'Shopping'), locateStrategy: 'xpath' }
}
}
}
};

View File

@@ -0,0 +1 @@
fbcredentials.json

53
tests/node_modules/nightwatch/examples/tests/digg.js generated vendored Normal file
View File

@@ -0,0 +1,53 @@
/**
* =============================================================================
* Demo of Facebook Connect automated login with Nightwatch.js.
* The test navigates to digg.com and tries to perform a Facebook connect login.
*
* This test requires a fbcredentials.json file to be placed in the same
* folder, containing the facebook username and password in the form below:
* -----
* {
* "username" : "",
* "password" : ""
* }
* -----
* The test only works if you have the permissions ALREADY enabled for digg.com
* in your facebook account.
* =============================================================================
*/
module.exports = {
disabled : true,
'digg facebook login' : function (client) {
var fbcredentials;
try {
fbcredentials = require('./fbcredentials.json');
} catch (err) {
console.error('Couldn\'t load the facebook credentials file. Please ensure that ' +
'you have the fbcredentials.json in the same folder as the test.');
process.exit();
}
client
.url('http://digg.com')
.waitForElementVisible('body', 1000)
.click('#nav-signin')
.click('#btn-facebook-auth-topnav')
.windowHandles(function(result) {
client.assert.equal(result.value.length, 2, 'There should be two windows open.');
var fbWindowHandle = result.value[1];
client.switchWindow(fbWindowHandle);
})
.waitForElementVisible('#facebook body', 1000)
.setValue('input#email', fbcredentials.username)
.setValue('input#pass', fbcredentials.password)
.click('#loginbutton input')
.windowHandles(function(result) {
client.assert.equal(result.value.length, 1, 'There should be only one window open.');
client.switchWindow(result.value[0]);
})
.waitForElementVisible('#digg-header.authenticated', 3000)
.end();
}
};

View File

@@ -0,0 +1,14 @@
module.exports = {
tags: ['git'],
'Demo test GitHub' : function (client) {
client
.url('https://github.com/nightwatchjs/nightwatch')
.waitForElementVisible('body', 1000)
.assert.visible('.container h1 strong a')
.assert.containsText('.container h1 strong a', 'nightwatch', 'Checking project title is set to nightwatch');
},
after : function(client) {
client.end();
}
};

29
tests/node_modules/nightwatch/examples/tests/google.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
/* jshint expr: true */
module.exports = {
tags: ['google'],
'Demo test Google' : function (client) {
client
.url('http://google.no')
.pause(1000);
client.expect.element('body').to.be.present;
client.expect.element('#lst-ib').to.have.css('display');
client.expect.element('body').to.have.attribute('class').which.contains('vasq');
client.expect.element('body').to.have.attribute('class').which.matches(/vasq$/);
client.expect.element('body').to.have.attribute('class').before(1000);
client.expect.element('#lst-ib').to.be.enabled;
client.expect.element('#hplogo').text.to.match(/Norge/).before(1000);
client.setValue('#lst-ib', 'Norway').pause(500);
client.expect.element('#lst-ib').to.have.value.equal('Norway');
client.expect.element('#lst-ib').to.be.an('input');
client.expect.element('#lst-ib').to.be.not.selected;
client.expect.element('#lst-ib').to.be.visible;
client.end();
}
};

View File

@@ -0,0 +1,22 @@
/**
* Sample automated test scenario for Nightwatch.js
*
* > it navigates to google.com and searches for nightwatch,
* verifying if the term 'The Night Watch' exists in the search results
*/
module.exports = {
'demo test google' : function (client) {
client
.url('http://google.com')
.waitForElementPresent('body', 1000);
},
'part two' : function(client) {
client
.setValue('input[type=text]', ['nightwatch', client.Keys.ENTER])
.pause(1000)
.assert.containsText('#main', 'Night Watch')
.end();
}
};

View File

@@ -0,0 +1,29 @@
/* jshint expr: true */
module.exports = {
'Demo Google search test using page objects' : function (client) {
var homePage = client.page.home();
homePage.navigate();
homePage.expect.element('@searchBar').to.be.enabled;
homePage
.setValue('@searchBar', 'Nightwatch.js')
.submit();
var resultsPage = client.page.searchResults();
resultsPage.expect.element('@results').to.be.present.after(2000);
resultsPage.expect.element('@results').to.contain.text('Nightwatch.js');
resultsPage.expect.section('@menu').to.be.visible;
var menuSection = resultsPage.section.menu;
menuSection.expect.element('@web').to.be.visible;
menuSection.expect.element('@video').to.be.visible;
menuSection.expect.element('@images').to.be.visible;
menuSection.expect.element('@shopping').to.be.visible;
menuSection.productIsSelected('@web', function(result) {
this.assert.ok(result, 'Web results are shown by default on search results page');
});
client.end();
}
};

View File

@@ -0,0 +1,18 @@
module.exports = {
disabled : true,
'Demo test NightwatchJS.org' : function (client) {
client
.url('http://nightwatchjs.org')
.waitForElementVisible('body', 1000)
.elements('css selector', '#index-container ul.features li', function (result) {
for (var i = 0; i < result.value.length; i++) {
var element = result.value[i];
var selector = '#index-container ul.features li:nth-child(' + (element.ELEMENT ) +') em';
client.verify.cssClassPresent(selector, 'glyphicon');
}
})
.end();
}
};

View File

@@ -0,0 +1,39 @@
/**
* Sample automated test scenario for Nightwatch.js
*
* > it navigates to page that has onbeforeunload handler
*/
module.exports = {
'go to page with unload handler': function(client) {
client
.url('http://www.4guysfromrolla.com/demos/OnBeforeUnloadDemo1.htm')
.waitForElementVisible('body', 1000);
},
'navigate away from page WITH unload handler': function(client) {
var hasDialog = false;
client
.hasOnBeforeUnload(function(result) {
this.verify.equal(result, true, 'The page should have an onbeforeunload handler');
hasDialog = result;
})
.url('http://google.com', function() {
if (hasDialog) {
this.acceptAlert();
}
})
.waitForElementVisible('body', 1000);
},
'go to nightwatch' : function(c) {
c.url('http://nightwatchjs.org')
.waitForElementVisible('body', 1000);
},
after : function(c) {
c.end();
}
};

View File

@@ -0,0 +1,14 @@
module.exports = {
tags: ['git'],
'Demo test GitHub' : function (client) {
client
.url('https://github.com/nightwatchjs/nightwatch')
.waitForElementVisible('body', 1000)
.assert.visible('.container h1 strong a')
.assert.containsText('.container h1 strong a', 'nightwatch', 'Checking project title is set to nightwatch');
},
after : function(client) {
client.end();
}
};

View File

@@ -0,0 +1,9 @@
module.exports = {
'demo UnitTest' : function (client, done) {
client.assert.ok('TEST');
setTimeout(function() {
done();
}, 500);
}
};

View File

@@ -0,0 +1,41 @@
var Utils = require('../../lib/util/utils.js');
module.exports = {
testFormatElapsedTime : function(client) {
var test = client.assert;
var resultMs = Utils.formatElapsedTime(999);
test.equal(resultMs, '999ms');
var resultSec = Utils.formatElapsedTime(1999);
test.equal(resultSec, '1.999s');
var resultMin = Utils.formatElapsedTime(122299, true);
test.equal(resultMin, '2m 2s / 122299ms');
},
testMakeFnAsync : function(client) {
function asynFn(done) {
done();
}
function syncFn() {}
var test = client.assert;
test.equal(Utils.makeFnAsync(1, asynFn), asynFn);
var convertedFn = Utils.makeFnAsync(1, syncFn);
convertedFn(function() {
test.ok('converted fn called');
});
},
testGetTestSuiteName : function(client) {
var test = client.assert;
test.equal(Utils.getTestSuiteName('test-case-one'), 'Test Case One');
test.equal(Utils.getTestSuiteName('test_case_two'), 'Test Case Two');
test.equal(Utils.getTestSuiteName('test.case.one'), 'Test Case One');
test.equal(Utils.getTestSuiteName('testCaseOne'), 'Test Case One');
}
};

View File

@@ -0,0 +1,29 @@
var Utils = require('../../lib/util/utils.js');
var expect = require('chai').expect;
module.exports = {
testFormatElapsedTime : function(client) {
var resultMs = Utils.formatElapsedTime(999);
var resultSec = Utils.formatElapsedTime(1999);
var resultMin = Utils.formatElapsedTime(122299, true);
expect(resultMs).to.equal('999ms');
expect(resultSec).to.equal('1.999s');
expect(resultMin).to.equal('2m 2s / 122299ms');
},
testFormatElapsedTimeMore : function(client) {
var resultMs = Utils.formatElapsedTime(999);
expect(resultMs).to.equal('999ms');
},
testMakeFnAsync : function(client) {
function asynFn(done) {
done();
}
function syncFn() {}
expect(Utils.makeFnAsync(1, asynFn)).to.equal(asynFn);
}
};

3
tests/node_modules/nightwatch/index.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
module.exports = process.env.NIGHTWATCH_COV ?
require('./lib-cov/index') :
require('./lib/index');

View File

@@ -0,0 +1,57 @@
/**
* Checks if the given attribute of an element contains the expected value.
*
* ```
* this.demoTest = function (client) {
* browser.assert.attributeContains('#someElement', 'href', 'google.com');
* };
* ```
*
* @method attributeContains
* @param {string} selector The selector (CSS / Xpath) used to locate the element.
* @param {string} attribute The attribute name
* @param {string} expected The expected contained value of the attribute to check.
* @param {string} [message] Optional log message to display in the output. If missing, one is displayed by default.
* @api assertions
*/
var util = require('util');
exports.assertion = function(selector, attribute, expected, msg) {
var DEFAULT_MSG = 'Testing if attribute %s of <%s> contains "%s".';
var MSG_ELEMENT_NOT_FOUND = DEFAULT_MSG + ' ' + 'Element could not be located.';
var MSG_ATTR_NOT_FOUND = DEFAULT_MSG + ' ' + 'Element does not have a ' + attribute + ' attribute.';
this.message = msg || util.format(DEFAULT_MSG, attribute, selector, expected);
this.expected = function() {
return expected;
};
this.pass = function(value) {
return value.indexOf(expected) > -1;
};
this.failure = function(result) {
var failed = (result === false) ||
// no such element
result && (result.status === -1 || result.value === null);
if (failed) {
var defaultMsg = MSG_ELEMENT_NOT_FOUND;
if (result && result.value === null) {
defaultMsg = MSG_ATTR_NOT_FOUND;
}
this.message = msg || util.format(defaultMsg, attribute, selector, expected);
}
return failed;
};
this.value = function(result) {
return result.value;
};
this.command = function(callback) {
return this.api.getAttribute(selector, attribute, callback);
};
};

View File

@@ -0,0 +1,57 @@
/**
* Checks if the given attribute of an element has the expected value.
*
* ```
* this.demoTest = function (client) {
* browser.assert.attributeEquals('body', 'data-attr', 'some value');
* };
* ```
*
* @method attributeEquals
* @param {string} selector The selector (CSS / Xpath) used to locate the element.
* @param {string} attribute The attribute name
* @param {string} expected The expected value of the attribute to check.
* @param {string} [message] Optional log message to display in the output. If missing, one is displayed by default.
* @api assertions
*/
var util = require('util');
exports.assertion = function(selector, attribute, expected, msg) {
var DEFAULT_MSG = 'Testing if attribute %s of <%s> equals "%s".';
var MSG_ELEMENT_NOT_FOUND = DEFAULT_MSG + ' ' + 'Element could not be located.';
var MSG_ATTR_NOT_FOUND = DEFAULT_MSG + ' ' + 'Element does not have a ' + attribute + ' attribute.';
this.message = msg || util.format(DEFAULT_MSG, attribute, selector, expected);
this.expected = function() {
return expected;
};
this.pass = function(value) {
return value === expected;
};
this.failure = function(result) {
var failed = (result === false) ||
// no such element
result && (result.status === -1 || result.value === null);
if (failed) {
var defaultMsg = MSG_ELEMENT_NOT_FOUND;
if (result && result.value === null) {
defaultMsg = MSG_ATTR_NOT_FOUND;
}
this.message = msg || util.format(defaultMsg, attribute, selector, expected);
}
return failed;
};
this.value = function(result) {
return result.value;
};
this.command = function(callback) {
return this.api.getAttribute(selector, attribute, callback);
};
};

View File

@@ -0,0 +1,49 @@
/**
* Checks if the given element contains the specified text.
*
* ```
* this.demoTest = function (client) {
* browser.assert.containsText('#main', 'The Night Watch');
* };
* ```
*
* @method containsText
* @param {string} selector The selector (CSS / Xpath) used to locate the element.
* @param {string} expectedText The text to look for.
* @param {string} [message] Optional log message to display in the output. If missing, one is displayed by default.
* @api assertions
*/
var util = require('util');
exports.assertion = function(selector, expectedText, msg) {
var MSG_ELEMENT_NOT_FOUND = 'Testing if element <%s> contains text: "%s". ' +
'Element could not be located.';
this.message = msg || util.format('Testing if element <%s> contains text: "%s".', selector, expectedText);
this.expected = function() {
return expectedText;
};
this.pass = function(value) {
return value.indexOf(expectedText) > -1;
};
this.failure = function(result) {
var failed = result === false || result && result.status === -1;
if (failed) {
this.message = msg || util.format(MSG_ELEMENT_NOT_FOUND, selector, expectedText);
}
return failed;
};
this.value = function(result) {
return result.value;
};
this.command = function(callback) {
return this.api.getText(selector, callback);
};
};

Some files were not shown because too many files have changed in this diff Show More