mirror of
https://github.com/servo/servo.git
synced 2025-08-10 16:05:43 +01:00
Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255
This commit is contained in:
parent
b2a5225831
commit
1a81b18b9f
12321 changed files with 544385 additions and 6 deletions
38
tests/wpt/web-platform-tests/webdriver/README.md
Normal file
38
tests/wpt/web-platform-tests/webdriver/README.md
Normal file
|
@ -0,0 +1,38 @@
|
|||
# W3C Browser Automation Specification Tests
|
||||
|
||||
This repository defines a set of conformance tests for the W3C web
|
||||
browser automation specification known as WebDriver. The purpose is
|
||||
for the different driver implementations to be tested to determine
|
||||
whether they meet the recognized standard.
|
||||
|
||||
## How to run the tests
|
||||
|
||||
1. Go to the WebDriver tests: `cd _WEBDRIVER_TEST_ROOT_`
|
||||
2. Run the tests: `python runtests.py`
|
||||
3. Run the test against a different config specified in webdriver.cfg:
|
||||
`WD_BROWSER=chrome python runtests.py`
|
||||
|
||||
To be run a specific test file you can just run `python test_file.py`
|
||||
|
||||
Similarly you can specify a different browser to run against if in webdriver.cfg:
|
||||
`WD_BROWSER=chrome python ecmascript/ecmascript_test.py`
|
||||
|
||||
Note: that you will need likely need to start the driver's server before running.
|
||||
|
||||
## Updating configuration
|
||||
|
||||
The _webdriver.cfg_ file holds any configuration that the tests might
|
||||
require. Change the value of browser to your needs. This will then
|
||||
be picked up by WebDriverBaseTest when tests are run.
|
||||
|
||||
Be sure not to commit your _webdriver.cfg_ changes when your create or modify tests.
|
||||
|
||||
## How to write tests
|
||||
|
||||
1. Create a test file per section from the specification.
|
||||
2. For each test there needs to be one or more corresponding HTML
|
||||
files that will be used for testing. HTML files are not to be
|
||||
reused between tests. HTML files and other support files
|
||||
should be stored in a folder named 'res'.
|
||||
3. Test name should explain the intention of the test e.g. `def
|
||||
test_navigate_and_return_title(self):`
|
49
tests/wpt/web-platform-tests/webdriver/base_test.py
Normal file
49
tests/wpt/web-platform-tests/webdriver/base_test.py
Normal file
|
@ -0,0 +1,49 @@
|
|||
import ConfigParser
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from network import get_lan_ip
|
||||
|
||||
repo_root = os.path.abspath(os.path.join(__file__, "../.."))
|
||||
sys.path.insert(1, os.path.join(repo_root, "tools", "webdriver"))
|
||||
sys.path.insert(1, os.path.join(repo_root, "tools", "wptserve"))
|
||||
from wptserve import server
|
||||
from webdriver.driver import WebDriver
|
||||
|
||||
|
||||
class WebDriverBaseTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.driver = create_driver()
|
||||
|
||||
cls.webserver = server.WebTestHttpd(host=get_lan_ip())
|
||||
cls.webserver.start()
|
||||
cls.webserver.where_is = cls.webserver.get_url
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.webserver.stop()
|
||||
if cls.driver:
|
||||
cls.driver.quit()
|
||||
|
||||
|
||||
def create_driver():
|
||||
config = ConfigParser.ConfigParser()
|
||||
config.read('webdriver.cfg')
|
||||
section = os.environ.get("WD_BROWSER", 'firefox')
|
||||
url = 'http://127.0.0.1:4444/wd/hub'
|
||||
if config.has_option(section, 'url'):
|
||||
url = config.get(section, "url")
|
||||
capabilities = None
|
||||
if config.has_option(section, 'capabilities'):
|
||||
try:
|
||||
capabilities = json.loads(config.get(section, "capabilities"))
|
||||
except:
|
||||
pass
|
||||
mode = 'compatibility'
|
||||
if config.has_option(section, 'mode'):
|
||||
mode = config.get(section, 'mode')
|
||||
|
||||
return WebDriver(url, {}, capabilities, mode)
|
67
tests/wpt/web-platform-tests/webdriver/cookie/cookie_test.py
Normal file
67
tests/wpt/web-platform-tests/webdriver/cookie/cookie_test.py
Normal file
|
@ -0,0 +1,67 @@
|
|||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
from webdriver import exceptions
|
||||
|
||||
|
||||
class CookieTest(base_test.WebDriverBaseTest):
|
||||
def setUp(self):
|
||||
self.driver.get(self.webserver.where_is("cookie/res/cookie_container.html"))
|
||||
|
||||
def test_can_create_a_well_formed_cookie( self ):
|
||||
name = 'foo'
|
||||
value = 'bar'
|
||||
|
||||
self.driver.add_cookie({ 'name': name, 'value': value })
|
||||
|
||||
def test_cookies_should_allow_secure_to_be_set( self ):
|
||||
name = 'foo'
|
||||
value = 'bar'
|
||||
secure = True
|
||||
|
||||
self.driver.add_cookie({ 'name': name,
|
||||
'value': value,
|
||||
'path': '/',
|
||||
'secure': secure})
|
||||
self.assertTrue(self.driver.get_cookie(name)[0]['secure'])
|
||||
|
||||
def test_secure_defaults_to_false( self ):
|
||||
name = 'foo'
|
||||
value = 'bar'
|
||||
|
||||
self.driver.add_cookie({ 'name': name,
|
||||
'value': value})
|
||||
|
||||
self.assertFalse(self.driver.get_cookie(name)[0]['secure'])
|
||||
|
||||
def test_should_throw_an_exception_when_semicolon_exists_in_the_cookie_attribute(self):
|
||||
invalid_name = 'foo;bar'
|
||||
value = 'foobar'
|
||||
|
||||
try:
|
||||
self.driver.add_cookie({ 'name': invalid_name, 'value': value })
|
||||
self.fail( 'should have thrown exceptions.' )
|
||||
|
||||
except exceptions.UnableToSetCookieException:
|
||||
pass
|
||||
except exceptions.InvalidCookieDomainException:
|
||||
pass
|
||||
|
||||
def test_should_throw_an_exception_the_name_is_null(self):
|
||||
val = 'foobar'
|
||||
|
||||
try:
|
||||
self.driver.add_cookie({ 'name': None, 'value': val })
|
||||
self.fail( 'should have thrown exceptions.' )
|
||||
|
||||
except exceptions.UnableToSetCookieException:
|
||||
pass
|
||||
except exceptions.InvalidCookieDomainException:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>Cookie Container</title>
|
||||
<body>
|
||||
</body>
|
|
@ -0,0 +1,17 @@
|
|||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
|
||||
|
||||
class EcmasScriptTest(base_test.WebDriverBaseTest):
|
||||
def test_that_ecmascript_returns_document_title(self):
|
||||
self.driver.get(self.webserver.where_is("ecmascript/res/ecmascript_test.html"))
|
||||
result = self.driver.execute_script("return document.title;");
|
||||
self.assertEquals("ecmascript test", result);
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<title>ecmascript test</title>
|
|
@ -0,0 +1,37 @@
|
|||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
|
||||
|
||||
class ElementLocationTest(base_test.WebDriverBaseTest):
|
||||
def test_find_element_by_name(self):
|
||||
self.driver.get(self.webserver.where_is("element_location/res/elements.html"))
|
||||
e = self.driver.find_element_by_css("*[name='name']")
|
||||
self.assertEquals("name", e.text)
|
||||
|
||||
def test_find_element_by_css_selector(self):
|
||||
self.driver.get(self.webserver.where_is("element_location/res/elements.html"))
|
||||
e = self.driver.find_element_by_css("#id")
|
||||
self.assertEquals("id", e.text)
|
||||
|
||||
def test_find_element_by_link_text(self):
|
||||
self.driver.get(self.webserver.where_is("element_location/res/elements.html"))
|
||||
e = self.driver.find_element_by_link_text("link text")
|
||||
self.assertEquals("link text", e.text)
|
||||
|
||||
def test_find_element_by_partial_link_text(self):
|
||||
self.driver.get(self.webserver.where_is("element_location/res/elements.html"))
|
||||
e = self.driver.find_element_by_partial_link_text("link tex")
|
||||
self.assertEquals("link text", e.text)
|
||||
|
||||
def test_find_element_by_xpath(self):
|
||||
self.driver.get(self.webserver.where_is("element_location/res/elements.html"))
|
||||
e = self.driver.find_element_by_xpath("//*[@id='id']")
|
||||
self.assertEquals("id", e.text)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>Element location</title>
|
||||
|
||||
<body>
|
||||
<div id="id">id</div>
|
||||
<div id="name" name="name">name</div>
|
||||
<a id="link">link text</a>
|
||||
</body>
|
|
@ -0,0 +1,71 @@
|
|||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
|
||||
|
||||
class GetElementAttributeTest(base_test.WebDriverBaseTest):
|
||||
def test_get_element_attribute(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-with-id-attribute.html"))
|
||||
el = self.driver.find_element_by_css("div")
|
||||
self.assertEqual("myId", el.get_attribute("id"))
|
||||
|
||||
def test_style_attribute(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-with-style-attribute.html"))
|
||||
el = self.driver.find_element_by_css("div")
|
||||
expected_style = """
|
||||
font-family: \"Gill Sans Extrabold\",Helvetica,sans-serif;
|
||||
line-height: 1.2; font-weight: bold;
|
||||
"""
|
||||
self.assertEqual(expected_style, el.get_attribute("style"))
|
||||
|
||||
def test_color_serialization_of_style_attribute(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-with-color-style-attribute.html"))
|
||||
el = self.driver.find_element_by_css("div")
|
||||
self.assertEqual("color: rgba(255, 0, 0, 1.0);", el.get_attribute("style"))
|
||||
|
||||
def test_true_if_boolean_attribute_present(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/input-with-checked-attribute.html"))
|
||||
el = self.driver.find_element_by_css("input")
|
||||
self.assertEqual("true", el.get_attribute("checked"))
|
||||
|
||||
def test_none_if_boolean_attribute_absent(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/input-without-checked-attribute.html"))
|
||||
el = self.driver.find_element_by_css("input")
|
||||
self.assertIsNone(el.get_attribute("checked"))
|
||||
|
||||
def test_option_with_attribute_value(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/option-with-value-attribute.html"))
|
||||
el = self.driver.find_element_by_css("option")
|
||||
self.assertEqual("value1", el.get_attribute("value"))
|
||||
|
||||
def test_option_without_value_attribute(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/option-without-value-attribute.html"))
|
||||
el = self.driver.find_element_by_css("option")
|
||||
self.assertEqual("Value 1", el.get_attribute("value"))
|
||||
|
||||
def test_a_href_attribute(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/a-with-href-attribute.html"))
|
||||
el = self.driver.find_element_by_css("a")
|
||||
self.assertEqual("http://web-platform.test:8000/path#fragment", el.get_attribute("href"))
|
||||
|
||||
def test_img_src_attribute(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/img-with-src-attribute.html"))
|
||||
el = self.driver.find_element_by_css("img")
|
||||
self.assertEqual("http://web-platform.test:8000/images/blue.png", el.get_attribute("src"))
|
||||
|
||||
def test_custom_attribute(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-with-custom-attribute.html"))
|
||||
el = self.driver.find_element_by_css("div")
|
||||
self.assertEqual("attribute value", el.get_attribute("webdriver-custom-attribute"))
|
||||
|
||||
def test_attribute_not_present(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-without-attribute.html"))
|
||||
el = self.driver.find_element_by_css("div")
|
||||
self.assertIsNone(el.get_attribute("class"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset='utf-8'>
|
||||
<title>0x0 pixel element</title>
|
||||
|
||||
<style>
|
||||
div {
|
||||
height: 0;
|
||||
width: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>This element is not visible.</div>
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset='utf-8'>
|
||||
<title>1x1 pixel element</title>
|
||||
|
||||
<style>
|
||||
p {
|
||||
height: 1px;
|
||||
width: 1px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<p>This element is visible.</p>
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>"a" element with not fully qualified url</title>
|
||||
|
||||
<a href="//web-platform.test:8000/path#fragment"> </a>
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Parent node visible with absolutely positioned children, where ancestor overflow is hidden</title>
|
||||
|
||||
<style>
|
||||
body {
|
||||
overflow: hidden;
|
||||
height: 0;
|
||||
width: 0;
|
||||
}
|
||||
.child { position: absolute }
|
||||
</style>
|
||||
|
||||
<div id=parent>
|
||||
<div class=child>grated</div>
|
||||
<div class=child>cheese</div>
|
|
@ -0,0 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>BODY element has no children. MUST be reported displayed</title>
|
||||
<body/>
|
|
@ -0,0 +1,3 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>BODY tag is omitted; BODY element MUST be reported displayed</title>
|
|
@ -0,0 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>BODY element with style=overflow:hidden. MUST be reported displayed</title>
|
||||
<body style="overflow:hidden"/>
|
|
@ -0,0 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>BODY element with style=visibility:hidden. MUST be reported displayed</title>
|
||||
<body style="visibility:hidden"/>
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset='utf-8'>
|
||||
<title>display: block;</title>
|
||||
|
||||
<p>This element is visible.</p>
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>display: none applies to child node links</title>
|
||||
|
||||
<style>
|
||||
#parent { display: none }
|
||||
</style>
|
||||
|
||||
<div id="parent">
|
||||
<a id="child">hidden</a>
|
||||
</div>
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>display: none applies to child node paragraphs</title>
|
||||
|
||||
<style>
|
||||
#parent { display: none }
|
||||
</style>
|
||||
|
||||
<div id="parent">
|
||||
<p id="child">hidden</p>
|
||||
</div>
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>display: none applies to child nodes</title>
|
||||
|
||||
<style>
|
||||
#parent { display: none }
|
||||
</style>
|
||||
|
||||
<div id="parent">
|
||||
<div id="child">Brie is good</div>
|
||||
</div>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>display: none set dynamically</title>
|
||||
|
||||
<p id="hidden">Should not be visible</span>
|
||||
|
||||
<script>
|
||||
var hidden = document.getElementById("hidden");
|
||||
hidden.style.display = "none";
|
||||
</script>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>display: none on parent takes presedence over visibility: visible on child node</title>
|
||||
|
||||
<style>
|
||||
#parent { display: none }
|
||||
#child { visibility: visible }
|
||||
</style>
|
||||
|
||||
<div id="parent">
|
||||
<div id="child">
|
||||
hidden
|
||||
</div>
|
||||
</div>
|
||||
in
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>display: none on parent takes presedence</title>
|
||||
|
||||
<style>
|
||||
#parent { display: none }
|
||||
#child { dipslay: block }
|
||||
</style>
|
||||
|
||||
<div id="parent">
|
||||
<div id="child">
|
||||
hidden
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset='utf-8'>
|
||||
<title>display: none;</title>
|
||||
|
||||
<style>
|
||||
p {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<p>This element is not visible.</p>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Element outside viewport</title>
|
||||
|
||||
<style>
|
||||
div { position: absolute }
|
||||
</style>
|
||||
|
||||
<div>hidden</div>
|
||||
|
||||
<script>
|
||||
var el = document.getElementsByTagName("div")[0];
|
||||
el.style.top = "-500px";
|
||||
el.style.left = "-500px";
|
||||
</script>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Element hidden by other element</title>
|
||||
|
||||
<style>
|
||||
div {
|
||||
position: absolute;
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
#overlay {
|
||||
background: blue;
|
||||
}
|
||||
|
||||
#hidden { background: red }
|
||||
</style>
|
||||
|
||||
<div id="hidden"></div>
|
||||
<div id="overlay"></div>
|
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Element hidden by z-index</title>
|
||||
|
||||
<style>
|
||||
* { position: relative }
|
||||
|
||||
#overlay,
|
||||
#hidden {
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
#overlay {
|
||||
background: blue;
|
||||
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
#hidden {
|
||||
background: red;
|
||||
top: -50px;
|
||||
|
||||
z-index: -1;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="overlay"></div>
|
||||
<div id="hidden"></div>
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Element moved behind other element by transform</title>
|
||||
|
||||
<style>
|
||||
* { position: relative }
|
||||
|
||||
#overlay {
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
background: blue;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
#hidden {
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
background: red;
|
||||
z-index: -1;
|
||||
|
||||
transform: translate(0, -50px);
|
||||
|
||||
/* fix your browsers god damnit */
|
||||
-webkit-transform: translate(0, -50px);
|
||||
-moz-transform: translate(0x, -50px);
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="overlay"></div>
|
||||
<div id="hidden"></div>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Element moved outside viewpor by transform</title>
|
||||
|
||||
<style>
|
||||
div {
|
||||
transform: translate(-200px, -200px);
|
||||
|
||||
/* fix your browsers god damnit */
|
||||
-webkit-transform: translate(-200px, -200px);
|
||||
-moz-transform: translate(-200px, -200px);
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>Cheddar!</div>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Element outside viewport</title>
|
||||
|
||||
<style>
|
||||
div {
|
||||
position: absolute;
|
||||
top: -500px;
|
||||
left: -500px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>hidden</div>
|
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Element partially hidden by other element</title>
|
||||
|
||||
<style>
|
||||
div {
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
#partial {
|
||||
background: yellow;
|
||||
}
|
||||
|
||||
#other {
|
||||
background: blue;
|
||||
margin-top: -50px;
|
||||
margin-left: 50px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="partial"></div>
|
||||
<div id="other"></div>
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Element with color style attribute</title>
|
||||
|
||||
<div style="color: red"> </div>
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Element with custom attribute</title>
|
||||
|
||||
<div webdriver-custom-attribute="attribute value"> </div>
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Element with id attribute</title>
|
||||
|
||||
<div id="myId"> </div>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Element with same color as background</title>
|
||||
|
||||
<style>
|
||||
body, div { background: white }
|
||||
div { width: 50px; height: 50px; }
|
||||
</style>
|
||||
|
||||
<div> </div>
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Element with same color as background</title>
|
||||
|
||||
<style>
|
||||
#overlay,
|
||||
#hidden {
|
||||
background: blue;
|
||||
width: 50px; height: 50px;
|
||||
}
|
||||
|
||||
#hidden {
|
||||
margin-top: -50px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="overlay"></div>
|
||||
<div id="hidden"></div>
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Element with style attribute</title>
|
||||
|
||||
<div style='font-family: "Gill Sans Extrabold", Helvetica, sans-serif; line-height: 1.2; font-weight:bold'> </div>
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Element without attribute</title>
|
||||
|
||||
<div> </div>
|
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Hidden INPUT @type="checkbox" is untogglable</title>
|
||||
|
||||
<style>
|
||||
input { display: none }
|
||||
</style>
|
||||
|
||||
<input type="checkbox" />
|
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Typing in hidden input is impossible</title>
|
||||
|
||||
<style>
|
||||
input { display: none }
|
||||
</style>
|
||||
|
||||
<input type="text" />
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<div id='singleHidden' hidden>This will not be visible</div>
|
||||
<div id='parent' hidden>
|
||||
<div id='child'>My parent is hidden so you can't see me</div>
|
||||
</div>
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>"img" element with not fully qualified url</title>
|
||||
|
||||
<img src="//web-platform.test:8000/images/blue.png"> </a>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>INPUT motphs into @type="hidden"</title>
|
||||
|
||||
<input />
|
||||
|
||||
<script>
|
||||
var input = document.getElementsByTagName("input")[0];
|
||||
input.type = "hidden";
|
||||
</script>
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>INPUT @type="hidden" is unclickable</title>
|
||||
|
||||
<input type="hidden" />
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>INPUT @type="hidden" are always hidden</title>
|
||||
|
||||
<input type="hidden" />
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Input with checked attribute</title>
|
||||
|
||||
<input type=checkbox checked="false"> </input>
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Input without checked attribute</title>
|
||||
|
||||
<input type=checkbox> </input>
|
|
@ -0,0 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Option with value attribute</title>
|
||||
|
||||
<select>
|
||||
<option value="value1">Value 1</option>
|
||||
</select>
|
|
@ -0,0 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Option without value attribute</title>
|
||||
|
||||
<select>
|
||||
<option>Value 1</option>
|
||||
</select>
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Text with matching color and background</title>
|
||||
|
||||
<style>
|
||||
p {
|
||||
background: blue;
|
||||
color: blue;
|
||||
}
|
||||
</style>
|
||||
|
||||
<p>
|
||||
This on the other hand, should be visible
|
||||
</p>
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Text with same color as background</title>
|
||||
|
||||
<style>
|
||||
body { background: white }
|
||||
p { color: white }
|
||||
</style>
|
||||
|
||||
<p>
|
||||
Shouldn't be visible.
|
||||
</p>
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Text with same color as parent background</title>
|
||||
|
||||
<style>
|
||||
#parent { background: gray }
|
||||
p { color: gray }
|
||||
</style>
|
||||
|
||||
<div id="parent">
|
||||
<p>
|
||||
Should not be visible
|
||||
</p>
|
||||
</div>g
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>visibility: hidden applies to child node of type A</title>
|
||||
|
||||
<style>
|
||||
#parent { visibility: hidden }
|
||||
</style>
|
||||
|
||||
<div id="parent">
|
||||
<a id="child" href="#">Brie is good</a>
|
||||
</div>
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>visibility: hidden applies to child nodes of type P</title>
|
||||
|
||||
<style>
|
||||
#parent { visibility: hidden }
|
||||
</style>
|
||||
|
||||
<div id="parent">
|
||||
<p id="child">Brie is good</p>
|
||||
</div>
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>visibility: visible on child node takes presedence</title>
|
||||
|
||||
<style>
|
||||
#parent { visibility: hidden }
|
||||
#child { visibility: visible }
|
||||
</style>
|
||||
|
||||
<div id="parent">
|
||||
<div id="child">Brie is good</div>
|
||||
</div>
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>visibility: hidden applies to child nodes</title>
|
||||
|
||||
<style>
|
||||
#parent { visibility: hidden }
|
||||
</style>
|
||||
|
||||
<div id="parent">
|
||||
<div id="child">Brie is good</div>
|
||||
</div>
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset='utf-8'>
|
||||
<title>visibility: hidden;</title>
|
||||
|
||||
<style>
|
||||
p {
|
||||
visibility: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<p>This element is not visible.</p>
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset='utf-8'>
|
||||
<title>visibility: visible;</title>
|
||||
|
||||
<p>This element is visible.</p>
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Page with overflow</title>
|
||||
<style>
|
||||
#over {
|
||||
width:400px;
|
||||
height: 300px;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="over">
|
||||
<div style="width: 5000px;">
|
||||
<div style="width: 100%; text-align: right;" ><a href="#" id="right" onclick="document.getElementById('right-clicked').innerText='ok'">Click right</a></div>
|
||||
</div>
|
||||
<div style="height: 5000px; width: 5000px;">
|
||||
Right clicked: <span id="right-clicked"></span></br>
|
||||
Bottom clicked: <span id="bottom-clicked"></span></br>
|
||||
Bottom-right clicked: <span id="bottom-right-clicked"></span></br>
|
||||
</div>
|
||||
<div style="width: 5000px;">
|
||||
<div style="width: 100%; text-align: right;" ><a href="#" id="bottom-right" onclick="document.getElementById('bottom-right-clicked').innerText='ok'">Click bottom-right</a></div>
|
||||
</div>
|
||||
<a href="#" id="bottom" onclick="document.getElementById('bottom-clicked').innerText='ok'">Click bottom</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Page with overflow</title>
|
||||
<style>
|
||||
#over {
|
||||
width:400px;
|
||||
height: 300px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="over">
|
||||
<div style="width: 5000px;">
|
||||
<div style="width: 100%; text-align: right;" ><a href="#" id="right" onclick="document.getElementById('right-clicked').innerText='ok'">Click right</a></div>
|
||||
</div>
|
||||
<div style="height: 5000px; width: 5000px;">
|
||||
Right clicked: <span id="right-clicked"></span></br>
|
||||
Bottom clicked: <span id="bottom-clicked"></span></br>
|
||||
Bottom-right clicked: <span id="bottom-right-clicked"></span></br>
|
||||
</div>
|
||||
<div style="width: 5000px;">
|
||||
<div style="width: 100%; text-align: right;" ><a href="#" id="bottom-right" onclick="document.getElementById('bottom-right-clicked').innerText='ok'">Click bottom-right</a></div>
|
||||
</div>
|
||||
<a href="#" id="bottom" onclick="document.getElementById('bottom-clicked').innerText='ok'">Click bottom</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Page with overflow</title>
|
||||
<style>
|
||||
#over {
|
||||
width:400px;
|
||||
height: 300px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="over">
|
||||
<div style="width: 5000px;">
|
||||
<div style="width: 100%; text-align: right;" ><a href="#" id="right" onclick="document.getElementById('right-clicked').innerText='ok'">Click right</a></div>
|
||||
</div>
|
||||
<div style="height: 5000px; width: 5000px;">
|
||||
Right clicked: <span id="right-clicked"></span></br>
|
||||
Bottom clicked: <span id="bottom-clicked"></span></br>
|
||||
Bottom-right clicked: <span id="bottom-right-clicked"></span></br>
|
||||
</div>
|
||||
<div style="width: 5000px;">
|
||||
<div style="width: 100%; text-align: right;" ><a href="#" id="bottom-right" onclick="document.getElementById('bottom-right-clicked').innerText='ok'">Click bottom-right</a></div>
|
||||
</div>
|
||||
<a href="#" id="bottom" onclick="document.getElementById('bottom-clicked').innerText='ok'">Click bottom</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Page with overflow</title>
|
||||
<style>
|
||||
#over {
|
||||
width:400px;
|
||||
height: 300px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="over">
|
||||
<div style="width: 5000px;">
|
||||
<div style="width: 100%; text-align: right;" ><a href="#" id="right" onclick="document.getElementById('right-clicked').innerText='ok'">Click right</a></div>
|
||||
</div>
|
||||
<div style="height: 5000px; width: 5000px;">
|
||||
Right clicked: <span id="right-clicked"></span></br>
|
||||
Bottom clicked: <span id="bottom-clicked"></span></br>
|
||||
Bottom-right clicked: <span id="bottom-right-clicked"></span></br>
|
||||
</div>
|
||||
<div style="width: 5000px;">
|
||||
<div style="width: 100%; text-align: right;" ><a href="#" id="bottom-right" onclick="document.getElementById('bottom-right-clicked').innerText='ok'">Click bottom-right</a></div>
|
||||
</div>
|
||||
<a href="#" id="bottom" onclick="document.getElementById('bottom-clicked').innerText='ok'">Click bottom</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Page with overflow</title>
|
||||
<style>
|
||||
#over {
|
||||
width:400px;
|
||||
height: 300px;
|
||||
overflow-x: scroll;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="over">
|
||||
<div style="width: 5000px;">
|
||||
<div style="width: 100%; text-align: right;" ><a href="#" id="right" onclick="document.getElementById('right-clicked').innerText='ok'">Click right</a></div>
|
||||
</div>
|
||||
<div style="height: 5000px; width: 5000px;">
|
||||
Right clicked: <span id="right-clicked"></span></br>
|
||||
Bottom clicked: <span id="bottom-clicked"></span></br>
|
||||
Bottom-right clicked: <span id="bottom-right-clicked"></span></br>
|
||||
</div>
|
||||
<div style="width: 5000px;">
|
||||
<div style="width: 100%; text-align: right;" ><a href="#" id="bottom-right" onclick="document.getElementById('bottom-right-clicked').innerText='ok'">Click bottom-right</a></div>
|
||||
</div>
|
||||
<a href="#" id="bottom" onclick="document.getElementById('bottom-clicked').innerText='ok'">Click bottom</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Zero sized element with sizable decendant</title>
|
||||
|
||||
<style>
|
||||
#parent { width: 0; height: 0; }
|
||||
#child { width: 100; height: 100; background-color: blue; }
|
||||
</style>
|
||||
|
||||
<div id="parent">
|
||||
<div id="child">
|
||||
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,324 @@
|
|||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
from webdriver import exceptions
|
||||
|
||||
|
||||
class NaturalNonVisibleElementsTest(base_test.WebDriverBaseTest):
|
||||
def test_0x0_pixel_element_is_not_visible(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/0x0-pixels.html"))
|
||||
el = self.driver.find_element_by_css("div")
|
||||
self.assertFalse(el.is_displayed())
|
||||
|
||||
def test_0x0_pixel_text_node_is_visible(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/0x0-pixels-text-node.html"))
|
||||
el = self.driver.find_element_by_css("p")
|
||||
self.assertTrue(el.is_displayed())
|
||||
|
||||
def test_1x1_pixel_element(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/1x1-pixels.html"))
|
||||
el = self.driver.find_element_by_css("p")
|
||||
self.assertTrue(el.is_displayed())
|
||||
|
||||
def test_zero_sized_element_is_shown_if_decendant_has_size(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/zero-sized-element-with-sizable-decendant.html"))
|
||||
parent = self.driver.find_element_by_css("#parent")
|
||||
child = self.driver.find_element_by_css("#child")
|
||||
|
||||
self.assertTrue(parent.is_displayed())
|
||||
self.assertTrue(child.is_displayed())
|
||||
|
||||
def test_input_type_hidden_is_never_visible(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/input-type-hidden.html"))
|
||||
input = self.driver.find_element_by_css("input")
|
||||
self.assertFalse(input.is_displayed())
|
||||
|
||||
def test_input_morphs_into_hidden(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/input-morphs-into-hidden.html"))
|
||||
input = self.driver.find_element_by_css("input")
|
||||
self.assertFalse(input.is_displayed())
|
||||
|
||||
def test_parent_node_visible_when_all_children_are_absolutely_positioned_and_overflow_is_hidden(self):
|
||||
pass
|
||||
|
||||
def test_parent_of_absolutely_positioned_elements_visible_where_ancestor_overflow_is_hidden(self):
|
||||
"""When a parent's ancestor hides any overflow, absolutely positioned child elements are
|
||||
still visible. The parent container is also considered visible by webdriver for this
|
||||
reason because it is interactable."""
|
||||
|
||||
self.driver.get(self.webserver.where_is("element_state/res/absolute-children-ancestor-hidden-overflow.html"))
|
||||
|
||||
children = self.driver.find_elements_by_css(".child")
|
||||
assert all(child.is_displayed() for child in children)
|
||||
|
||||
parent = self.driver.find_element_by_css("#parent")
|
||||
assert parent.is_displayed()
|
||||
|
||||
def test_element_hidden_by_overflow_x_is_not_visible(self):
|
||||
# TODO(andreastt): This test should probably be split in three. Also it's making two
|
||||
# assertions.
|
||||
pages = ["element_state/res/x-hidden-y-hidden.html",
|
||||
"element_state/res/x-hidden-y-scroll.html",
|
||||
"element_state/res/x-hidden-y-auto.html"]
|
||||
|
||||
for page in pages:
|
||||
self.driver.get(self.webserver.where_is(page))
|
||||
right = self.driver.find_element_by_css("#right")
|
||||
bottom_right = self.driver.find_element_by_css("#bottom-right")
|
||||
|
||||
self.assertFalse(right.is_displayed())
|
||||
self.assertFalse(bottom_right.is_displayed())
|
||||
|
||||
def test_element_hidden_by_overflow_y_is_not_visible(self):
|
||||
# TODO(andreastt): This test should probably be split in three. Also it's making two
|
||||
# assertions.
|
||||
pages = ["element_state/res/x-hidden-y-hidden.html",
|
||||
"element_state/res/x-scroll-y-hidden.html",
|
||||
"element_state/res/x-auto-y-hidden.html"]
|
||||
|
||||
for page in pages:
|
||||
self.driver.get(self.webserver.where_is(page))
|
||||
bottom = self.driver.find_element_by_css("#bottom")
|
||||
bottom_right = self.driver.find_element_by_css("#bottom-right")
|
||||
|
||||
self.assertFalse(bottom.is_displayed())
|
||||
self.assertFalse(bottom_right.is_displayed())
|
||||
|
||||
def test_parent_node_visible_when_all_children_are_absolutely_position_and_overflow_is_hidden(self):
|
||||
pass
|
||||
|
||||
def test_element_scrollable_by_overflow_x_is_visible(self):
|
||||
pass
|
||||
|
||||
def test_element_scrollable_by_overflow_y_is_visible(self):
|
||||
pass
|
||||
|
||||
def test_element_scrollable_by_overflow_x_and_y_is_visible(self):
|
||||
pass
|
||||
|
||||
def test_element_scrollable_by_overflow_y_is_visible(self):
|
||||
pass
|
||||
|
||||
def test_element_outside_viewport(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-outside-viewport.html"))
|
||||
hidden = self.driver.find_element_by_css("div")
|
||||
self.assertFalse(hidden.is_displayed())
|
||||
|
||||
def test_element_dynamically_moved_outside_viewport(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-dynamically-moved-outside-viewport.html"))
|
||||
hidden = self.driver.find_element_by_css("div")
|
||||
self.assertFalse(hidden.is_displayed())
|
||||
|
||||
def test_element_hidden_by_other_element(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-hidden-by-other-element.html"))
|
||||
overlay = self.driver.find_element_by_css("#overlay")
|
||||
hidden = self.driver.find_element_by_css("#hidden")
|
||||
|
||||
self.assertTrue(overlay.is_displayed())
|
||||
self.assertFalse(hidden.is_displayed())
|
||||
|
||||
def test_element_partially_hidden_by_other_element(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-partially-hidden-by-other-element.html"))
|
||||
partial = self.driver.find_element_by_css("#partial")
|
||||
self.assertTrue(partial.is_displayed())
|
||||
|
||||
def test_element_hidden_by_z_index(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-hidden-by-z-index.html"))
|
||||
overlay = self.driver.find_element_by_css("#overlay")
|
||||
hidden = self.driver.find_element_by_css("#hidden")
|
||||
|
||||
self.assertTrue(overlay.is_displayed())
|
||||
self.assertFalse(hidden.is_displayed())
|
||||
|
||||
def test_element_moved_outside_viewport_by_transform(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-moved-outside-viewport-by-transform.html"))
|
||||
el = self.driver.find_element_by_css("div")
|
||||
self.assertFalse(el.is_displayed())
|
||||
|
||||
def test_element_moved_behind_other_element_by_transform(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-moved-behind-other-element-by-transform.html"))
|
||||
overlay = self.driver.find_element_by_css("#overlay")
|
||||
hidden = self.driver.find_element_by_css("#hidden")
|
||||
|
||||
self.assertTrue(overlay.is_displayed())
|
||||
self.assertFalse(hidden.is_displayed())
|
||||
|
||||
def test_text_with_same_color_as_background(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/text-with-same-color-as-background.html"))
|
||||
p = self.driver.find_element_by_css("p")
|
||||
self.assertFalse(p.is_displayed())
|
||||
|
||||
def test_text_with_same_color_as_parent_background(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/text-with-same-color-as-parent-background.html"))
|
||||
p = self.driver.find_element_by_css("p")
|
||||
self.assertFalse(p.is_displayed())
|
||||
|
||||
def test_text_with_matching_color_and_background(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/text-with-matching-color-and-background.html"))
|
||||
p = self.driver.find_element_by_css("p")
|
||||
self.assertTrue(p.is_displayed())
|
||||
|
||||
def test_element_with_same_color_as_background(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-with-same-color-as-background.html"))
|
||||
el = self.driver.find_element_by_css("div")
|
||||
self.assertFalse(el.is_displayed())
|
||||
|
||||
def test_element_with_same_color_as_parent_background(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-with-same-color-as-parent-background.html"))
|
||||
hidden = self.driver.find_element_by_css("#hidden")
|
||||
self.assertFalse(hidden.is_displayed())
|
||||
|
||||
|
||||
class BodyElementIsAlwaysDisplayedTest(base_test.WebDriverBaseTest):
|
||||
def assert_body_is_displayed_on(self, page):
|
||||
self.driver.get(self.webserver.where_is(page))
|
||||
body = self.driver.find_element_by_css("body")
|
||||
assert body.is_displayed()
|
||||
|
||||
def test_implicit(self):
|
||||
self.assert_body_is_displayed_on("element_state/res/body_implicit.html")
|
||||
|
||||
def test_empty(self):
|
||||
self.assert_body_is_displayed_on("element_state/res/body_empty.html")
|
||||
|
||||
def test_visibility_hidden(self):
|
||||
self.assert_body_is_displayed_on("element_state/res/body_visibility_hidden.html")
|
||||
|
||||
def test_overflow_hidden(self):
|
||||
self.assert_body_is_displayed_on("element_state/res/body_overflow_hidden.html")
|
||||
|
||||
|
||||
class DisplayTest(base_test.WebDriverBaseTest):
|
||||
def test_display_block(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/display-block.html"))
|
||||
el = self.driver.find_element_by_css("p")
|
||||
self.assertTrue(el.is_displayed())
|
||||
|
||||
def test_display_none(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/display-none.html"))
|
||||
el = self.driver.find_element_by_css("p")
|
||||
self.assertFalse(el.is_displayed())
|
||||
|
||||
def test_display_none_hides_child_node(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/display-none-child.html"))
|
||||
parent = self.driver.find_element_by_css("#parent")
|
||||
child = self.driver.find_element_by_css("#child")
|
||||
|
||||
self.assertFalse(parent.is_displayed())
|
||||
self.assertFalse(child.is_displayed())
|
||||
|
||||
def test_display_none_hides_child_node_link(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/display-none-child-link.html"))
|
||||
child = self.driver.find_element_by_css("#child")
|
||||
self.assertFalse(child.is_displayed())
|
||||
|
||||
def test_display_none_hides_child_node_paragraph(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/display-none-child-paragraph.html"))
|
||||
child = self.driver.find_element_by_css("#child")
|
||||
self.assertFalse(child.is_displayed())
|
||||
|
||||
def test_display_none_on_parent_takes_presedence(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/display-none-parent-presedence.html"))
|
||||
child = self.driver.find_element_by_css("#child")
|
||||
self.assertFalse(child.is_displayed())
|
||||
|
||||
def test_display_none_on_parent_takes_presedence_over_visibility_visible(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/display-none-parent-presedence-visibility.html"))
|
||||
child = self.driver.find_element_by_css("#child")
|
||||
self.assertFalse(child.is_displayed())
|
||||
|
||||
def test_display_none_hidden_dynamically(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/display-none-dynamic.html"))
|
||||
hidden = self.driver.find_element_by_css("#hidden")
|
||||
self.assertFalse(hidden.is_displayed())
|
||||
|
||||
|
||||
class VisibilityTest(base_test.WebDriverBaseTest):
|
||||
def test_element_state_hidden(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/visibility-hidden.html"))
|
||||
el = self.driver.find_element_by_css("p")
|
||||
self.assertFalse(el.is_displayed())
|
||||
|
||||
def test_element_state_visible(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/visibility-visible.html"))
|
||||
el = self.driver.find_element_by_css("p")
|
||||
self.assertTrue(el.is_displayed())
|
||||
|
||||
def test_visibility_hidden_hides_child_node(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/visibility-child.html"))
|
||||
parent = self.driver.find_element_by_css("#parent")
|
||||
child = self.driver.find_element_by_css("#child")
|
||||
|
||||
self.assertFalse(parent.is_displayed())
|
||||
self.assertFalse(child.is_displayed())
|
||||
|
||||
def test_visibility_hidden_hides_child_node_link(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/visibility-child-link.html"))
|
||||
parent = self.driver.find_element_by_css("#parent")
|
||||
child = self.driver.find_element_by_css("#child")
|
||||
|
||||
self.assertFalse(parent.is_displayed())
|
||||
self.assertFalse(child.is_displayed())
|
||||
|
||||
def test_visibility_hidden_hides_child_node_paragraph(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/visibility-child-paragraph.html"))
|
||||
parent = self.driver.find_element_by_css("#parent")
|
||||
child = self.driver.find_element_by_css("#child")
|
||||
|
||||
self.assertFalse(parent.is_displayed())
|
||||
self.assertFalse(child.is_displayed())
|
||||
|
||||
def test_visibility_hidden_on_child_takes_precedence(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/visibility-child-presedence.html"))
|
||||
child = self.driver.find_element_by_css("#child")
|
||||
self.assertTrue(child.is_displayed())
|
||||
|
||||
def test_visibility_hidden_on_parent_takes_precedence_over_display_block(self):
|
||||
pass
|
||||
|
||||
def test_visibility_hidden_set_dynamically(self):
|
||||
pass
|
||||
|
||||
def test_should_show_element_not_visible_with_hidden_attribute(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/hidden.html"))
|
||||
singleHidden = self.driver.find_element_by_css('#singleHidden')
|
||||
self.assertFalse(singleHidden.is_displayed())
|
||||
|
||||
def test_should_show_element_not_visible_when_parent_element_has_hidden_attribute(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/hidden.html"))
|
||||
child = self.driver.find_element_by_css('#child')
|
||||
self.assertFalse(child.is_displayed())
|
||||
|
||||
|
||||
class VisibilityInteractionTest(base_test.WebDriverBaseTest):
|
||||
def test_input_hidden_is_unclickable(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/input-type-hidden-unclickable.html"))
|
||||
input = self.driver.find_element_by_css("input")
|
||||
|
||||
with self.assertRaises(exceptions.ElementNotVisibleException):
|
||||
input.click()
|
||||
|
||||
def test_hidden_input_checkbox_is_untogglable(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/hidden-input-type-checkbox-untogglable.html"))
|
||||
checkbox = self.driver.find_element_by_css("input")
|
||||
|
||||
with self.assertRaises(exceptions.ElementNotVisibleException):
|
||||
checkbox.click()
|
||||
|
||||
def test_typing_in_hidden_input_is_impossible(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/hidden-input-type-text-writing.html"))
|
||||
textfield = self.driver.find_element_by_css("input")
|
||||
|
||||
with self.assertRaises(exceptions.ElementNotVisibleException):
|
||||
textfield.send_keys("Koha is a popular Indian cheese")
|
||||
|
||||
|
||||
class OpacityTest(base_test.WebDriverBaseTest):
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
|
@ -0,0 +1,128 @@
|
|||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
|
||||
|
||||
class ExecuteScriptTest(base_test.WebDriverBaseTest):
|
||||
def test_ecmascript_translates_null_return_to_none(self):
|
||||
self.driver.get(self.webserver.where_is("javascript/res/execute_script_test.html"))
|
||||
result = self.driver.execute_script("return null;")
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_ecmascript_translates_undefined_return_to_none(self):
|
||||
self.driver.get(self.webserver.where_is("javascript/res/execute_script_test.html"))
|
||||
result = self.driver.execute_script("var undef; return undef;")
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_can_return_numbers_from_scripts(self):
|
||||
self.driver.get(self.webserver.where_is("javascript/res/execute_script_test.html"))
|
||||
self.assertEquals(1, self.driver.execute_script("return 1;"))
|
||||
self.assertEquals(3.14, self.driver.execute_script("return 3.14;"))
|
||||
|
||||
def test_can_return_strings_from_scripts(self):
|
||||
self.driver.get(self.webserver.where_is("javascript/res/execute_script_test.html"))
|
||||
self.assertEquals("hello, world!",
|
||||
self.driver.execute_script("return 'hello, world!'"))
|
||||
|
||||
def test_can_return_booleans_from_scripts(self):
|
||||
self.driver.get(self.webserver.where_is("javascript/res/execute_script_test.html"))
|
||||
self.assertTrue(self.driver.execute_script("return true;"))
|
||||
self.assertFalse(self.driver.execute_script("return false;"))
|
||||
|
||||
def test_can_return_an_array_of_primitives(self):
|
||||
self.driver.get(self.webserver.where_is("javascript/res/execute_script_test.html"))
|
||||
|
||||
result = self.driver.execute_script("return [1, false, null, 3.14]")
|
||||
self.assertListEqual([1, False, None, 3.14], result)
|
||||
|
||||
def test_can_return_nested_arrays(self):
|
||||
self.driver.get(self.webserver.where_is("javascript/res/execute_script_test.html"))
|
||||
result = self.driver.execute_script("return [[1, 2, [3]]]")
|
||||
|
||||
self.assertIsInstance(result, list)
|
||||
self.assertEquals(1, len(result))
|
||||
|
||||
result = result[0]
|
||||
self.assertListEqual([1, 2], result[:2])
|
||||
self.assertListEqual([3], result[2])
|
||||
|
||||
def test_can_return_object_literals(self):
|
||||
self.driver.get(self.webserver.where_is("javascript/res/execute_script_test.html"))
|
||||
|
||||
result = self.driver.execute_script("return {}")
|
||||
self.assertDictEqual({}, result)
|
||||
|
||||
result = self.driver.execute_script("return {a: 1, b: false, c: null}")
|
||||
self.assertDictEqual({
|
||||
"a": 1,
|
||||
"b": False,
|
||||
"c": None
|
||||
}, result)
|
||||
|
||||
def test_can_return_complex_object_literals(self):
|
||||
self.driver.get(self.webserver.where_is("javascript/res/execute_script_test.html"))
|
||||
result = self.driver.execute_script("return {a:{b: 'hello'}}")
|
||||
self.assertIsInstance(result, dict)
|
||||
self.assertIsInstance(result['a'], dict)
|
||||
self.assertDictEqual({"b": "hello"}, result["a"])
|
||||
|
||||
def test_dom_element_return_value_is_translated_to_a_web_element(self):
|
||||
self.driver.get(self.webserver.where_is(
|
||||
"javascript/res/return_document_body.html"))
|
||||
|
||||
result = self.driver.execute_script("return document.body")
|
||||
self.assertEquals(result.text, "Hello, world!")
|
||||
|
||||
def test_return_an_array_of_dom_elements(self):
|
||||
self.driver.get(self.webserver.where_is(
|
||||
"javascript/res/return_array_of_dom_elements.html"))
|
||||
|
||||
result = self.driver.execute_script(
|
||||
"var nodes = document.getElementsByTagName('div');"
|
||||
"return [nodes[0], nodes[1]]")
|
||||
|
||||
self.assertIsInstance(result, list)
|
||||
self.assertEquals(2, len(result))
|
||||
self.assertEquals("a", result[0].text)
|
||||
self.assertEquals("b", result[1].text)
|
||||
|
||||
def test_node_list_return_value_is_translated_to_list_of_web_elements(self):
|
||||
self.driver.get(self.webserver.where_is(
|
||||
"javascript/res/return_array_of_dom_elements.html"))
|
||||
|
||||
result = self.driver.execute_script(
|
||||
"return document.getElementsByTagName('div');")
|
||||
|
||||
self.assertIsInstance(result, list)
|
||||
self.assertEquals(2, len(result))
|
||||
self.assertEquals("a", result[0].text)
|
||||
self.assertEquals("b", result[1].text)
|
||||
|
||||
def test_return_object_literal_with_dom_element_property(self):
|
||||
self.driver.get(self.webserver.where_is("javascript/res/execute_script_test.html"))
|
||||
result = self.driver.execute_script("return {a: document.body}")
|
||||
self.assertIsInstance(result, dict)
|
||||
self.assertEquals("body", result["a"].tag_name)
|
||||
|
||||
def test_scripts_execute_in_anonymous_function_and_do_not_pollute_global_scope(self):
|
||||
self.driver.get(self.webserver.where_is("javascript/res/execute_script_test.html"))
|
||||
self.driver.execute_script("var x = 1;")
|
||||
self.assertEquals("undefined", self.driver.execute_script("return typeof x;"));
|
||||
|
||||
def test_scripts_can_modify_context_window_object(self):
|
||||
self.driver.get(self.webserver.where_is("javascript/res/execute_script_test.html"))
|
||||
self.driver.execute_script("window.x = 1;")
|
||||
self.assertEquals("number", self.driver.execute_script("return typeof x;"));
|
||||
self.assertEquals(1, self.driver.execute_script("return x;"));
|
||||
|
||||
def test_that_ecmascript_returns_document_title(self):
|
||||
self.driver.get(self.webserver.where_is("javascript/res/execute_script_test.html"))
|
||||
result = self.driver.execute_script("return document.title;")
|
||||
self.assertEquals("executeScript test", result)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<title>executeScript test</title>
|
|
@ -0,0 +1,3 @@
|
|||
<!DOCTYPE html>
|
||||
<div id="one">a</div>
|
||||
<div id="two">b</div>
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<div>Hello, world!</div>
|
|
@ -0,0 +1,3 @@
|
|||
<!DOCTYPE html>
|
||||
<div id="one">a</div>
|
||||
<div id="two">b</div>
|
0
tests/wpt/web-platform-tests/webdriver/modal/__init__.py
Normal file
0
tests/wpt/web-platform-tests/webdriver/modal/__init__.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
from webdriver import exceptions, wait
|
||||
|
||||
|
||||
class AlertsQuitTest(base_test.WebDriverBaseTest):
|
||||
def setUp(self):
|
||||
self.wait = wait.WebDriverWait(self.driver, 5, ignored_exceptions=[exceptions.NoSuchAlertException])
|
||||
self.driver.get(self.webserver.where_is('modal/res/alerts.html'))
|
||||
|
||||
def test_can_quit_when_an_alert_is_present(self):
|
||||
self.driver.find_element_by_css('#alert').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
self.driver.quit()
|
||||
with self.assertRaises(Exception):
|
||||
alert.accept()
|
||||
AlertsQuitTest.driver = None
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
147
tests/wpt/web-platform-tests/webdriver/modal/alerts_test.py
Normal file
147
tests/wpt/web-platform-tests/webdriver/modal/alerts_test.py
Normal file
|
@ -0,0 +1,147 @@
|
|||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
from webdriver import exceptions, wait
|
||||
|
||||
|
||||
class AlertsTest(base_test.WebDriverBaseTest):
|
||||
def setUp(self):
|
||||
self.wait = wait.WebDriverWait(self.driver, 5, ignored_exceptions = [exceptions.NoSuchAlertException])
|
||||
self.driver.get(self.webserver.where_is('modal/res/alerts.html'))
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
self.driver.switch_to_alert().dismiss()
|
||||
except exceptions.NoSuchAlertException:
|
||||
pass
|
||||
|
||||
# Alerts
|
||||
def test_should_allow_user_to_accept_an_alert(self):
|
||||
self.driver.find_element_by_css('#alert').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.accept()
|
||||
self.driver.get_current_url()
|
||||
|
||||
def test_should_allow_user_to_accept_an_alert_with_no_text(self):
|
||||
self.driver.find_element_by_css('#empty-alert').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.accept()
|
||||
self.driver.get_current_url()
|
||||
|
||||
def test_should_allow_user_to_dismiss_an_alert(self):
|
||||
self.driver.find_element_by_css('#alert').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.dismiss()
|
||||
self.driver.get_current_url()
|
||||
|
||||
def test_should_allow_user_to_get_text_of_an_alert(self):
|
||||
self.driver.find_element_by_css('#alert').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
self.assertEquals('cheese', value)
|
||||
|
||||
def test_setting_the_value_of_an_alert_throws(self):
|
||||
self.driver.find_element_by_css('#alert').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
with self.assertRaises(exceptions.ElementNotVisibleException):
|
||||
alert.send_keys('cheese')
|
||||
alert.accept()
|
||||
|
||||
def test_alert_should_not_allow_additional_commands_if_dismissed(self):
|
||||
self.driver.find_element_by_css('#alert').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.accept()
|
||||
with self.assertRaises(exceptions.NoSuchAlertException):
|
||||
alert.get_text()
|
||||
|
||||
# Prompts
|
||||
def test_should_allow_user_to_accept_a_prompt(self):
|
||||
self.driver.find_element_by_css('#prompt').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.accept()
|
||||
self.wait.until(lambda x: x.find_element_by_css('#text').text == '')
|
||||
|
||||
def test_should_allow_user_to_dismiss_a_prompt(self):
|
||||
self.driver.find_element_by_css('#prompt').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.dismiss()
|
||||
self.wait.until(lambda x: x.find_element_by_css('#text').text == 'null')
|
||||
|
||||
def test_should_allow_user_to_set_the_value_of_a_prompt(self):
|
||||
self.driver.find_element_by_css('#prompt').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.send_keys('cheese')
|
||||
alert.accept()
|
||||
self.wait.until(lambda x: x.find_element_by_css('#text').text == 'cheese')
|
||||
|
||||
def test_should_allow_user_to_get_text_of_a_prompt(self):
|
||||
self.driver.find_element_by_css('#prompt').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
self.assertEquals('Enter something', value)
|
||||
|
||||
def test_prompt_should_not_allow_additional_commands_if_dismissed(self):
|
||||
self.driver.find_element_by_css('#prompt').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.accept()
|
||||
with self.assertRaises(exceptions.NoSuchAlertException):
|
||||
alert.get_text()
|
||||
|
||||
def test_prompt_should_use_default_value_if_no_keys_sent(self):
|
||||
self.driver.find_element_by_css('#prompt-with-default').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.accept()
|
||||
self.wait.until(lambda x: x.find_element_by_css('#text').text == 'This is a default value')
|
||||
|
||||
def test_prompt_should_have_null_value_if_dismissed(self):
|
||||
self.driver.find_element_by_css('#prompt-with-default').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.dismiss()
|
||||
self.wait.until(lambda x: x.find_element_by_css('#text').text == 'null')
|
||||
|
||||
# Confirmations
|
||||
def test_should_allow_user_to_accept_a_confirm(self):
|
||||
self.driver.find_element_by_css('#confirm').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.accept()
|
||||
self.wait.until(lambda x: x.find_element_by_css('#text').text == 'true')
|
||||
|
||||
def test_should_allow_user_to_dismiss_a_confirm(self):
|
||||
self.driver.find_element_by_css('#confirm').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.dismiss()
|
||||
self.wait.until(lambda x: x.find_element_by_css('#text').text == 'false')
|
||||
|
||||
def test_setting_the_value_of_a_confirm_throws(self):
|
||||
self.driver.find_element_by_css('#confirm').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
with self.assertRaises(exceptions.ElementNotVisibleException):
|
||||
alert.send_keys('cheese')
|
||||
alert.accept()
|
||||
|
||||
def test_should_allow_user_to_get_text_of_a_confirm(self):
|
||||
self.driver.find_element_by_css('#confirm').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
self.assertEquals('cheese', value)
|
||||
|
||||
def test_confirm_should_not_allow_additional_commands_if_dismissed(self):
|
||||
self.driver.find_element_by_css('#confirm').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.accept()
|
||||
with self.assertRaises(exceptions.NoSuchAlertException):
|
||||
alert.get_text()
|
||||
|
||||
def test_switch_to_missing_alert_fails(self):
|
||||
with self.assertRaises(exceptions.NoSuchAlertException):
|
||||
self.driver.switch_to_alert()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
53
tests/wpt/web-platform-tests/webdriver/modal/res/alerts.html
Normal file
53
tests/wpt/web-platform-tests/webdriver/modal/res/alerts.html
Normal file
|
@ -0,0 +1,53 @@
|
|||
<html>
|
||||
<!-- Padding to account for small screens of mobile devices -->
|
||||
<style>
|
||||
p {margin-top:48px;}
|
||||
</style>
|
||||
<head>
|
||||
<title>Testing Alerts</title>
|
||||
|
||||
<script type="text/javascript">
|
||||
function setInnerText(id, value) {
|
||||
document.getElementById(id).innerHTML = '<p>' + value + '</p>';
|
||||
}
|
||||
|
||||
function displayPrompt() {
|
||||
setInnerText('text', prompt('Enter something'));
|
||||
}
|
||||
|
||||
function displayPromptWithDefault() {
|
||||
setInnerText('text', prompt('Enter something', 'This is a default value'));
|
||||
}
|
||||
|
||||
function displayTwoPrompts() {
|
||||
setInnerText('text1', prompt('First'));
|
||||
setInnerText('text2', prompt('Second'));
|
||||
}
|
||||
|
||||
function displayConfirm() {
|
||||
setInnerText('text', confirm('cheese'));
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Testing Alerts and Stuff</h1>
|
||||
|
||||
<p>This tests alerts: <a href="#" id="alert" onclick="alert('cheese');">click me</a></p>
|
||||
|
||||
<p>This tests alerts: <a href="#" id="empty-alert" onclick="alert('');">click me</a></p>
|
||||
|
||||
<p>Let's make the <a href="#" id="prompt" onclick="displayPrompt();">prompt happen</a></p>
|
||||
|
||||
<p>Let's make the <a href="#" id="prompt-with-default" onclick="displayPromptWithDefault();">prompt with default happen</a></p>
|
||||
|
||||
<p>Let's make TWO <a href="#" id="double-prompt" onclick="displayTwoPrompts();">prompts happen</a></p>
|
||||
|
||||
<p>This tests confirm: <a href="#" id="confirm" onclick="displayConfirm();">test confirm</a></p>
|
||||
|
||||
<div id="text"></div>
|
||||
<div id="text1"></div>
|
||||
<div id="text2"></div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,42 @@
|
|||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import ConfigParser
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
from webdriver import exceptions
|
||||
from wptserve import server
|
||||
from wptserve.router import any_method
|
||||
from wptserve.handlers import basic_auth_handler
|
||||
|
||||
class WebDriverAuthTest(unittest.TestCase):
|
||||
|
||||
# Set up class to start HTTP Server that responds to
|
||||
# test URLs with various 401 responses
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.driver = base_test.create_driver()
|
||||
cls.webserver = server.WebTestHttpd(routes=[(any_method, "*", basic_auth_handler)])
|
||||
cls.webserver.start()
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.driver.quit()
|
||||
cls.webserver.stop()
|
||||
|
||||
# Test that when 401 is seen by browser, a WebDriver response is still sent
|
||||
def test_response_401_auth_basic(self):
|
||||
page = self.webserver.get_url('navigation/res/authenticated.html')
|
||||
self.driver.set_page_load_timeout(5)
|
||||
try:
|
||||
self.driver.get( page )
|
||||
# if we got a responses instead of timeout, that's success
|
||||
self.assertTrue(True)
|
||||
except exceptions.TimeoutException:
|
||||
self.fail("Did not get response from browser.")
|
||||
except:
|
||||
self.fail("Unexpected failure. Please investigate.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
24
tests/wpt/web-platform-tests/webdriver/navigation/forward.py
Normal file
24
tests/wpt/web-platform-tests/webdriver/navigation/forward.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
import unittest
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
|
||||
|
||||
class ForwardTest(base_test.WebDriverBaseTest):
|
||||
# Get a static page that must be the same upon refresh
|
||||
def test_forward(self):
|
||||
self.driver.get(self.webserver.where_is('navigation/res/forwardStart.html'))
|
||||
self.driver.get(self.webserver.where_is('navigation/res/forwardNext.html'))
|
||||
nextbody = self.driver.find_element_by_css("body").text
|
||||
self.driver.go_back()
|
||||
currbody = self.driver.find_element_by_css("body").text
|
||||
self.assertNotEqual(nextbody, currbody)
|
||||
self.driver.go_forward()
|
||||
currbody = self.driver.find_element_by_css("body").text
|
||||
self.assertEqual(nextbody, currbody)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -0,0 +1,20 @@
|
|||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
|
||||
|
||||
class ForwardToNothingTest(base_test.WebDriverBaseTest):
|
||||
# Get a static page that must be the same upon refresh
|
||||
def test_forwardToNothing(self):
|
||||
self.driver.get(self.webserver.where_is('navigation/forwardStart.html'))
|
||||
body = self.driver.find_element_by_css("body").text
|
||||
self.driver.go_forward()
|
||||
currbody = self.driver.find_element_by_css("body").text
|
||||
self.assertEqual(body, currbody)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -0,0 +1,60 @@
|
|||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
|
||||
|
||||
class GetFromHttpTest(base_test.WebDriverBaseTest):
|
||||
def testGetUrlWithNoRedirectionOverHttp(self):
|
||||
page = self.webserver.where_is('navigation/res/empty.html')
|
||||
self.driver.get(page)
|
||||
url = self.driver.get_current_url()
|
||||
self.assertEquals(page, url)
|
||||
|
||||
|
||||
def testGetWillFollowTheLocationHeader(self):
|
||||
page = self.webserver.where_is('navigation/redirect')
|
||||
self.driver.get(page)
|
||||
expected = self.webserver.where_is('navigation/res/empty.html')
|
||||
url = self.driver.get_current_url()
|
||||
self.assertEquals(expected, url)
|
||||
|
||||
|
||||
def testGetWillFollowMetaRefreshThatRefreshesInstantly(self):
|
||||
page = self.webserver.where_is('navigation/res/instant-meta-redirect.html')
|
||||
self.driver.get(page)
|
||||
expected = self.webserver.where_is('navigation/res/empty.html')
|
||||
url = self.driver.get_current_url()
|
||||
self.assertEquals(expected, url)
|
||||
|
||||
|
||||
def testGetWillFollowMetaRefreshThatRefreshesAfterOneSecond(self):
|
||||
page = self.webserver.where_is('navigation/res/1s-meta-redirect.html')
|
||||
self.driver.get(page)
|
||||
expected = self.webserver.where_is('navigation/res/empty.html')
|
||||
url = self.driver.get_current_url()
|
||||
self.assertEquals(expected, url)
|
||||
|
||||
|
||||
def testGetWillNotFollowMetaRefreshThatRefreshesAfterMoreThanOneSecond(self):
|
||||
page = self.webserver.where_is('navigation/res/60s-meta-redirect.html')
|
||||
self.driver.get(page)
|
||||
url = self.driver.get_current_url()
|
||||
self.assertEquals(page, url)
|
||||
|
||||
|
||||
def testGetFragmentInCurrentDocumentDoesNotReloadPage(self):
|
||||
page = self.webserver.where_is("navigation/res/fragment.html")
|
||||
fragment_page = "%s#%s" % (page, "fragment")
|
||||
|
||||
self.driver.get(page)
|
||||
self.driver.execute_script("state = true")
|
||||
|
||||
self.driver.get(fragment_page)
|
||||
self.assertEquals(True, self.driver.execute_script("return state"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -0,0 +1,28 @@
|
|||
import BaseHTTPServer
|
||||
import os
|
||||
import ssl
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
|
||||
|
||||
here = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class InvalidCertTest(base_test.WebDriverBaseTest):
|
||||
def testCanNavigateToSiteWithSelfSignedCert(self):
|
||||
self.webserver.httpd.socket = ssl.wrap_socket(
|
||||
self.webserver.httpd.socket,
|
||||
certfile=os.path.join(here, 'res/self-signed.key'),
|
||||
server_side=True)
|
||||
expected = self.webserver.where_is(
|
||||
'navigation/res/empty.html').replace('http:', 'https:', 1)
|
||||
|
||||
self.driver.get(expected)
|
||||
self.assertEquals(expected, self.driver.get_current_url())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -0,0 +1,27 @@
|
|||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
|
||||
|
||||
class RefreshPageTest(base_test.WebDriverBaseTest):
|
||||
# Get a static page that must be the same upon refresh
|
||||
def test_refreshPage(self):
|
||||
self.driver.get(self.webserver.where_is('navigation/res/refreshPageStatic.html'))
|
||||
body = self.driver.find_element_by_css("body").text
|
||||
self.driver.execute_script("document.getElementById('body').innerHTML=''")
|
||||
self.driver.refresh()
|
||||
newbody = self.driver.find_element_by_css("body").text
|
||||
self.assertEqual(body, newbody)
|
||||
|
||||
self.driver.get(self.webserver.where_is('navigation/res/refreshPageDynamic.html'))
|
||||
body = self.driver.find_element_by_css("body").text
|
||||
self.driver.refresh()
|
||||
newbody = self.driver.find_element_by_css("body").text
|
||||
self.assertNotEqual(body, newbody)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -0,0 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Refresh" content="1; URL=empty.html">
|
||||
<title>meta-redirect</title>
|
|
@ -0,0 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Refresh" content="60; URL=empty.html">
|
||||
<title>meta-redirect</title>
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>authentication successful</title>
|
||||
<h1>You're in!</h1>
|
|
@ -0,0 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>Cheese</title>
|
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<body id=body>
|
||||
This is the next page.
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<body>
|
||||
This is the start page.
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Fragment</title>
|
||||
|
||||
<script>
|
||||
var state = false;
|
||||
</script>
|
||||
|
||||
<p id="fragment">I wish I were a pea, alas I am only a fragment.</p>
|
|
@ -0,0 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Refresh" content="0; URL=empty.html">
|
||||
<title>meta-redirect</title>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<body id="body">
|
||||
This is a dynamic page. It will always have different content if refreshed.
|
||||
<div id="dynamic"></div>
|
||||
</body>
|
||||
</html>
|
||||
<script>
|
||||
document.getElementById('dynamic').innerHTML = Math.random();
|
||||
</script>
|
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<body id="body">
|
||||
This is a static page. It will always have the same content if refreshed.
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,28 @@
|
|||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXAIBAAKBgQDoww50sF8aKYNe1owbtsEilK2KOZx2F1Iv+EElpO7N2hDarIBu
|
||||
9f87H+03b5RpI9oCSFCo67wTdCJ0A4B8SLwV2SUZY78CGJB1A8kXqP04tz0S0SYD
|
||||
2TQRliwTxx1r7pDv1VmLc7XZRE6n6FFKTEjKmdUhCwHuQfC1sOkCXqSzFQIDAQAB
|
||||
AoGAS5XcAeSsXXCRqqB9SxqjyTkCydo/htG37L/vV+whaFOiGYDfDClyQp7xh4kC
|
||||
Zsovp4IYP2Kd5qtV7NqeRL3R5Z/Dxf6+6G4HdbI7np5m7A7cU32hMIzxi5M55Lo6
|
||||
gveNgHb3uy+R+tZTyab6saUxFy1DqbMh/2ga4lbatRm7JdkCQQD9C8+Q3nN8FkH4
|
||||
sKbOnHsKEV27459EYz7WnENiwhcYByBt7vw9BPM/LrO4UzWtgNjtRtxBpFeVT/V+
|
||||
dF7OZuH/AkEA63qhJcs6Ru3G29R3kJ82ttyHU1INawB/7od3bKp3rE+jUwNG7ZbQ
|
||||
mtRdPTI02/OOeqZKeo46JX3D57gfMRDC6wJABZk/TGs/jt1HNGNkLWoU5tIfisqs
|
||||
eWzgtQrcCtFUhXmS5BvHhOoZH6q+2zMsGtyg8A8DTIiAT5NnURbuCg8IrQJAd3kh
|
||||
d85zw/byFSjofPz6wq6DDngsDKUVQ42BvyWCUG+bewvHmdYSAuxKXjkx7oLVQE9M
|
||||
rH+q6sizc8bMNJW/fwJBAPcobQ59ZGAEWrnDdtbWnNS1ieSV8p6u7sg20HvrUIPS
|
||||
TIQXeems9IKu0xs0dnLXNucm4ur8MnE7snkvWZnx2C8=
|
||||
-----END RSA PRIVATE KEY-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICAzCCAWwCCQCc6Lx6zkc0BDANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJV
|
||||
UzETMBEGA1UECAwKQ2FsaWZvcm5pYTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0
|
||||
cyBQdHkgTHRkMCAXDTEzMDcxMjIyMzMxNVoYDzIyODcwNDI2MjIzMzE1WjBFMQsw
|
||||
CQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEhMB8GA1UECgwYSW50ZXJu
|
||||
ZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDo
|
||||
ww50sF8aKYNe1owbtsEilK2KOZx2F1Iv+EElpO7N2hDarIBu9f87H+03b5RpI9oC
|
||||
SFCo67wTdCJ0A4B8SLwV2SUZY78CGJB1A8kXqP04tz0S0SYD2TQRliwTxx1r7pDv
|
||||
1VmLc7XZRE6n6FFKTEjKmdUhCwHuQfC1sOkCXqSzFQIDAQABMA0GCSqGSIb3DQEB
|
||||
BQUAA4GBAD6atn+xbACigA9+EmcZo2bpAzxLAuXOAVEBM6J7Nrd8pk1D3PRP0QPg
|
||||
UxjIDQ7ZqEWwLAcKb6AIfWwJ2Wj7q5LSX5nEFnUXggpywfUNTuZaR/fquUVnhMaO
|
||||
tF8fQB9AYSa1WjqUbIKlns3Z2RhUv2DSEifi6UNjsf2UpmDTxtkN
|
||||
-----END CERTIFICATE-----
|
30
tests/wpt/web-platform-tests/webdriver/network.py
Normal file
30
tests/wpt/web-platform-tests/webdriver/network.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
# this comes from this stack overflow post:
|
||||
# http://stackoverflow.com/a/1947766/725944
|
||||
|
||||
# module for getting the lan ip address of the computer
|
||||
|
||||
import os
|
||||
import socket
|
||||
|
||||
if os.name != "nt":
|
||||
import fcntl
|
||||
import struct
|
||||
def get_interface_ip(ifname):
|
||||
sckt = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
return socket.inet_ntoa(fcntl.ioctl(
|
||||
sckt.fileno(),
|
||||
0x8915, # SIOCGIFADDR
|
||||
struct.pack('256s', ifname[:15])
|
||||
)[20:24])
|
||||
|
||||
def get_lan_ip():
|
||||
ip = socket.gethostbyname(socket.gethostname())
|
||||
if ip.startswith("127.") and os.name != "nt":
|
||||
interfaces = ["eth0","eth1","eth2","wlan0","wlan1","wifi0","ath0","ath1","ppp0"]
|
||||
for ifname in interfaces:
|
||||
try:
|
||||
ip = get_interface_ip(ifname)
|
||||
break
|
||||
except IOError:
|
||||
pass
|
||||
return ip
|
14
tests/wpt/web-platform-tests/webdriver/runtests.py
Normal file
14
tests/wpt/web-platform-tests/webdriver/runtests.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
import unittest
|
||||
|
||||
from unittest import TestLoader, TextTestRunner, TestSuite
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
loader = TestLoader()
|
||||
suite = TestSuite((
|
||||
loader.discover(".", pattern="*.py")
|
||||
))
|
||||
|
||||
runner = TextTestRunner(verbosity=2)
|
||||
runner.run(suite)
|
||||
unittest.main()
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue