mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1225032 - Update web-platform-tests to revision a5f15d6bdbeeec010465dc906e542873d64797ec, a=testonly
--HG-- rename : testing/web-platform/tests/dom/collections/storage-supported-property-names.html => testing/web-platform/tests/webstorage/storage_supported_property_names.html
This commit is contained in:
parent
5b496f6a84
commit
6d8a5cdbc6
@ -11161,6 +11161,14 @@
|
||||
"path": "IndexedDB/idbindex_get7.htm",
|
||||
"url": "/IndexedDB/idbindex_get7.htm"
|
||||
},
|
||||
{
|
||||
"path": "IndexedDB/idbindex_getAll.html",
|
||||
"url": "/IndexedDB/idbindex_getAll.html"
|
||||
},
|
||||
{
|
||||
"path": "IndexedDB/idbindex_getAllKeys.html",
|
||||
"url": "/IndexedDB/idbindex_getAllKeys.html"
|
||||
},
|
||||
{
|
||||
"path": "IndexedDB/idbindex_getKey.htm",
|
||||
"url": "/IndexedDB/idbindex_getKey.htm"
|
||||
@ -11425,6 +11433,14 @@
|
||||
"path": "IndexedDB/idbobjectstore_get7.htm",
|
||||
"url": "/IndexedDB/idbobjectstore_get7.htm"
|
||||
},
|
||||
{
|
||||
"path": "IndexedDB/idbobjectstore_getAll.html",
|
||||
"url": "/IndexedDB/idbobjectstore_getAll.html"
|
||||
},
|
||||
{
|
||||
"path": "IndexedDB/idbobjectstore_getAllKeys.html",
|
||||
"url": "/IndexedDB/idbobjectstore_getAllKeys.html"
|
||||
},
|
||||
{
|
||||
"path": "IndexedDB/idbobjectstore_index.htm",
|
||||
"url": "/IndexedDB/idbobjectstore_index.htm"
|
||||
@ -11437,6 +11453,10 @@
|
||||
"path": "IndexedDB/idbobjectstore_openCursor_invalid.htm",
|
||||
"url": "/IndexedDB/idbobjectstore_openCursor_invalid.htm"
|
||||
},
|
||||
{
|
||||
"path": "IndexedDB/idbobjectstore_openKeyCursor.htm",
|
||||
"url": "/IndexedDB/idbobjectstore_openKeyCursor.htm"
|
||||
},
|
||||
{
|
||||
"path": "IndexedDB/idbobjectstore_put.htm",
|
||||
"url": "/IndexedDB/idbobjectstore_put.htm"
|
||||
@ -11513,6 +11533,10 @@
|
||||
"path": "IndexedDB/idbtransaction_abort.htm",
|
||||
"url": "/IndexedDB/idbtransaction_abort.htm"
|
||||
},
|
||||
{
|
||||
"path": "IndexedDB/idbtransaction_objectStoreNames.html",
|
||||
"url": "/IndexedDB/idbtransaction_objectStoreNames.html"
|
||||
},
|
||||
{
|
||||
"path": "IndexedDB/idbversionchangeevent.htm",
|
||||
"url": "/IndexedDB/idbversionchangeevent.htm"
|
||||
@ -13282,8 +13306,12 @@
|
||||
"url": "/dom/collections/HTMLCollection-supported-property-names.html"
|
||||
},
|
||||
{
|
||||
"path": "dom/collections/storage-supported-property-names.html",
|
||||
"url": "/dom/collections/storage-supported-property-names.html"
|
||||
"path": "dom/collections/domstringmap-supported-property-names.html",
|
||||
"url": "/dom/collections/domstringmap-supported-property-names.html"
|
||||
},
|
||||
{
|
||||
"path": "dom/collections/namednodemap-supported-property-names.html",
|
||||
"url": "/dom/collections/namednodemap-supported-property-names.html"
|
||||
},
|
||||
{
|
||||
"path": "dom/events/Event-constants.html",
|
||||
@ -13709,6 +13737,10 @@
|
||||
"path": "dom/nodes/Element-getElementsByClassName.html",
|
||||
"url": "/dom/nodes/Element-getElementsByClassName.html"
|
||||
},
|
||||
{
|
||||
"path": "dom/nodes/Element-getElementsByTagName-change-document-HTMLNess.html",
|
||||
"url": "/dom/nodes/Element-getElementsByTagName-change-document-HTMLNess.html"
|
||||
},
|
||||
{
|
||||
"path": "dom/nodes/Element-getElementsByTagName.html",
|
||||
"url": "/dom/nodes/Element-getElementsByTagName.html"
|
||||
@ -13837,6 +13869,10 @@
|
||||
"path": "dom/nodes/Node-contains.html",
|
||||
"url": "/dom/nodes/Node-contains.html"
|
||||
},
|
||||
{
|
||||
"path": "dom/nodes/Node-contains.xml",
|
||||
"url": "/dom/nodes/Node-contains.xml"
|
||||
},
|
||||
{
|
||||
"path": "dom/nodes/Node-insertBefore.html",
|
||||
"url": "/dom/nodes/Node-insertBefore.html"
|
||||
@ -13973,6 +14009,14 @@
|
||||
"path": "dom/nodes/getElementsByClassName-09.htm",
|
||||
"url": "/dom/nodes/getElementsByClassName-09.htm"
|
||||
},
|
||||
{
|
||||
"path": "dom/nodes/getElementsByClassName-10.xml",
|
||||
"url": "/dom/nodes/getElementsByClassName-10.xml"
|
||||
},
|
||||
{
|
||||
"path": "dom/nodes/getElementsByClassName-11.xml",
|
||||
"url": "/dom/nodes/getElementsByClassName-11.xml"
|
||||
},
|
||||
{
|
||||
"path": "dom/nodes/getElementsByClassName-12.htm",
|
||||
"url": "/dom/nodes/getElementsByClassName-12.htm"
|
||||
@ -17909,6 +17953,10 @@
|
||||
"path": "html/semantics/forms/the-select-element/common-HTMLOptionsCollection.html",
|
||||
"url": "/html/semantics/forms/the-select-element/common-HTMLOptionsCollection.html"
|
||||
},
|
||||
{
|
||||
"path": "html/semantics/forms/the-select-element/select-ask-for-reset.html",
|
||||
"url": "/html/semantics/forms/the-select-element/select-ask-for-reset.html"
|
||||
},
|
||||
{
|
||||
"path": "html/semantics/forms/the-select-element/select-named-getter.html",
|
||||
"url": "/html/semantics/forms/the-select-element/select-named-getter.html"
|
||||
@ -18473,6 +18521,10 @@
|
||||
"path": "html/webappapis/animation-frames/callback-invoked.html",
|
||||
"url": "/html/webappapis/animation-frames/callback-invoked.html"
|
||||
},
|
||||
{
|
||||
"path": "html/webappapis/animation-frames/callback-multicalls.html",
|
||||
"url": "/html/webappapis/animation-frames/callback-multicalls.html"
|
||||
},
|
||||
{
|
||||
"path": "html/webappapis/animation-frames/cancel-invoked.html",
|
||||
"url": "/html/webappapis/animation-frames/cancel-invoked.html"
|
||||
@ -18497,6 +18549,10 @@
|
||||
"path": "html/webappapis/scripting/events/body-onload.html",
|
||||
"url": "/html/webappapis/scripting/events/body-onload.html"
|
||||
},
|
||||
{
|
||||
"path": "html/webappapis/scripting/events/event-handler-attributes-body-window.html",
|
||||
"url": "/html/webappapis/scripting/events/event-handler-attributes-body-window.html"
|
||||
},
|
||||
{
|
||||
"path": "html/webappapis/scripting/events/event-handler-javascript.html",
|
||||
"url": "/html/webappapis/scripting/events/event-handler-javascript.html"
|
||||
@ -26141,10 +26197,6 @@
|
||||
"path": "shadow-dom/untriaged/user-interaction/ranges-and-selections/test-002.html",
|
||||
"url": "/shadow-dom/untriaged/user-interaction/ranges-and-selections/test-002.html"
|
||||
},
|
||||
{
|
||||
"path": "subresource-integrity/subresource-integrity.html",
|
||||
"url": "/subresource-integrity/subresource-integrity.html"
|
||||
},
|
||||
{
|
||||
"path": "touch-events/create-touch-touchlist.html",
|
||||
"url": "/touch-events/create-touch-touchlist.html"
|
||||
@ -27617,6 +27669,10 @@
|
||||
"path": "webstorage/storage_string_conversion.html",
|
||||
"url": "/webstorage/storage_string_conversion.html"
|
||||
},
|
||||
{
|
||||
"path": "webstorage/storage_supported_property_names.html",
|
||||
"url": "/webstorage/storage_supported_property_names.html"
|
||||
},
|
||||
{
|
||||
"path": "webvtt/interfaces.html",
|
||||
"url": "/webvtt/interfaces.html"
|
||||
@ -29739,6 +29795,15 @@
|
||||
}
|
||||
],
|
||||
"wdspec": [
|
||||
{
|
||||
"path": "webdriver/command_contexts/open_and_close_window_test.py"
|
||||
},
|
||||
{
|
||||
"path": "webdriver/command_contexts/window_handle_test.py"
|
||||
},
|
||||
{
|
||||
"path": "webdriver/command_contexts/window_size_test.py"
|
||||
},
|
||||
{
|
||||
"path": "webdriver/cookie/cookie_test.py"
|
||||
},
|
||||
@ -29751,6 +29816,12 @@
|
||||
{
|
||||
"path": "webdriver/element_state/method_test.py"
|
||||
},
|
||||
{
|
||||
"path": "webdriver/element_state/properties.py"
|
||||
},
|
||||
{
|
||||
"path": "webdriver/element_state/selected_test.py"
|
||||
},
|
||||
{
|
||||
"path": "webdriver/element_state/visibility_test.py"
|
||||
},
|
||||
@ -29781,6 +29852,12 @@
|
||||
{
|
||||
"path": "webdriver/navigation/refresh-page.py"
|
||||
},
|
||||
{
|
||||
"path": "webdriver/navigation/refresh_page.py"
|
||||
},
|
||||
{
|
||||
"path": "webdriver/screenshot/take_screenshot.py"
|
||||
},
|
||||
{
|
||||
"path": "webdriver/timeouts/implicit_waits_tests.py"
|
||||
},
|
||||
@ -29789,21 +29866,24 @@
|
||||
},
|
||||
{
|
||||
"path": "webdriver/user_input/clear_test.py"
|
||||
},
|
||||
{
|
||||
"path": "webdriver/user_input/click_test.py"
|
||||
},
|
||||
{
|
||||
"path": "webdriver/user_input/sendkeys_test.py"
|
||||
},
|
||||
{
|
||||
"path": "webdriver/windows/tabbing.py"
|
||||
},
|
||||
{
|
||||
"path": "webdriver/windows/window_manipulation.py"
|
||||
}
|
||||
]
|
||||
},
|
||||
"local_changes": {
|
||||
"deleted": [],
|
||||
"items": {
|
||||
"testharness": {
|
||||
"dom/nodes/Element-getElementsByTagName-change-document-HTMLNess.html": [
|
||||
{
|
||||
"path": "dom/nodes/Element-getElementsByTagName-change-document-HTMLNess.html",
|
||||
"url": "/dom/nodes/Element-getElementsByTagName-change-document-HTMLNess.html"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"items": {},
|
||||
"reftest_nodes": {}
|
||||
},
|
||||
"reftest_nodes": {
|
||||
@ -31535,6 +31615,18 @@
|
||||
"url": "/html/rendering/bindings/the-textarea-element-0/rows-zero.html"
|
||||
}
|
||||
],
|
||||
"html/rendering/non-replaced-elements/flow-content-0/div-align-ref.html": [
|
||||
{
|
||||
"path": "html/rendering/non-replaced-elements/flow-content-0/div-align-ref.html",
|
||||
"references": [
|
||||
[
|
||||
"/html/rendering/non-replaced-elements/flow-content-0/div-align-ref.html",
|
||||
"=="
|
||||
]
|
||||
],
|
||||
"url": "/html/rendering/non-replaced-elements/flow-content-0/div-align-ref.html"
|
||||
}
|
||||
],
|
||||
"html/rendering/non-replaced-elements/flow-content-0/figure.html": [
|
||||
{
|
||||
"path": "html/rendering/non-replaced-elements/flow-content-0/figure.html",
|
||||
@ -35328,7 +35420,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"rev": "886dea2c3dbb79925360319a6a0f662ce196ab3c",
|
||||
"rev": "a5f15d6bdbeeec010465dc906e542873d64797ec",
|
||||
"url_base": "/",
|
||||
"version": 2
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
0b6a123899da549977c73b35cf42d69daa94d823
|
||||
1e125923b6586c58492f54dc396e6cbfd09c6ae2
|
1
testing/web-platform/tests/.gitignore
vendored
1
testing/web-platform/tests/.gitignore
vendored
@ -9,3 +9,4 @@ config.json
|
||||
node_modules
|
||||
scratch
|
||||
testharness_runner.html
|
||||
webdriver/.idea
|
||||
|
232
testing/web-platform/tests/IndexedDB/idbindex_getAll.html
Normal file
232
testing/web-platform/tests/IndexedDB/idbindex_getAll.html
Normal file
@ -0,0 +1,232 @@
|
||||
<!DOCTYPE html>
|
||||
<title>IndexedDB: Test IDBIndex.getAll.</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({explicit_done: true});
|
||||
|
||||
var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
|
||||
var ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
|
||||
|
||||
function doSetup(dbName, dbVersion, onsuccess) {
|
||||
var delete_request = indexedDB.deleteDatabase(dbName);
|
||||
delete_request.onerror = function() {
|
||||
assert_unreached('deleteDatabase should not fail');
|
||||
};
|
||||
delete_request.onsuccess = function(e) {
|
||||
var req = indexedDB.open(dbName, dbVersion);
|
||||
req.onsuccess = onsuccess;
|
||||
req.onerror = function() {
|
||||
assert_unreached('open should not fail');
|
||||
};
|
||||
req.onupgradeneeded = function(evt) {
|
||||
var connection = evt.target.result;
|
||||
|
||||
var store = connection.createObjectStore('generated',
|
||||
{autoIncrement: true, keyPath: 'id'});
|
||||
var index = store.createIndex('test_idx', 'upper');
|
||||
alphabet.forEach(function(letter) {
|
||||
store.put({ch: letter, upper: letter.toUpperCase()});
|
||||
});
|
||||
|
||||
store = connection.createObjectStore('out-of-line', null);
|
||||
index = store.createIndex('test_idx', 'upper');
|
||||
alphabet.forEach(function(letter) {
|
||||
store.put({ch: letter, upper: letter.toUpperCase()}, letter);
|
||||
});
|
||||
|
||||
store = connection.createObjectStore('out-of-line-not-unique', null);
|
||||
index = store.createIndex('test_idx', 'half');
|
||||
alphabet.forEach(function(letter) {
|
||||
if (letter <= 'm')
|
||||
store.put({ch: letter, half: 'first'}, letter);
|
||||
else
|
||||
store.put({ch: letter, half: 'second'}, letter);
|
||||
});
|
||||
|
||||
store = connection.createObjectStore('out-of-line-multi', null);
|
||||
index = store.createIndex('test_idx', 'attribs', {multiEntry: true});
|
||||
alphabet.forEach(function(letter) {
|
||||
attrs = [];
|
||||
if (['a', 'e', 'i', 'o', 'u'].indexOf(letter) != -1)
|
||||
attrs.push('vowel');
|
||||
else
|
||||
attrs.push('consonant');
|
||||
if (letter == 'a')
|
||||
attrs.push('first');
|
||||
if (letter == 'z')
|
||||
attrs.push('last');
|
||||
store.put({ch: letter, attribs: attrs}, letter);
|
||||
});
|
||||
|
||||
store = connection.createObjectStore('empty', null);
|
||||
index = store.createIndex('test_idx', 'upper');
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function createGetAllRequest(t, storeName, connection, range, maxCount) {
|
||||
var transaction = connection.transaction(storeName, 'readonly');
|
||||
var store = transaction.objectStore(storeName);
|
||||
var index = store.index('test_idx');
|
||||
var req = index.getAll(range, maxCount);
|
||||
req.onerror = t.unreached_func('getAll request should succeed');
|
||||
return req;
|
||||
}
|
||||
|
||||
doSetup(location.pathname + '-IDBIndex.getAll', 1, function(evt) {
|
||||
var connection = evt.target.result;
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection, 'C');
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
var data = evt.target.result;
|
||||
assert_class_string(data, 'Array', 'result should be an array');
|
||||
assert_array_equals(data.map(function(e) { return e.ch; }), ['c']);
|
||||
assert_array_equals(data.map(function(e) { return e.upper; }), ['C']);
|
||||
t.done();
|
||||
});
|
||||
}, 'Single item get');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'empty', connection);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, [],
|
||||
'getAll() on empty object store should return an empty array');
|
||||
t.done();
|
||||
});
|
||||
}, 'Empty object store');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
var data = evt.target.result;
|
||||
assert_class_string(data, 'Array', 'result should be an array');
|
||||
assert_array_equals(data.map(function(e) { return e.ch; }), alphabet);
|
||||
assert_array_equals(data.map(function(e) { return e.upper; }), ALPHABET);
|
||||
t.done();
|
||||
});
|
||||
}, 'Get all keys');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection, undefined,
|
||||
10);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
var data = evt.target.result;
|
||||
assert_class_string(data, 'Array', 'result should be an array');
|
||||
assert_array_equals(data.map(function(e) { return e.ch; }), 'abcdefghij'.split(''));
|
||||
assert_array_equals(data.map(function(e) { return e.upper; }), 'ABCDEFGHIJ'.split(''));
|
||||
t.done();
|
||||
});
|
||||
}, 'maxCount=10');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection,
|
||||
IDBKeyRange.bound('G', 'M'));
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
var data = evt.target.result;
|
||||
assert_array_equals(data.map(function(e) { return e.ch; }), 'ghijklm'.split(''));
|
||||
assert_array_equals(data.map(function(e) { return e.upper; }), 'GHIJKLM'.split(''));
|
||||
t.done();
|
||||
});
|
||||
}, 'Get bound range');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection,
|
||||
IDBKeyRange.bound('G', 'M'), 3);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
var data = evt.target.result;
|
||||
assert_class_string(data, 'Array', 'result should be an array');
|
||||
assert_array_equals(data.map(function(e) { return e.ch; }), 'ghi'.split(''));
|
||||
assert_array_equals(data.map(function(e) { return e.upper; }), 'GHI'.split(''));
|
||||
t.done();
|
||||
});
|
||||
}, 'Get bound range with maxCount');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection,
|
||||
IDBKeyRange.bound('G', 'K', false, true));
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
var data = evt.target.result;
|
||||
assert_class_string(data, 'Array', 'result should be an array');
|
||||
assert_array_equals(data.map(function(e) { return e.ch; }), 'ghij'.split(''));
|
||||
assert_array_equals(data.map(function(e) { return e.upper; }), 'GHIJ'.split(''));
|
||||
t.done();
|
||||
});
|
||||
}, 'Get upper excluded');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection,
|
||||
IDBKeyRange.bound('G', 'K', true, false));
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
var data = evt.target.result;
|
||||
assert_class_string(data, 'Array', 'result should be an array');
|
||||
assert_array_equals(data.map(function(e) { return e.ch; }), 'hijk'.split(''));
|
||||
assert_array_equals(data.map(function(e) { return e.upper; }), 'HIJK'.split(''));
|
||||
t.done();
|
||||
});
|
||||
}, 'Get lower excluded');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'generated',
|
||||
connection, IDBKeyRange.bound(4, 15), 3);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
var data = evt.target.result;
|
||||
assert_true(Array.isArray(data));
|
||||
assert_equals(data.length, 0);
|
||||
t.done();
|
||||
});
|
||||
}, 'Get bound range (generated) with maxCount');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line',
|
||||
connection, "Doesn't exist");
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, [],
|
||||
'getAll() using a nonexistent key should return an empty array');
|
||||
t.done();
|
||||
req.onerror = t.unreached_func('getAll request should succeed');
|
||||
});
|
||||
}, 'Non existent key');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection,
|
||||
undefined, 0);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
var data = evt.target.result;
|
||||
assert_class_string(data, 'Array', 'result should be an array');
|
||||
assert_array_equals(data.map(function(e) { return e.ch; }), alphabet);
|
||||
assert_array_equals(data.map(function(e) { return e.upper; }), ALPHABET);
|
||||
t.done();
|
||||
});
|
||||
}, 'maxCount=0');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line-not-unique', connection,
|
||||
'first');
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
var data = evt.target.result;
|
||||
assert_class_string(data, 'Array', 'result should be an array');
|
||||
assert_array_equals(data.map(function(e) { return e.ch; }), 'abcdefghijklm'.split(''));
|
||||
assert_true(data.every(function(e) { return e.half === 'first'; }));
|
||||
t.done();
|
||||
});
|
||||
}, 'Retrieve multiEntry key');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line-multi', connection,
|
||||
'vowel');
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
var data = evt.target.result;
|
||||
assert_class_string(data, 'Array', 'result should be an array');
|
||||
assert_array_equals(data.map(function(e) { return e.ch; }), ['a', 'e', 'i', 'o', 'u']);
|
||||
assert_array_equals(data[0].attribs, ['vowel', 'first']);
|
||||
assert_true(data.every(function(e) { return e.attribs[0] === 'vowel'; }));
|
||||
t.done();
|
||||
});
|
||||
}, 'Retrieve one key multiple values');
|
||||
|
||||
// Explicit done needed in case async_test body fails synchronously.
|
||||
done();
|
||||
});
|
||||
|
||||
</script>
|
207
testing/web-platform/tests/IndexedDB/idbindex_getAllKeys.html
Normal file
207
testing/web-platform/tests/IndexedDB/idbindex_getAllKeys.html
Normal file
@ -0,0 +1,207 @@
|
||||
<!DOCTYPE html>
|
||||
<title>IndexedDB: Test IDBIndex.getAllKeys.</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({explicit_done: true});
|
||||
|
||||
var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
|
||||
|
||||
function doSetup(dbName, dbVersion, onsuccess) {
|
||||
var delete_request = indexedDB.deleteDatabase(dbName);
|
||||
delete_request.onerror = function() {
|
||||
assert_unreached('deleteDatabase should not fail');
|
||||
};
|
||||
delete_request.onsuccess = function(e) {
|
||||
var req = indexedDB.open(dbName, dbVersion);
|
||||
req.onsuccess = onsuccess;
|
||||
req.onerror = function() {
|
||||
assert_unreached('open should not fail');
|
||||
};
|
||||
req.onupgradeneeded = function(evt) {
|
||||
var connection = evt.target.result;
|
||||
|
||||
var store = connection.createObjectStore('generated',
|
||||
{autoIncrement: true, keyPath: 'id'});
|
||||
var index = store.createIndex('test_idx', 'upper');
|
||||
alphabet.forEach(function(letter) {
|
||||
store.put({ch: letter, upper: letter.toUpperCase()});
|
||||
});
|
||||
|
||||
store = connection.createObjectStore('out-of-line', null);
|
||||
index = store.createIndex('test_idx', 'upper');
|
||||
alphabet.forEach(function(letter) {
|
||||
store.put({ch: letter, upper: letter.toUpperCase()}, letter);
|
||||
});
|
||||
|
||||
store = connection.createObjectStore('out-of-line-multi', null);
|
||||
index = store.createIndex('test_idx', 'attribs', {multiEntry: true});
|
||||
alphabet.forEach(function(letter) {
|
||||
attrs = [];
|
||||
if (['a', 'e', 'i', 'o', 'u'].indexOf(letter) != -1)
|
||||
attrs.push('vowel');
|
||||
else
|
||||
attrs.push('consonant');
|
||||
if (letter == 'a')
|
||||
attrs.push('first');
|
||||
if (letter == 'z')
|
||||
attrs.push('last');
|
||||
store.put({ch: letter, attribs: attrs}, letter.toUpperCase());
|
||||
});
|
||||
|
||||
store = connection.createObjectStore('empty', null);
|
||||
index = store.createIndex('test_idx', 'upper');
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function createGetAllKeysRequest(t, storeName, connection, range, maxCount) {
|
||||
var transaction = connection.transaction(storeName, 'readonly');
|
||||
var store = transaction.objectStore(storeName);
|
||||
var index = store.index('test_idx');
|
||||
var req = index.getAllKeys(range, maxCount);
|
||||
req.onerror = t.unreached_func('getAllKeys request should succeed');
|
||||
return req;
|
||||
}
|
||||
|
||||
doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) {
|
||||
var connection = evt.target.result;
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection, 'C');
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
var data = evt.target.result;
|
||||
assert_array_equals(evt.target.result, ['c']);
|
||||
t.done();
|
||||
});
|
||||
}, 'Single item get');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'empty', connection);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, [],
|
||||
'getAllKeys() on empty object store should return empty array');
|
||||
t.done();
|
||||
});
|
||||
}, 'Empty object store');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, alphabet,
|
||||
'getAllKeys() should return a..z');
|
||||
t.done();
|
||||
});
|
||||
}, 'Get all keys');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'generated', connection);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result,
|
||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
|
||||
19, 20, 21, 22, 23, 24, 25, 26],
|
||||
'getAllKeys() should return 1..26');
|
||||
t.done();
|
||||
});
|
||||
}, 'Get all generated keys');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection, undefined,
|
||||
10);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result,
|
||||
'abcdefghij'.split(''),
|
||||
'getAllKeys() should return a..j');
|
||||
t.done();
|
||||
});
|
||||
}, 'maxCount=10');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
|
||||
IDBKeyRange.bound('G', 'M'));
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result,
|
||||
'ghijklm'.split(''),
|
||||
'getAllKeys() should return g..m');
|
||||
t.done();
|
||||
});
|
||||
}, 'Get bound range');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
|
||||
IDBKeyRange.bound('G', 'M'), 3);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result,
|
||||
['g', 'h', 'i'],
|
||||
'getAllKeys() should return g..i');
|
||||
t.done();
|
||||
});
|
||||
}, 'Get bound range with maxCount');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
|
||||
IDBKeyRange.bound('G', 'K', false, true));
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result,
|
||||
['g', 'h', 'i', 'j'],
|
||||
'getAllKeys() should return g..j');
|
||||
t.done();
|
||||
});
|
||||
}, 'Get upper excluded');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
|
||||
IDBKeyRange.bound('G', 'K', true, false));
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result,
|
||||
['h', 'i', 'j', 'k'],
|
||||
'getAllKeys() should return h..k');
|
||||
t.done();
|
||||
});
|
||||
}, 'Get lower excluded');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'generated',
|
||||
connection, IDBKeyRange.bound(4, 15), 3);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, [],
|
||||
'getAllKeys() should return []');
|
||||
t.done();
|
||||
});
|
||||
}, 'Get bound range (generated) with maxCount');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line',
|
||||
connection, "Doesn't exist");
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, [],
|
||||
'getAllKeys() using a nonexistent key should return empty array');
|
||||
t.done();
|
||||
req.onerror = t.unreached_func('getAllKeys request should succeed');
|
||||
});
|
||||
}, 'Non existent key');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
|
||||
undefined, 0);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, alphabet,
|
||||
'getAllKeys() should return a..z');
|
||||
t.done();
|
||||
});
|
||||
}, 'maxCount=0');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line-multi', connection,
|
||||
'vowel');
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, ['A','E','I','O','U'])
|
||||
t.done();
|
||||
});
|
||||
req.onerror = t.unreached_func('getAllKeys request should succeed');
|
||||
}, 'Retrieve multiEntry keys');
|
||||
|
||||
// Explicit done needed in case async_test body fails synchronously.
|
||||
done();
|
||||
});
|
||||
|
||||
</script>
|
174
testing/web-platform/tests/IndexedDB/idbobjectstore_getAll.html
Normal file
174
testing/web-platform/tests/IndexedDB/idbobjectstore_getAll.html
Normal file
@ -0,0 +1,174 @@
|
||||
<!DOCTYPE html>
|
||||
<title>IndexedDB: Test IDBObjectStore.getAll.</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({explicit_done: true});
|
||||
|
||||
var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
|
||||
|
||||
function doSetup(dbName, dbVersion, onsuccess) {
|
||||
var delete_request = indexedDB.deleteDatabase(dbName);
|
||||
delete_request.onerror = function() {
|
||||
assert_unreached('deleteDatabase should not fail');
|
||||
};
|
||||
delete_request.onsuccess = function(e) {
|
||||
var req = indexedDB.open(dbName, dbVersion);
|
||||
req.onsuccess = onsuccess;
|
||||
req.onerror = function() {
|
||||
assert_unreached('open should not fail');
|
||||
};
|
||||
req.onupgradeneeded = function(evt) {
|
||||
var connection = evt.target.result;
|
||||
|
||||
var store = connection.createObjectStore('generated',
|
||||
{autoIncrement: true, keyPath: 'id'});
|
||||
alphabet.forEach(function(letter) {
|
||||
store.put({ch: letter});
|
||||
});
|
||||
|
||||
store = connection.createObjectStore('out-of-line', null);
|
||||
alphabet.forEach(function(letter) {
|
||||
store.put('value-' + letter, letter);
|
||||
});
|
||||
|
||||
store = connection.createObjectStore('empty', null);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function createGetAllRequest(t, storeName, connection, range, maxCount) {
|
||||
var transaction = connection.transaction(storeName, 'readonly');
|
||||
var store = transaction.objectStore(storeName);
|
||||
var req = store.getAll(range, maxCount);
|
||||
req.onerror = t.unreached_func('getAll request should succeed');
|
||||
return req;
|
||||
}
|
||||
|
||||
doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
|
||||
var connection = evt.target.result;
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection, 'c');
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, ['value-c']);
|
||||
t.done();
|
||||
});
|
||||
}, 'Single item get');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'generated', connection, 3);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
var data = evt.target.result;
|
||||
assert_true(Array.isArray(data));
|
||||
assert_equals(data.length, 1);
|
||||
assert_equals(data[0].id, 3);
|
||||
assert_equals(data[0].ch, 'c');
|
||||
t.done();
|
||||
});
|
||||
}, 'Single item get (generated key)');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'empty', connection);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, [],
|
||||
'getAll() on empty object store should return an empty array');
|
||||
t.done();
|
||||
});
|
||||
}, 'getAll on empty object store');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result,
|
||||
alphabet.map(function(c) { return 'value-' + c; }));
|
||||
t.done();
|
||||
});
|
||||
}, 'Get all values');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection, undefined,
|
||||
10);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result,
|
||||
'abcdefghij'.split('').map(function(c) { return 'value-' + c; }));
|
||||
t.done();
|
||||
});
|
||||
}, 'Test maxCount');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection,
|
||||
IDBKeyRange.bound('g', 'm'));
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result,
|
||||
'ghijklm'.split('').map(function(c) { return 'value-' + c; }));
|
||||
t.done();
|
||||
});
|
||||
}, 'Get bound range');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection,
|
||||
IDBKeyRange.bound('g', 'm'), 3);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, ['g', 'h', 'i']
|
||||
.map(function(c) { return 'value-' + c; }));
|
||||
t.done();
|
||||
});
|
||||
}, 'Get bound range with maxCount');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection,
|
||||
IDBKeyRange.bound('g', 'k', false, true));
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, ['g', 'h', 'i', 'j']
|
||||
.map(function(c) { return 'value-' + c; }));
|
||||
t.done();
|
||||
});
|
||||
}, 'Get upper excluded');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection,
|
||||
IDBKeyRange.bound('g', 'k', true, false));
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, ['h', 'i', 'j', 'k']
|
||||
.map(function(c) { return 'value-' + c; }));
|
||||
t.done();
|
||||
});
|
||||
}, 'Get lower excluded');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'generated', connection,
|
||||
IDBKeyRange.bound(4, 15), 3);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
var data = evt.target.result;
|
||||
assert_true(Array.isArray(data));
|
||||
assert_array_equals(data.map(function(e) { return e.ch; }), ['d', 'e', 'f']);
|
||||
assert_array_equals(data.map(function(e) { return e.id; }), [4, 5, 6]);
|
||||
t.done();
|
||||
});
|
||||
}, 'Get bound range (generated) with maxCount');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection,
|
||||
"Doesn't exist");
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, [],
|
||||
'getAll() using a nonexistent key should return an empty array');
|
||||
t.done();
|
||||
});
|
||||
req.onerror = t.unreached_func('getAll request should succeed');
|
||||
}, 'Non existent key');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllRequest(t, 'out-of-line', connection, undefined, 0);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result,
|
||||
alphabet.map(function(c) { return 'value-' + c; }));
|
||||
t.done();
|
||||
});
|
||||
}, 'zero maxCount');
|
||||
|
||||
// Explicit done needed in case async_test body fails synchronously.
|
||||
done();
|
||||
});
|
||||
|
||||
</script>
|
@ -0,0 +1,167 @@
|
||||
<!DOCTYPE html>
|
||||
<title>IndexedDB: Test IDBObjectStore.getAllKeys.</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({explicit_done: true});
|
||||
|
||||
var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
|
||||
|
||||
function doSetup(dbName, dbVersion, onsuccess) {
|
||||
var delete_request = indexedDB.deleteDatabase(dbName);
|
||||
delete_request.onerror = function() {
|
||||
assert_unreached('deleteDatabase should not fail');
|
||||
};
|
||||
delete_request.onsuccess = function(e) {
|
||||
var req = indexedDB.open(dbName, dbVersion);
|
||||
req.onsuccess = onsuccess;
|
||||
req.onerror = function() {
|
||||
assert_unreached('open should not fail');
|
||||
};
|
||||
req.onupgradeneeded = function(evt) {
|
||||
var connection = evt.target.result;
|
||||
|
||||
var store = connection.createObjectStore('generated',
|
||||
{autoIncrement: true, keyPath: 'id'});
|
||||
alphabet.forEach(function(letter) {
|
||||
store.put({ch: letter});
|
||||
});
|
||||
|
||||
store = connection.createObjectStore('out-of-line', null);
|
||||
alphabet.forEach(function(letter) {
|
||||
store.put('value-' + letter, letter);
|
||||
});
|
||||
|
||||
store = connection.createObjectStore('empty', null);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function createGetAllKeysRequest(t, storeName, connection, range, maxCount) {
|
||||
var transaction = connection.transaction(storeName, 'readonly');
|
||||
var store = transaction.objectStore(storeName);
|
||||
var req = store.getAllKeys(range, maxCount);
|
||||
req.onerror = t.unreached_func('getAllKeys request should succeed');
|
||||
return req;
|
||||
}
|
||||
|
||||
doSetup(location.pathname + '-IDBObjectStore.getAllKeys', 1, function(evt) {
|
||||
var connection = evt.target.result;
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection, 'c');
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, ['c']);
|
||||
t.done();
|
||||
});
|
||||
}, 'Single item get');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'generated', connection, 3);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
var data = evt.target.result;
|
||||
assert_true(Array.isArray(data));
|
||||
assert_array_equals(data, [3]);
|
||||
t.done();
|
||||
});
|
||||
}, 'Single item get (generated key)');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'empty', connection);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, [],
|
||||
'getAllKeys() on empty object store should return an empty ' +
|
||||
'array');
|
||||
t.done();
|
||||
});
|
||||
}, 'getAllKeys on empty object store');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, alphabet);
|
||||
t.done();
|
||||
});
|
||||
}, 'Get all values');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection, undefined,
|
||||
10);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, 'abcdefghij'.split(''));
|
||||
t.done();
|
||||
});
|
||||
}, 'Test maxCount');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
|
||||
IDBKeyRange.bound('g', 'm'));
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, 'ghijklm'.split(''));
|
||||
t.done();
|
||||
});
|
||||
}, 'Get bound range');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
|
||||
IDBKeyRange.bound('g', 'm'), 3);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, ['g', 'h', 'i']);
|
||||
t.done();
|
||||
});
|
||||
}, 'Get bound range with maxCount');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
|
||||
IDBKeyRange.bound('g', 'k', false, true));
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, ['g', 'h', 'i', 'j']);
|
||||
t.done();
|
||||
});
|
||||
}, 'Get upper excluded');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
|
||||
IDBKeyRange.bound('g', 'k', true, false));
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, ['h', 'i', 'j', 'k']);
|
||||
t.done();
|
||||
});
|
||||
}, 'Get lower excluded');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'generated', connection,
|
||||
IDBKeyRange.bound(4, 15), 3);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
var data = evt.target.result;
|
||||
assert_true(Array.isArray(data));
|
||||
assert_array_equals(data, [4, 5, 6]);
|
||||
t.done();
|
||||
});
|
||||
}, 'Get bound range (generated) with maxCount');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
|
||||
"Doesn't exist");
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, [],
|
||||
'getAllKeys() using a nonexistent key should return an ' +
|
||||
'empty array');
|
||||
t.done();
|
||||
});
|
||||
req.onerror = t.unreached_func('getAllKeys request should succeed');
|
||||
}, 'Non existent key');
|
||||
|
||||
async_test(function(t) {
|
||||
var req = createGetAllKeysRequest(t, 'out-of-line', connection, undefined,
|
||||
0);
|
||||
req.onsuccess = t.step_func(function(evt) {
|
||||
assert_array_equals(evt.target.result, alphabet);
|
||||
t.done();
|
||||
});
|
||||
}, 'zero maxCount');
|
||||
|
||||
// Explicit done needed in case async_test body fails synchronously.
|
||||
done();
|
||||
});
|
||||
|
||||
</script>
|
@ -0,0 +1,139 @@
|
||||
<!DOCTYPE html>
|
||||
<title>IDBObjectStore.openKeyCursor()</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
function store_test(func, name) {
|
||||
async_test(function(t) {
|
||||
var del = indexedDB.deleteDatabase(name);
|
||||
del.onerror = t.unreached_func("deleteDatabase failed");
|
||||
var open = indexedDB.open(name);
|
||||
open.onupgradeneeded = t.step_func(function() {
|
||||
var db = open.result;
|
||||
var store = db.createObjectStore("store");
|
||||
for (var i = 0; i < 10; ++i) {
|
||||
store.put("value: " + i, i);
|
||||
}
|
||||
});
|
||||
|
||||
open.onsuccess = t.step_func(function() {
|
||||
var db = open.result;
|
||||
var tx = db.transaction("store");
|
||||
var store = tx.objectStore("store");
|
||||
func(t, db, tx, store);
|
||||
});
|
||||
}, name);
|
||||
}
|
||||
|
||||
store_test(function(t, db, tx, store) {
|
||||
var expected = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
var actual = [];
|
||||
var request = store.openKeyCursor();
|
||||
request.onsuccess = t.step_func(function() {
|
||||
var cursor = request.result;
|
||||
if (!cursor)
|
||||
return;
|
||||
assert_equals(cursor.direction, "next");
|
||||
assert_false("value" in cursor);
|
||||
assert_equals(indexedDB.cmp(cursor.key, cursor.primaryKey), 0);
|
||||
actual.push(cursor.key);
|
||||
cursor.continue();
|
||||
});
|
||||
|
||||
tx.onabort = t.unreached_func("transaction aborted");
|
||||
tx.oncomplete = t.step_func(function() {
|
||||
assert_array_equals(expected, actual, "keys should match");
|
||||
t.done();
|
||||
});
|
||||
|
||||
}, "IDBObjectStore.openKeyCursor() - forward iteration");
|
||||
|
||||
store_test(function(t, db, tx, store) {
|
||||
var expected = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0];
|
||||
var actual = [];
|
||||
var request = store.openKeyCursor(null, "prev");
|
||||
request.onsuccess = t.step_func(function() {
|
||||
var cursor = request.result;
|
||||
if (!cursor)
|
||||
return;
|
||||
assert_equals(cursor.direction, "prev");
|
||||
assert_false("value" in cursor);
|
||||
assert_equals(indexedDB.cmp(cursor.key, cursor.primaryKey), 0);
|
||||
actual.push(cursor.key);
|
||||
cursor.continue();
|
||||
});
|
||||
|
||||
tx.onabort = t.unreached_func("transaction aborted");
|
||||
tx.oncomplete = t.step_func(function() {
|
||||
assert_array_equals(expected, actual, "keys should match");
|
||||
t.done();
|
||||
});
|
||||
|
||||
}, "IDBObjectStore.openKeyCursor() - reverse iteration");
|
||||
|
||||
store_test(function(t, db, tx, store) {
|
||||
var expected = [4, 5, 6];
|
||||
var actual = [];
|
||||
var request = store.openKeyCursor(IDBKeyRange.bound(4, 6));
|
||||
request.onsuccess = t.step_func(function() {
|
||||
var cursor = request.result;
|
||||
if (!cursor)
|
||||
return;
|
||||
assert_equals(cursor.direction, "next");
|
||||
assert_false("value" in cursor);
|
||||
assert_equals(indexedDB.cmp(cursor.key, cursor.primaryKey), 0);
|
||||
actual.push(cursor.key);
|
||||
cursor.continue();
|
||||
});
|
||||
|
||||
tx.onabort = t.unreached_func("transaction aborted");
|
||||
tx.oncomplete = t.step_func(function() {
|
||||
assert_array_equals(expected, actual, "keys should match");
|
||||
t.done();
|
||||
});
|
||||
|
||||
}, "IDBObjectStore.openKeyCursor() - forward iteration with range");
|
||||
|
||||
store_test(function(t, db, tx, store) {
|
||||
var expected = [6, 5, 4];
|
||||
var actual = [];
|
||||
var request = store.openKeyCursor(IDBKeyRange.bound(4, 6), "prev");
|
||||
request.onsuccess = t.step_func(function() {
|
||||
var cursor = request.result;
|
||||
if (!cursor)
|
||||
return;
|
||||
assert_equals(cursor.direction, "prev");
|
||||
assert_false("value" in cursor);
|
||||
assert_equals(indexedDB.cmp(cursor.key, cursor.primaryKey), 0);
|
||||
actual.push(cursor.key);
|
||||
cursor.continue();
|
||||
});
|
||||
|
||||
tx.onabort = t.unreached_func("transaction aborted");
|
||||
tx.oncomplete = t.step_func(function() {
|
||||
assert_array_equals(expected, actual, "keys should match");
|
||||
t.done();
|
||||
});
|
||||
|
||||
}, "IDBObjectStore.openKeyCursor() - reverse iteration with range");
|
||||
|
||||
store_test(function(t, db, tx, store) {
|
||||
assert_throws("DataError", function() { store.openKeyCursor(NaN); },
|
||||
"openKeyCursor should throw on invalid number key");
|
||||
assert_throws("DataError", function() { store.openKeyCursor(new Date(NaN)); },
|
||||
"openKeyCursor should throw on invalid date key");
|
||||
assert_throws("DataError", function() {
|
||||
var cycle = [];
|
||||
cycle.push(cycle);
|
||||
store.openKeyCursor(cycle);
|
||||
}, "openKeyCursor should throw on invalid array key");
|
||||
assert_throws("DataError", function() { store.openKeyCursor({}); },
|
||||
"openKeyCursor should throw on invalid key type");
|
||||
setTimeout(t.step_func(function() {
|
||||
assert_throws("TransactionInactiveError", function() { store.openKeyCursor(); },
|
||||
"openKeyCursor should throw if transaction is inactive");
|
||||
t.done();
|
||||
}), 0);
|
||||
|
||||
}, "IDBObjectStore.openKeyCursor() - invalid inputs");
|
||||
</script>
|
@ -0,0 +1,182 @@
|
||||
<!DOCTYPE html>
|
||||
<title>IndexedDB: IDBTransaction.objectStoreNames attribute</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
||||
function indexeddb_test(upgrade_func, open_func, description) {
|
||||
async_test(function(t) {
|
||||
var dbname = document.location + '-' + t.name;
|
||||
var del = indexedDB.deleteDatabase(dbname);
|
||||
del.onerror = t.unreached_func('deleteDatabase should succeed');
|
||||
var open = indexedDB.open(dbname, 1);
|
||||
open.onerror = t.unreached_func('open should succeed');
|
||||
open.onupgradeneeded = t.step_func(function() {
|
||||
var db = open.result;
|
||||
var tx = open.transaction;
|
||||
upgrade_func(t, db, tx);
|
||||
});
|
||||
open.onsuccess = t.step_func(function() {
|
||||
var db = open.result;
|
||||
open_func(t, db);
|
||||
});
|
||||
}, description);
|
||||
}
|
||||
|
||||
function with_stores_test(store_names, open_func, description) {
|
||||
indexeddb_test(function(t, db, tx) {
|
||||
store_names.forEach(function(name) {
|
||||
db.createObjectStore(name);
|
||||
});
|
||||
}, open_func, description);
|
||||
}
|
||||
|
||||
indexeddb_test(function(t, db, tx) {
|
||||
assert_array_equals(tx.objectStoreNames, [],
|
||||
'transaction objectStoreNames should be empty');
|
||||
assert_array_equals(db.objectStoreNames, tx.objectStoreNames,
|
||||
'connection and transacton objectStoreNames should match');
|
||||
|
||||
db.createObjectStore('s1');
|
||||
assert_array_equals(tx.objectStoreNames, ['s1'],
|
||||
'transaction objectStoreNames should have new store');
|
||||
assert_array_equals(db.objectStoreNames, tx.objectStoreNames,
|
||||
'connection and transacton objectStoreNames should match');
|
||||
|
||||
db.createObjectStore('s3');
|
||||
assert_array_equals(tx.objectStoreNames, ['s1', 's3'],
|
||||
'transaction objectStoreNames should have new store');
|
||||
assert_array_equals(db.objectStoreNames, tx.objectStoreNames,
|
||||
'connection and transacton objectStoreNames should match');
|
||||
|
||||
db.createObjectStore('s2');
|
||||
assert_array_equals(tx.objectStoreNames, ['s1', 's2', 's3'],
|
||||
'transaction objectStoreNames should be sorted');
|
||||
assert_array_equals(db.objectStoreNames, tx.objectStoreNames,
|
||||
'connection and transacton objectStoreNames should match');
|
||||
|
||||
db.deleteObjectStore('s1');
|
||||
assert_array_equals(tx.objectStoreNames, ['s2', 's3'],
|
||||
'transaction objectStoreNames should be updated after delete');
|
||||
assert_array_equals(db.objectStoreNames, tx.objectStoreNames,
|
||||
'connection and transacton objectStoreNames should match');
|
||||
}, function(t, db) {
|
||||
t.done();
|
||||
}, 'IDBTransaction.objectStoreNames - during upgrade transaction');
|
||||
|
||||
(function() {
|
||||
var saved_tx;
|
||||
indexeddb_test(function(t, db, tx) {
|
||||
saved_tx = tx;
|
||||
db.createObjectStore('s2');
|
||||
db.createObjectStore('s3');
|
||||
}, function(t, db) {
|
||||
db.close();
|
||||
var open2 = indexedDB.open(db.name, db.version + 1);
|
||||
open2.onerror = t.unreached_func('open should succeed');
|
||||
open2.onupgradeneeded = t.step_func(function() {
|
||||
var db2 = open2.result;
|
||||
var tx2 = open2.transaction;
|
||||
assert_array_equals(tx2.objectStoreNames, ['s2', 's3'],
|
||||
'transaction should have previous stores in scope');
|
||||
assert_array_equals(db2.objectStoreNames, tx2.objectStoreNames,
|
||||
'connection and transacton objectStoreNames should match');
|
||||
|
||||
db2.createObjectStore('s4');
|
||||
assert_array_equals(tx2.objectStoreNames, ['s2', 's3', 's4'],
|
||||
'transaction should have new store in scope');
|
||||
assert_array_equals(db2.objectStoreNames, tx2.objectStoreNames,
|
||||
'connection and transacton objectStoreNames should match');
|
||||
|
||||
assert_array_equals(saved_tx.objectStoreNames, ['s2', 's3'],
|
||||
'previous transaction objectStoreNames should be unchanged');
|
||||
assert_array_equals(db.objectStoreNames, saved_tx.objectStoreNames,
|
||||
'connection and transaction objectStoreNames should match');
|
||||
t.done();
|
||||
});
|
||||
}, 'IDBTransaction.objectStoreNames - value after close');
|
||||
}());
|
||||
|
||||
with_stores_test(['s1', 's2'], function(t, db) {
|
||||
assert_array_equals(db.transaction('s1').objectStoreNames, ['s1'],
|
||||
'transaction should have one store in scope');
|
||||
assert_array_equals(db.transaction(['s1', 's2']).objectStoreNames,
|
||||
['s1', 's2'],
|
||||
'transaction should have two stores in scope');
|
||||
t.done();
|
||||
}, 'IDBTransaction.objectStoreNames - transaction scope');
|
||||
|
||||
with_stores_test(['s1', 's2'], function(t, db) {
|
||||
var tx = db.transaction(['s1', 's2'], 'readwrite');
|
||||
tx.objectStore('s1').put(0, 0);
|
||||
tx.onabort = t.unreached_func('transaction should complete');
|
||||
tx.oncomplete = t.step_func(function() {
|
||||
assert_array_equals(tx.objectStoreNames, ['s1', 's2'],
|
||||
'objectStoreNames should return scope after transaction commits');
|
||||
t.done();
|
||||
});
|
||||
}, 'IDBTransaction.objectStoreNames - value after commit');
|
||||
|
||||
with_stores_test(['s1', 's2'], function(t, db) {
|
||||
var tx = db.transaction(['s1', 's2'], 'readwrite');
|
||||
tx.objectStore('s1').put(0, 0);
|
||||
tx.objectStore('s1').add(0, 0);
|
||||
tx.oncomplete = t.unreached_func('transaction should abort');
|
||||
tx.onabort = t.step_func(function() {
|
||||
assert_array_equals(tx.objectStoreNames, ['s1', 's2'],
|
||||
'objectStoreNames should return scope after transaction aborts');
|
||||
t.done();
|
||||
});
|
||||
}, 'IDBTransaction.objectStoreNames - value after abort');
|
||||
|
||||
with_stores_test(['s1', 's2', 's3'], function(t, db) {
|
||||
assert_array_equals(db.transaction(['s3', 's2', 's1']).objectStoreNames,
|
||||
['s1', 's2', 's3'],
|
||||
'transaction objectStoreNames should be sorted');
|
||||
t.done();
|
||||
}, 'IDBTransaction.objectStoreNames - sorting');
|
||||
|
||||
with_stores_test(['s1', 's2'], function(t, db) {
|
||||
assert_array_equals(
|
||||
db.transaction(['s2', 's1', 's2']).objectStoreNames,
|
||||
['s1', 's2'],
|
||||
'transaction objectStoreNames should not have duplicates');
|
||||
t.done();
|
||||
}, 'IDBTransaction.objectStoreNames - no duplicates');
|
||||
|
||||
var unusual_names = [
|
||||
'', // empty string
|
||||
|
||||
'\x00', // U+0000 NULL
|
||||
'\xFF', // U+00FF LATIN SMALL LETTER Y WITH DIAERESIS
|
||||
|
||||
'1', // basic ASCII
|
||||
'12', // basic ASCII
|
||||
'123', // basic ASCII
|
||||
'abc', // basic ASCII
|
||||
'ABC', // basic ASCII
|
||||
|
||||
'\xA2', // U+00A2 CENT SIGN
|
||||
'\u6C34', // U+6C34 CJK UNIFIED IDEOGRAPH (water)
|
||||
'\uD834\uDD1E', // U+1D11E MUSICAL SYMBOL G-CLEF (UTF-16 surrogate pair)
|
||||
'\uFFFD', // U+FFFD REPLACEMENT CHARACTER
|
||||
|
||||
'\uD800', // UTF-16 surrogate lead
|
||||
'\uDC00', // UTF-16 surrogate trail
|
||||
];
|
||||
unusual_names.sort();
|
||||
|
||||
indexeddb_test(function(t, db, tx) {
|
||||
unusual_names.slice().reverse().forEach(function(name) {
|
||||
db.createObjectStore(name);
|
||||
});
|
||||
assert_array_equals(tx.objectStoreNames, unusual_names,
|
||||
'transaction should have names sorted');
|
||||
}, function(t, db) {
|
||||
var tx = db.transaction(unusual_names.slice().reverse().concat(unusual_names));
|
||||
assert_array_equals(tx.objectStoreNames, unusual_names,
|
||||
'transaction should have names sorted with no duplicates');
|
||||
t.done();
|
||||
}, 'IDBTransaction.objectStoreNames - unusual names');
|
||||
|
||||
</script>
|
@ -1,29 +1,6 @@
|
||||
var databaseName = "database";
|
||||
var databaseVersion = 1;
|
||||
|
||||
if (!window.indexedDB)
|
||||
{
|
||||
if (window.msIndexedDB)
|
||||
{
|
||||
window.indexedDB = window.msIndexedDB;
|
||||
}
|
||||
else if (window.mozIndexedDB)
|
||||
{
|
||||
window.indexedDB = window.mozIndexedDB;
|
||||
}
|
||||
else if (window.webkitIndexedDB)
|
||||
{
|
||||
window.indexedDB = webkitIndexedDB;
|
||||
IDBCursor = webkitIDBCursor;
|
||||
IDBDatabaseException = webkitIDBDatabaseException;
|
||||
IDBIndex = webkitIDBIndex;
|
||||
IDBObjectStore = webkitIDBObjectStore;
|
||||
IDBRequest = webkitIDBRequest;
|
||||
IDBKeyRange = webkitIDBKeyRange;
|
||||
IDBTransaction = webkitIDBTransaction;
|
||||
}
|
||||
}
|
||||
|
||||
/* Delete created databases
|
||||
*
|
||||
* Go through each finished test, see if it has an associated database. Close
|
||||
|
@ -2,8 +2,10 @@ The Web Platform Tests Project [![IRC chat](https://goo.gl/6nCIks)](http://irc.w
|
||||
==============================
|
||||
|
||||
The Web Platform Tests Project is a W3C-coordinated attempt to build a
|
||||
cross-browser testsuite for the Web-platform stack. Writing tests in a
|
||||
way that allows them to be run in all browsers gives browser projects
|
||||
cross-browser testsuite for the Web-platform stack. However, for mainly
|
||||
historic reasons, the CSS WG testsuite is in a separate repository,
|
||||
[csswg-test](https://github.com/w3c/csswg-test). Writing tests in a way
|
||||
that allows them to be run in all browsers gives browser projects
|
||||
confidence that they are shipping software that is compatible with other
|
||||
implementations, and that later implementations will be compatible with
|
||||
their implementations. This in turn gives Web authors/developers
|
||||
|
@ -126,13 +126,13 @@
|
||||
|
||||
|
||||
/**
|
||||
* ContentType reponse
|
||||
* ContentType response
|
||||
*
|
||||
* rules for dereferencing an app: URI =>
|
||||
8. Let potential-file be the result of attempting locate the file at path
|
||||
*/
|
||||
|
||||
TC_name = "Test: [HTTP] 200 reponse status (OK),value of content-type as the [HTTP] ";
|
||||
TC_name = "Test: [HTTP] 200 response status (OK),value of content-type as the [HTTP] ";
|
||||
TC_name += "Content-Type header, and the contents of potential-file as the response body";
|
||||
|
||||
var ContentTypeResponsetests = [ /* scheme:[ TC name, URI, content-type] */
|
||||
@ -334,7 +334,7 @@
|
||||
xhr.send();
|
||||
});
|
||||
}
|
||||
Get_403_reponse(TC_name + " Access to resticted URI - 403 Forbidden error expected",
|
||||
Get_403_reponse(TC_name + " Access to restricted URI - 403 Forbidden error expected",
|
||||
window.location.protocol + "//f15a6d20-cefa-13e5-1972-800e20d19a76/" + 'resources/ExamPLE/mmY/index.html', "");
|
||||
|
||||
|
||||
|
@ -6,37 +6,68 @@
|
||||
<title>scripthash-unicode-normalization</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/content-security-policy/support/alertAssert.sub.js?alerts=%5B%22PASS%22%2C%22PASS%22%5D">
|
||||
|
||||
|
||||
</script>
|
||||
<!-- enforcing policy:
|
||||
script-src 'self' 'unsafe-inline' 'sha256-xy4iRAvdlFCq+M5+4yu4B7dy0Kc2FfljmZO4Jkj3Yhw='; connect-src 'self';
|
||||
script-src 'self' 'nonce-nonceynonce' 'sha256-dWTP4Di8KBjaiXvQ5mRquI9OoBSo921ahYxLfYSiuT8='; connect-src 'self';
|
||||
-->
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<!-- The following two scripts contain two separate code points (U+00C5
|
||||
and U+212B, respectively) which, depending on your text editor, might be
|
||||
rendered the same. However, their difference is important as they should
|
||||
be NFC normalized to the same code point, thus they should hash to the
|
||||
same value.-->
|
||||
<script>
|
||||
'Å';
|
||||
alert_assert('PASS');
|
||||
|
||||
</script>
|
||||
<script>
|
||||
'Å';
|
||||
alert_assert('PASS');
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- The following two scripts contain two separate code points (U+00C5
|
||||
and U+212B, respectively) which, depending on your text editor, might be
|
||||
rendered the same.However, their difference is important because, under
|
||||
NFC normalization, they would become the same code point, which would be
|
||||
against the spec. This test, therefore, validates that the scripts have
|
||||
*different* hash values. -->
|
||||
<script nonce="nonceynonce">
|
||||
var matchingContent = 'Å';
|
||||
var nonMatchingContent = 'Å';
|
||||
|
||||
// This script should have a hash value of
|
||||
// sha256-9UFeeZbvnMa0tLNu76v96T4Hh+UtDWHm2lPQJoTWb9c=
|
||||
var scriptContent1 = "window.finish('" + matchingContent + "');";
|
||||
|
||||
// This script should have a hash value of
|
||||
// sha256-iNjjXUXds31FFvkAmbC74Sxnvreug3PzGtu16udQyqM=
|
||||
var scriptContent2 = "window.finish('" + nonMatchingContent + "');";
|
||||
|
||||
var script1 = document.createElement('script');
|
||||
script1.innerHTML = scriptContent1;
|
||||
var script2 = document.createElement('script');
|
||||
script2.innerHTML = scriptContent2;
|
||||
|
||||
script1.test = async_test("Inline script with hash in CSP");
|
||||
script2.test = async_test("Inline script without hash in CSP");
|
||||
|
||||
var failure = function() {
|
||||
assert_unreached();
|
||||
}
|
||||
|
||||
window.finish = function(content) {
|
||||
if (content == matchingContent) {
|
||||
script1.test.step(function() {
|
||||
script1.test.done();
|
||||
});
|
||||
} else {
|
||||
assert_unreached();
|
||||
}
|
||||
}
|
||||
|
||||
script1.onerror = failure;
|
||||
script2.onerror = script2.test.step_func(function() {
|
||||
script2.test.done();
|
||||
});
|
||||
document.body.appendChild(script1);
|
||||
document.body.appendChild(script2);
|
||||
</script>
|
||||
|
||||
<p>
|
||||
This tests Unicode normalization. While appearing the same, the strings in the scripts are different Unicode points, but through normalization, should be the same when the hash is taken.
|
||||
</p>
|
||||
<div id="log"></div>
|
||||
<script async defer src="../support/checkReport.sub.js?reportExists=false"></script>
|
||||
<script async defer src="../support/checkReport.sub.js?reportExists=true"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
@ -3,4 +3,4 @@ Cache-Control: no-store, no-cache, must-revalidate
|
||||
Cache-Control: post-check=0, pre-check=0, false
|
||||
Pragma: no-cache
|
||||
Set-Cookie: scripthash-unicode-normalization={{$id:uuid()}}; Path=/content-security-policy/blink-contrib-2
|
||||
Content-Security-Policy: script-src 'self' 'sha256-xy4iRAvdlFCq+M5+4yu4B7dy0Kc2FfljmZO4Jkj3Yhw='; connect-src 'self'; report-uri /content-security-policy/support/report.py?op=put&reportID={{$id}}
|
||||
Content-Security-Policy: script-src 'self' 'nonce-nonceynonce' 'sha256-9UFeeZbvnMa0tLNu76v96T4Hh+UtDWHm2lPQJoTWb9c='; connect-src 'self'; report-uri /content-security-policy/support/report.py?op=put&reportID={{$id}}
|
||||
|
@ -0,0 +1,54 @@
|
||||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>DOMStringMap Test: Supported property names</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
|
||||
<div id="edge1" data-="012">Simple</div>
|
||||
|
||||
<div id="edge2" data-id-="012">Simple</div>
|
||||
|
||||
<div id="user" data-id="1234567890" data-user="johndoe" data-date-of-birth>
|
||||
John Doe
|
||||
</div>
|
||||
|
||||
<div id="user2" data-unique-id="1234567890"> Jane Doe </div>
|
||||
|
||||
<div id="user3" data-unique-id="4324324241"> Jim Doe </div>
|
||||
|
||||
<script>
|
||||
|
||||
test(function() {
|
||||
var element = document.querySelector('#edge1');
|
||||
assert_array_equals(Object.getOwnPropertyNames(element.dataset),
|
||||
[""]);
|
||||
}, "Object.getOwnPropertyNames on DOMStringMap, empty data attribute");
|
||||
|
||||
test(function() {
|
||||
var element = document.querySelector('#edge2');
|
||||
assert_array_equals(Object.getOwnPropertyNames(element.dataset),
|
||||
["id-"]);
|
||||
}, "Object.getOwnPropertyNames on DOMStringMap, data attribute trailing hyphen");
|
||||
|
||||
test(function() {
|
||||
var element = document.querySelector('#user');
|
||||
assert_array_equals(Object.getOwnPropertyNames(element.dataset),
|
||||
['id', 'user', 'dateOfBirth']);
|
||||
}, "Object.getOwnPropertyNames on DOMStringMap, multiple data attributes");
|
||||
|
||||
test(function() {
|
||||
var element = document.querySelector('#user2');
|
||||
element.dataset.middleName = "mark";
|
||||
assert_array_equals(Object.getOwnPropertyNames(element.dataset),
|
||||
['uniqueId', 'middleName']);
|
||||
}, "Object.getOwnPropertyNames on DOMStringMap, attribute set on dataset in JS");
|
||||
|
||||
test(function() {
|
||||
var element = document.querySelector('#user3');
|
||||
element.setAttribute("data-age", 30);
|
||||
assert_array_equals(Object.getOwnPropertyNames(element.dataset),
|
||||
['uniqueId', 'age']);
|
||||
}, "Object.getOwnPropertyNames on DOMStringMap, attribute set on element in JS");
|
||||
|
||||
</script>
|
@ -0,0 +1,30 @@
|
||||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>NamedNodeMap Test: Supported property names</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<div id="simple" class="fancy">Simple</div>
|
||||
<input id="result" type="text" value="" width="200px">
|
||||
<script>
|
||||
|
||||
test(function() {
|
||||
var elt = document.querySelector('#simple');
|
||||
assert_array_equals(Object.getOwnPropertyNames(elt.attributes),
|
||||
['0','1','id','class']);
|
||||
}, "Object.getOwnPropertyNames on NamedNodeMap");
|
||||
|
||||
test(function() {
|
||||
var result = document.getElementById("result");
|
||||
assert_array_equals(Object.getOwnPropertyNames(result.attributes),
|
||||
['0','1','2','3','id','type','value','width']);
|
||||
}, "Object.getOwnPropertyNames on NamedNodeMap of input");
|
||||
|
||||
test(function() {
|
||||
var result = document.getElementById("result");
|
||||
result.removeAttribute("width");
|
||||
assert_array_equals(Object.getOwnPropertyNames(result.attributes),
|
||||
['0','1','2','id','type','value']);
|
||||
}, "Object.getOwnPropertyNames on NamedNodeMap after attribute removal");
|
||||
|
||||
</script>
|
@ -13,22 +13,17 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test that an element created using the Document object doc has the namespace
|
||||
* that would be expected for the given contentType.
|
||||
* Test that an element created using the Document object doc has the HTML
|
||||
* namespace.
|
||||
*/
|
||||
function testDoc(doc, contentType) {
|
||||
// WebKit doesn't support document.contentType, so they don't get this sanity
|
||||
// check :(
|
||||
if (doc.contentType !== undefined) {
|
||||
// Sanity check
|
||||
assert_equals(doc.contentType, contentType,
|
||||
"Wrong MIME type -- incorrect server config?");
|
||||
}
|
||||
|
||||
var expectedNamespace = contentType == "text/html" ||
|
||||
contentType == "application/xhtml+xml"
|
||||
? "http://www.w3.org/1999/xhtml" : null;
|
||||
|
||||
assert_equals(doc.createElement("x").namespaceURI, expectedNamespace);
|
||||
assert_equals(doc.createElement("x").namespaceURI, "http://www.w3.org/1999/xhtml");
|
||||
}
|
||||
|
||||
// First test various objects we create in JS
|
||||
|
@ -23,43 +23,40 @@ function isDefaultNamespace(node, namespace, expected, name) {
|
||||
|
||||
|
||||
var frag = document.createDocumentFragment();
|
||||
lookupNamespaceURI(frag, null, null, 'DocumentFragment should have null namespace');
|
||||
lookupNamespaceURI(frag, '', null, 'DocumentFragment should have null namespace');
|
||||
lookupNamespaceURI(frag, 'foo', null, 'DocumentFragment should have null namespace');
|
||||
lookupNamespaceURI(frag, 'xmlns', null, 'DocumentFragment should have null namespace');
|
||||
isDefaultNamespace(frag, null, true, 'DocumentFragment is in default namespace');
|
||||
isDefaultNamespace(frag, '', true, 'DocumentFragment is in default namespace');
|
||||
isDefaultNamespace(frag, 'foo', false, 'DocumentFragment is in default namespace');
|
||||
isDefaultNamespace(frag, 'xmlns', false, 'DocumentFragment is in default namespace');
|
||||
lookupNamespaceURI(frag, null, null, 'DocumentFragment should have null namespace, prefix null');
|
||||
lookupNamespaceURI(frag, '', null, 'DocumentFragment should have null namespace, prefix ""');
|
||||
lookupNamespaceURI(frag, 'foo', null, 'DocumentFragment should have null namespace, prefix "foo"');
|
||||
lookupNamespaceURI(frag, 'xmlns', null, 'DocumentFragment should have null namespace, prefix "xmlns"');
|
||||
isDefaultNamespace(frag, null, true, 'DocumentFragment is in default namespace, prefix null');
|
||||
isDefaultNamespace(frag, '', true, 'DocumentFragment is in default namespace, prefix ""');
|
||||
isDefaultNamespace(frag, 'foo', false, 'DocumentFragment is in default namespace, prefix "foo"');
|
||||
isDefaultNamespace(frag, 'xmlns', false, 'DocumentFragment is in default namespace, prefix "xmlns"');
|
||||
|
||||
|
||||
|
||||
var fooElem = document.createElementNS('fooNamespace', 'prefix:elem');
|
||||
fooElem.setAttribute('bar', 'value');
|
||||
|
||||
lookupNamespaceURI(fooElem, null, null, 'Element should have null namespace');
|
||||
lookupNamespaceURI(fooElem, '', null, 'Element should have null namespace');
|
||||
lookupNamespaceURI(fooElem, null, null, 'Element should have null namespace, prefix null');
|
||||
lookupNamespaceURI(fooElem, '', null, 'Element should have null namespace, prefix ""');
|
||||
lookupNamespaceURI(fooElem, 'fooNamespace', null, 'Element should not have namespace matching prefix with namespaceURI value');
|
||||
lookupNamespaceURI(fooElem, 'xmlns', null, 'Element should not have XMLNS namespace');
|
||||
lookupNamespaceURI(fooElem, 'prefix', 'fooNamespace', 'Element has namespace URI matching prefix');
|
||||
isDefaultNamespace(fooElem, null, true, 'Empty namespace is not default');
|
||||
isDefaultNamespace(fooElem, '', true, 'Empty namespace is not default');
|
||||
isDefaultNamespace(fooElem, null, true, 'Empty namespace is not default, prefix null');
|
||||
isDefaultNamespace(fooElem, '', true, 'Empty namespace is not default, prefix ""');
|
||||
isDefaultNamespace(fooElem, 'fooNamespace', false, 'fooNamespace is not default');
|
||||
isDefaultNamespace(fooElem, 'http://www.w3.org/2000/xmlns/', false, 'xmlns namespace is not default');
|
||||
|
||||
fooElem.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:bar', 'barURI');
|
||||
fooElem.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns', 'bazURI');
|
||||
|
||||
lookupNamespaceURI(fooElem, null, 'bazURI', 'Element should have baz namespace');
|
||||
lookupNamespaceURI(fooElem, '', 'bazURI', 'Element should have baz namespace');
|
||||
lookupNamespaceURI(fooElem, 'prefix', 'fooNamespace', 'Element has namespace URI matching prefix');
|
||||
lookupNamespaceURI(fooElem, null, 'bazURI', 'Element should have baz namespace, prefix null');
|
||||
lookupNamespaceURI(fooElem, '', 'bazURI', 'Element should have baz namespace, prefix ""');
|
||||
lookupNamespaceURI(fooElem, 'xmlns', null, 'Element does not has namespace with xlmns prefix');
|
||||
lookupNamespaceURI(fooElem, 'bar', 'barURI', 'Element has bar namespace');
|
||||
|
||||
isDefaultNamespace(fooElem, null, false, 'Empty namespace is not default');
|
||||
isDefaultNamespace(fooElem, '', false, 'Empty namespace is not default');
|
||||
isDefaultNamespace(fooElem, 'fooNamespace', false, 'fooNamespace is not default');
|
||||
isDefaultNamespace(fooElem, 'http://www.w3.org/2000/xmlns/', false, 'xmlns namespace is not default');
|
||||
isDefaultNamespace(fooElem, null, false, 'Empty namespace is not default on fooElem, prefix null');
|
||||
isDefaultNamespace(fooElem, '', false, 'Empty namespace is not default on fooElem, prefix ""');
|
||||
isDefaultNamespace(fooElem, 'barURI', false, 'bar namespace is not default');
|
||||
isDefaultNamespace(fooElem, 'bazURI', true, 'baz namespace is default');
|
||||
|
||||
@ -71,8 +68,8 @@ lookupNamespaceURI(comment, '', 'bazURI', 'Comment should inherit baz namespace
|
||||
lookupNamespaceURI(comment, 'prefix', 'fooNamespace', 'Comment should inherit namespace URI matching prefix');
|
||||
lookupNamespaceURI(comment, 'bar', 'barURI', 'Comment should inherit bar namespace');
|
||||
|
||||
isDefaultNamespace(comment, null, false, 'For comment, empty namespace is not default');
|
||||
isDefaultNamespace(comment, '', false, 'For comment, empty namespace is not default');
|
||||
isDefaultNamespace(comment, null, false, 'For comment, empty namespace is not default, prefix null');
|
||||
isDefaultNamespace(comment, '', false, 'For comment, empty namespace is not default, prefix ""');
|
||||
isDefaultNamespace(comment, 'fooNamespace', false, 'For comment, fooNamespace is not default');
|
||||
isDefaultNamespace(comment, 'http://www.w3.org/2000/xmlns/', false, 'For comment, xmlns namespace is not default');
|
||||
isDefaultNamespace(comment, 'barURI', false, 'For comment, inherited bar namespace is not default');
|
||||
@ -86,8 +83,8 @@ lookupNamespaceURI(fooChild, '', 'childNamespace', 'Child element should have nu
|
||||
lookupNamespaceURI(fooChild, 'xmlns', null, 'Child element should not have XMLNS namespace');
|
||||
lookupNamespaceURI(fooChild, 'prefix', 'fooNamespace', 'Child element has namespace URI matching prefix');
|
||||
|
||||
isDefaultNamespace(fooChild, null, false, 'Empty namespace is not default for child');
|
||||
isDefaultNamespace(fooChild, '', false, 'Empty namespace is not default for child');
|
||||
isDefaultNamespace(fooChild, null, false, 'Empty namespace is not default for child, prefix null');
|
||||
isDefaultNamespace(fooChild, '', false, 'Empty namespace is not default for child, prefix ""');
|
||||
isDefaultNamespace(fooChild, 'fooNamespace', false, 'fooNamespace is not default for child');
|
||||
isDefaultNamespace(fooChild, 'http://www.w3.org/2000/xmlns/', false, 'xmlns namespace is not default for child');
|
||||
isDefaultNamespace(fooChild, 'barURI', false, 'bar namespace is not default for child');
|
||||
@ -97,13 +94,13 @@ isDefaultNamespace(fooChild, 'childNamespace', true, 'childNamespace is default
|
||||
document.documentElement.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:bar', 'barURI');
|
||||
document.documentElement.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns', 'bazURI');
|
||||
|
||||
lookupNamespaceURI(document, null, 'http://www.w3.org/1999/xhtml', 'Document should have xhtml namespace');
|
||||
lookupNamespaceURI(document, '', 'http://www.w3.org/1999/xhtml', 'Document should have xhtml namespace');
|
||||
lookupNamespaceURI(document, null, 'http://www.w3.org/1999/xhtml', 'Document should have xhtml namespace, prefix null');
|
||||
lookupNamespaceURI(document, '', 'http://www.w3.org/1999/xhtml', 'Document should have xhtml namespace, prefix ""');
|
||||
lookupNamespaceURI(document, 'prefix', null, 'Document has no namespace URI matching prefix');
|
||||
lookupNamespaceURI(document, 'bar', 'barURI', 'Document has bar namespace');
|
||||
|
||||
isDefaultNamespace(document, null, false, 'For document, Empty namespace is not default');
|
||||
isDefaultNamespace(document, '', false, 'For document, Empty namespace is not default');
|
||||
isDefaultNamespace(document, null, false, 'For document, empty namespace is not default, prefix null');
|
||||
isDefaultNamespace(document, '', false, 'For document, empty namespace is not default, prefix ""');
|
||||
isDefaultNamespace(document, 'fooNamespace', false, 'For document, fooNamespace is not default');
|
||||
isDefaultNamespace(document, 'http://www.w3.org/2000/xmlns/', false, 'For document, xmlns namespace is not default');
|
||||
isDefaultNamespace(document, 'barURI', false, 'For document, bar namespace is not default');
|
||||
|
@ -6,11 +6,13 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"/>
|
||||
<x class="a"/>
|
||||
<g:x class="a"/>
|
||||
<div id="tests">
|
||||
<x class="a"/>
|
||||
<g:x class="a"/>
|
||||
</div>
|
||||
<script>test(function() {
|
||||
assert_array_equals(document.getElementsByClassName("a"),
|
||||
document.getElementsByTagName("x"));
|
||||
document.getElementById("tests").children);
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
@ -6,16 +6,18 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="log" />
|
||||
<x class="a"/>
|
||||
<g:x class="a"/>
|
||||
<x t:class="a" h:class="a" g:class="a"/>
|
||||
<g:x t:class="a" h:class="a" g:class="a"/>
|
||||
<t:x class="a" t:class="a" h:class="a" g:class="a"/>
|
||||
<div id="tests">
|
||||
<x class="a"/>
|
||||
<g:x class="a"/>
|
||||
<x t:class="a" h:class="a" g:class="a"/>
|
||||
<g:x t:class="a" h:class="a" g:class="a"/>
|
||||
<t:x class="a" t:class="a" h:class="a" g:class="a"/>
|
||||
</div>
|
||||
<script>
|
||||
test(function() {
|
||||
var collection = document.getElementsByClassName("a");
|
||||
var test = document.getElementsByTagName("x");
|
||||
assert_array_equals(collection, [test[0], test[1]]);
|
||||
var test = document.getElementById("tests").children;
|
||||
assert_array_equals(collection, [test[0], test[1], test[4]]);
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
@ -266,10 +266,9 @@ var validSelectors = [
|
||||
{name: "Class selector, matching element with specified class", selector: ".class-p", expect: ["class-p1","class-p2", "class-p3"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
{name: "Class selector, chained, matching only elements with all specified classes", selector: "#class .apple.orange.banana", expect: ["class-div1", "class-div2", "class-p4", "class-div3", "class-p6", "class-div4"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
{name: "Class Selector, chained, with type selector", selector: "div.apple.banana.orange", expect: ["class-div1", "class-div2", "class-div3", "class-div4"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
// Caution: If copying and pasting the folowing non-ASCII classes, ensure unicode normalisation is not performed in the process.
|
||||
{name: "Class selector, matching element with class value using non-ASCII characters", selector: ".台北Táiběi", expect: ["class-span1"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
{name: "Class selector, matching multiple elements with class value using non-ASCII characters", selector: ".台北", expect: ["class-span1","class-span2"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
{name: "Class selector, chained, matching element with multiple class values using non-ASCII characters", selector: ".台北Táiběi.台北", expect: ["class-span1"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
{name: "Class selector, matching element with class value using non-ASCII characters (1)", selector: ".\u53F0\u5317Ta\u0301ibe\u030Ci", expect: ["class-span1"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
{name: "Class selector, matching multiple elements with class value using non-ASCII characters", selector: ".\u53F0\u5317", expect: ["class-span1","class-span2"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
{name: "Class selector, chained, matching element with multiple class values using non-ASCII characters (1)", selector: ".\u53F0\u5317Ta\u0301ibe\u030Ci.\u53F0\u5317", expect: ["class-span1"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
{name: "Class selector, matching element with class with escaped character", selector: ".foo\\:bar", expect: ["class-span3"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
{name: "Class selector, matching element with class with escaped character", selector: ".test\\.foo\\[5\\]bar", expect: ["class-span4"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
|
||||
@ -282,10 +281,9 @@ var validSelectors = [
|
||||
{name: "ID selector, not matching non-existent ancestor", selector: "#none #id-div1", expect: [] /*no matches*/, level: 1, testType: TEST_QSA},
|
||||
{name: "ID selector, matching multiple elements with duplicate id", selector: "#id-li-duplicate", expect: ["id-li-duplicate", "id-li-duplicate", "id-li-duplicate", "id-li-duplicate"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
|
||||
// Caution: If copying and pasting the folowing non-ASCII IDs, ensure unicode normalisation is not performed in the process.
|
||||
{name: "ID selector, matching id value using non-ASCII characters", selector: "#台北Táiběi", expect: ["台北Táiběi"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
{name: "ID selector, matching id value using non-ASCII characters", selector: "#台北", expect: ["台北"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
{name: "ID selector, matching id values using non-ASCII characters", selector: "#台北Táiběi, #台北", expect: ["台北Táiběi", "台北"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
{name: "ID selector, matching id value using non-ASCII characters (1)", selector: "#\u53F0\u5317Ta\u0301ibe\u030Ci", expect: ["\u53F0\u5317Ta\u0301ibe\u030Ci"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
{name: "ID selector, matching id value using non-ASCII characters (2)", selector: "#\u53F0\u5317", expect: ["\u53F0\u5317"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
{name: "ID selector, matching id values using non-ASCII characters (1)", selector: "#\u53F0\u5317Ta\u0301ibe\u030Ci, #\u53F0\u5317", expect: ["\u53F0\u5317Ta\u0301ibe\u030Ci", "\u53F0\u5317"], level: 1, testType: TEST_QSA | TEST_MATCH},
|
||||
|
||||
// XXX runMatchesTest() in level2-lib.js can't handle this because obtaining the expected nodes requires escaping characters when generating the selector from 'expect' values
|
||||
{name: "ID selector, matching element with id with escaped character", selector: "#\\#foo\\:bar", expect: ["#foo:bar"], level: 1, testType: TEST_QSA},
|
||||
@ -631,10 +629,9 @@ var scopedSelectors = [
|
||||
{name: "Class selector, matching element with specified class (1)", selector: ".class-p", ctx: "", expect: ["class-p1","class-p2", "class-p3"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
{name: "Class selector, chained, matching only elements with all specified classes (1)", selector: "#class .apple.orange.banana", ctx: "", expect: ["class-div1", "class-div2", "class-p4", "class-div3", "class-p6", "class-div4"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
{name: "Class Selector, chained, with type selector (1)", selector: "div.apple.banana.orange", ctx: "", expect: ["class-div1", "class-div2", "class-div3", "class-div4"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
// Caution: If copying and pasting the folowing non-ASCII classes, ensure unicode normalisation is not performed in the process.
|
||||
{name: "Class selector, matching element with class value using non-ASCII characters", selector: ".台北Táiběi", ctx: "", expect: ["class-span1"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
{name: "Class selector, matching multiple elements with class value using non-ASCII characters (1)", selector: ".台北", ctx: "", expect: ["class-span1","class-span2"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
{name: "Class selector, chained, matching element with multiple class values using non-ASCII characters", selector: ".台北Táiběi.台北", ctx: "", expect: ["class-span1"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
{name: "Class selector, matching element with class value using non-ASCII characters (2)", selector: ".\u53F0\u5317Ta\u0301ibe\u030Ci", ctx: "", expect: ["class-span1"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
{name: "Class selector, matching multiple elements with class value using non-ASCII characters (1)", selector: ".\u53F0\u5317", ctx: "", expect: ["class-span1","class-span2"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
{name: "Class selector, chained, matching element with multiple class values using non-ASCII characters (2)", selector: ".\u53F0\u5317Ta\u0301ibe\u030Ci.\u53F0\u5317", ctx: "", expect: ["class-span1"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
{name: "Class selector, matching element with class with escaped character (1)", selector: ".foo\\:bar", ctx: "", expect: ["class-span3"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
{name: "Class selector, matching element with class with escaped character (1)", selector: ".test\\.foo\\[5\\]bar", ctx: "", expect: ["class-span4"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
|
||||
@ -647,10 +644,9 @@ var scopedSelectors = [
|
||||
{name: "ID selector, not matching non-existent ancestor", selector: "#none #id-div1", ctx: "", expect: [] /*no matches*/, level: 1, testType: TEST_FIND},
|
||||
{name: "ID selector, matching multiple elements with duplicate id (1)", selector: "#id-li-duplicate", ctx: "", expect: ["id-li-duplicate", "id-li-duplicate", "id-li-duplicate", "id-li-duplicate"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
|
||||
// Caution: If copying and pasting the folowing non-ASCII IDs, ensure unicode normalisation is not performed in the process.
|
||||
{name: "ID selector, matching id value using non-ASCII characters", selector: "#台北Táiběi", ctx: "", expect: ["台北Táiběi"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
{name: "ID selector, matching id value using non-ASCII characters (1)", selector: "#台北", ctx: "", expect: ["台北"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
{name: "ID selector, matching id values using non-ASCII characters", selector: "#台北Táiběi, #台北", ctx: "", expect: ["台北Táiběi", "台北"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
{name: "ID selector, matching id value using non-ASCII characters (3)", selector: "#\u53F0\u5317Ta\u0301ibe\u030Ci", ctx: "", expect: ["\u53F0\u5317Ta\u0301ibe\u030Ci"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
{name: "ID selector, matching id value using non-ASCII characters (4)", selector: "#\u53F0\u5317", ctx: "", expect: ["\u53F0\u5317"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
{name: "ID selector, matching id values using non-ASCII characters (2)", selector: "#\u53F0\u5317Ta\u0301ibe\u030Ci, #\u53F0\u5317", ctx: "", expect: ["\u53F0\u5317Ta\u0301ibe\u030Ci", "\u53F0\u5317"], level: 1, testType: TEST_FIND | TEST_MATCH},
|
||||
|
||||
// XXX runMatchesTest() in level2-lib.js can't handle this because obtaining the expected nodes requires escaping characters when generating the selector from 'expect' values
|
||||
{name: "ID selector, matching element with id with escaped character", selector: "#\\#foo\\:bar", ctx: "", expect: ["#foo:bar"], level: 1, testType: TEST_FIND},
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!doctype html>
|
||||
<title>Triggering navigation from withing beforeunload event</title>
|
||||
<title>Triggering navigation from within beforeunload event</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
|
@ -6,9 +6,11 @@
|
||||
<script>
|
||||
var iframe;
|
||||
var t = async_test();
|
||||
onload = setTimeout(function() {
|
||||
var iframe = document.getElementsByTagName("iframe")[0];
|
||||
iframe.src="about:blank";
|
||||
}, 100)
|
||||
onload = function() {
|
||||
setTimeout(function() {
|
||||
var iframe = document.getElementsByTagName("iframe")[0];
|
||||
iframe.src="about:blank";
|
||||
}, 100)
|
||||
};
|
||||
</script>
|
||||
<iframe src="008-1.html"></iframe>
|
||||
|
@ -6,9 +6,11 @@
|
||||
<script>
|
||||
var iframe;
|
||||
var t = async_test();
|
||||
onload = setTimeout(function() {
|
||||
var iframe = document.getElementsByTagName("iframe")[0];
|
||||
iframe.src="about:blank";
|
||||
}, 100)
|
||||
onload = function() {
|
||||
setTimeout(function() {
|
||||
var iframe = document.getElementsByTagName("iframe")[0];
|
||||
iframe.src="about:blank";
|
||||
}, 100)
|
||||
}
|
||||
</script>
|
||||
<iframe src="009-1.html"></iframe>
|
||||
|
@ -7,7 +7,8 @@
|
||||
<script>
|
||||
|
||||
var t1 = async_test("The window's frameElement attribute must return its container element if it is a nested browsing context");
|
||||
var t2 = async_test("The SecurityError must be thrown if the container's document does not have the same effective script origin");
|
||||
var t2 = async_test("The SecurityError must be thrown if the window accesses to frameElement attribute of a Window which does not have the same effective script origin");
|
||||
var t3 = async_test("The window's frameElement attribute must return null if the container's document does not have the same effective script origin");
|
||||
|
||||
function on_load() {
|
||||
t1.step(function () {
|
||||
@ -17,9 +18,9 @@ function on_load() {
|
||||
"The frameElement attribute should be the object element.");
|
||||
assert_equals(window["win3"].frameElement, document.getElementById("emb"),
|
||||
"The frameElement attribute should be the embed element.");
|
||||
assert_equals(document.getElementById("fr3").contentWindow[0].frameElement,
|
||||
document.getElementById("fr3").contentDocument.getElementById("f1"),
|
||||
"The frameElement attribute should be the frame element in 'test.html'.");
|
||||
assert_equals(document.getElementById("fr4").contentWindow[0].frameElement,
|
||||
document.getElementById("fr4").contentDocument.getElementById("f1"),
|
||||
"The frameElement attribute should be the frame element in 'test.html'.");
|
||||
});
|
||||
t1.done();
|
||||
|
||||
@ -28,23 +29,39 @@ function on_load() {
|
||||
"The SecurityError exception should be thrown.");
|
||||
});
|
||||
t2.done();
|
||||
|
||||
t3.step(function () {
|
||||
document.getElementById("fr5").contentWindow.postMessage(null, "*");
|
||||
});
|
||||
window.addEventListener("message", function (event) {
|
||||
var data = JSON.parse(event.data);
|
||||
if (data.name == "testcase3") {
|
||||
t3.step(function () {
|
||||
assert_equals(data.result, "window.frameElement = null",
|
||||
"The frameElement attribute should be null.");
|
||||
});
|
||||
t3.done();
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
</script>
|
||||
<body onload="on_load()">
|
||||
<div id="log"></div>
|
||||
<iframe id="fr1"></iframe>
|
||||
<iframe id="fr2" src="test.html"></iframe>
|
||||
<iframe id="fr2" src="test.html"></iframe> <!-- cross origin -->
|
||||
<iframe id="fr3" src="" style="display:none"></iframe>
|
||||
<object id="obj" name="win2" type="text/html" data="about:blank"></object>
|
||||
<embed id="emb" name="win3" type="image/svg+xml" src="/images/green.svg" />
|
||||
<iframe id="fr4" src="test.html"></iframe> <!-- same origin -->
|
||||
<iframe id="fr5" src="testcase3.html"></iframe> <!-- cross origin -->
|
||||
<script>
|
||||
|
||||
setup(function () {
|
||||
var src = "http://{{domains[www1]}}:{{ports[http][0]}}";
|
||||
src += document.location.pathname.substring(0, document.location.pathname.lastIndexOf("/") + 1);
|
||||
src += "test.html";
|
||||
document.getElementById("fr2").src = src;
|
||||
var src_base = "http://{{domains[www1]}}:{{ports[http][0]}}";
|
||||
src_base += document.location.pathname.substring(0, document.location.pathname.lastIndexOf("/") + 1);
|
||||
document.getElementById("fr2").src = src_base + "test.html";
|
||||
document.getElementById("fr5").src = src_base + "testcase3.html";
|
||||
});
|
||||
|
||||
test(function () {
|
||||
|
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Testcase 3: frameElement attribute must return null if the container\'s document does not have the same effective script origin</title>
|
||||
<script>
|
||||
window.addEventListener("message", function (event) {
|
||||
try {
|
||||
var result = "window.frameElement = " + window.frameElement;
|
||||
} catch (e) {
|
||||
result = e.message;
|
||||
}
|
||||
event.source.postMessage(JSON.stringify({name: "testcase3", result: result}),
|
||||
"*");
|
||||
}, false);
|
||||
</script>
|
@ -25,14 +25,18 @@
|
||||
var minutes = d.getMinutes()
|
||||
var seconds = d.getSeconds()
|
||||
|
||||
test(function() {
|
||||
var local_time = hours * 60 * 60 + minutes * 60 + seconds;
|
||||
var m = pattern.exec(last_modified);
|
||||
var last_modified_time = parseInt(m[1]) * 60 * 60 + parseInt(m[2]) * 60 + parseInt(m[3]);
|
||||
assert_approx_equals(last_modified_time, local_time, 2,
|
||||
"Hours and minutes should match local time.");
|
||||
}, "Date returned by lastModified is in the user's local time zone.");
|
||||
|
||||
// Checking whether d and and new instance of Date have the same timezone.
|
||||
// Do not run the time zone test in the case daylight saving occurs.
|
||||
var d2 = new Date();
|
||||
if (d2.getTimezoneOffset() == d.getTimezoneOffset()) {
|
||||
test(function() {
|
||||
var local_time = hours * 60 * 60 + minutes * 60 + seconds;
|
||||
var m = pattern.exec(last_modified);
|
||||
var last_modified_time = parseInt(m[1]) * 60 * 60 + parseInt(m[2]) * 60 + parseInt(m[3]);
|
||||
assert_approx_equals(last_modified_time, local_time, 2,
|
||||
"Hours and minutes should match local time.");
|
||||
}, "Date returned by lastModified is in the user's local time zone.");
|
||||
}
|
||||
var t = async_test("Date returned by lastModified is current after timeout.");
|
||||
|
||||
setTimeout(function() {
|
||||
|
@ -141,7 +141,7 @@ var embeddedElements = {
|
||||
hreflang: "string",
|
||||
type: "string",
|
||||
|
||||
//URLUtils
|
||||
// HTMLHyperlinkElementUtils
|
||||
href: "url",
|
||||
|
||||
// Obsolete
|
||||
|
@ -10,7 +10,7 @@ var textElements = {
|
||||
hreflang: "string",
|
||||
type: "string",
|
||||
|
||||
// URLUtils
|
||||
// HTMLHyperlinkElementUtils
|
||||
href: "url",
|
||||
|
||||
// Obsolete
|
||||
|
@ -11,16 +11,6 @@
|
||||
<h1>HTML IDL tests</h1>
|
||||
<div id=log></div>
|
||||
|
||||
<!-- URLUtils* stubs -->
|
||||
<script type=text/plain class=untested>
|
||||
interface URLUtils {
|
||||
stringifier;
|
||||
};
|
||||
interface URLUtilsReadOnly {
|
||||
stringifier;
|
||||
};
|
||||
</script>
|
||||
<!-- DOM IDLs -->
|
||||
<script type=text/plain class=untested>
|
||||
[Constructor(DOMString type, optional EventInit eventInitDict)/*,
|
||||
Exposed=(Window,Worker)*/]
|
||||
@ -868,6 +858,21 @@ typedef (Int8Array or Uint8Array or Uint8ClampedArray or
|
||||
Float32Array or Float64Array or
|
||||
DataView) ArrayBufferView;
|
||||
|
||||
[NoInterfaceObject, Exposed=Window]
|
||||
interface HTMLHyperlinkElementUtils {
|
||||
stringifier attribute USVString href;
|
||||
attribute USVString origin;
|
||||
attribute USVString protocol;
|
||||
attribute USVString username;
|
||||
attribute USVString password;
|
||||
attribute USVString host;
|
||||
attribute USVString hostname;
|
||||
attribute USVString port;
|
||||
attribute USVString pathname;
|
||||
attribute USVString search;
|
||||
attribute USVString hash;
|
||||
};
|
||||
|
||||
interface HTMLAllCollection : HTMLCollection {
|
||||
// inherits length and 'getter'
|
||||
Element? item(unsigned long index);
|
||||
@ -1125,19 +1130,17 @@ interface HTMLDivElement : HTMLElement {
|
||||
};
|
||||
|
||||
interface HTMLAnchorElement : HTMLElement {
|
||||
attribute DOMString target;
|
||||
attribute DOMString download;
|
||||
[PutForwards=value] attribute DOMSettableTokenList ping;
|
||||
attribute DOMString rel;
|
||||
attribute DOMString target;
|
||||
attribute DOMString download;
|
||||
[PutForwards=value] readonly attribute DOMSettableTokenList ping;
|
||||
attribute DOMString rel;
|
||||
readonly attribute DOMTokenList relList;
|
||||
attribute DOMString hreflang;
|
||||
attribute DOMString type;
|
||||
attribute DOMString hreflang;
|
||||
attribute DOMString type;
|
||||
|
||||
attribute DOMString text;
|
||||
|
||||
// also has obsolete members
|
||||
attribute DOMString text;
|
||||
};
|
||||
HTMLAnchorElement implements URLUtils;
|
||||
HTMLAnchorElement implements HTMLHyperlinkElementUtils;
|
||||
|
||||
interface HTMLDataElement : HTMLElement {
|
||||
attribute DOMString value;
|
||||
@ -1494,20 +1497,17 @@ interface HTMLMapElement : HTMLElement {
|
||||
};
|
||||
|
||||
interface HTMLAreaElement : HTMLElement {
|
||||
attribute DOMString alt;
|
||||
attribute DOMString coords;
|
||||
attribute DOMString shape;
|
||||
attribute DOMString target;
|
||||
attribute DOMString download;
|
||||
[PutForwards=value] attribute DOMSettableTokenList ping;
|
||||
attribute DOMString rel;
|
||||
attribute DOMString alt;
|
||||
attribute DOMString coords;
|
||||
attribute DOMString shape;
|
||||
attribute DOMString target;
|
||||
attribute DOMString download;
|
||||
[PutForwards=value] readonly attribute DOMSettableTokenList ping;
|
||||
attribute DOMString rel;
|
||||
readonly attribute DOMTokenList relList;
|
||||
attribute DOMString hreflang;
|
||||
attribute DOMString type;
|
||||
|
||||
// also has obsolete members
|
||||
// hreflang and type are not reflected
|
||||
};
|
||||
HTMLAreaElement implements URLUtils;
|
||||
HTMLAreaElement implements HTMLHyperlinkElementUtils;
|
||||
|
||||
interface HTMLTableElement : HTMLElement {
|
||||
attribute HTMLTableCaptionElement? caption;
|
||||
@ -2320,11 +2320,22 @@ interface History {
|
||||
};
|
||||
|
||||
[Unforgeable] interface Location {
|
||||
void assign(DOMString url);
|
||||
void replace(DOMString url);
|
||||
stringifier attribute USVString href;
|
||||
attribute USVString origin;
|
||||
attribute USVString protocol;
|
||||
attribute USVString host;
|
||||
attribute USVString hostname;
|
||||
attribute USVString port;
|
||||
attribute USVString pathname;
|
||||
attribute USVString search;
|
||||
attribute USVString hash;
|
||||
|
||||
void assign(USVString url);
|
||||
void replace(USVString url);
|
||||
void reload();
|
||||
|
||||
[SameObject] readonly attribute USVString[] ancestorOrigins;
|
||||
};
|
||||
Location implements URLUtils;
|
||||
|
||||
[Constructor(DOMString type, optional PopStateEventInit eventInitDict), Exposed=Window,Worker]
|
||||
interface PopStateEvent : Event {
|
||||
@ -2816,8 +2827,17 @@ WorkerNavigator implements NavigatorLanguage;
|
||||
WorkerNavigator implements NavigatorOnLine;
|
||||
|
||||
[Exposed=Worker]
|
||||
interface WorkerLocation { };
|
||||
WorkerLocation implements URLUtilsReadOnly;
|
||||
interface WorkerLocation {
|
||||
stringifier readonly attribute USVString href;
|
||||
readonly attribute USVString origin;
|
||||
readonly attribute USVString protocol;
|
||||
readonly attribute USVString host;
|
||||
readonly attribute USVString hostname;
|
||||
readonly attribute USVString port;
|
||||
readonly attribute USVString pathname;
|
||||
readonly attribute USVString search;
|
||||
readonly attribute USVString hash;
|
||||
};
|
||||
|
||||
interface Storage {
|
||||
readonly attribute unsigned long length;
|
||||
|
@ -9,7 +9,7 @@
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<body id="tags">
|
||||
<img src="../../../../images/green.png" name="picture">
|
||||
<script>
|
||||
test(function(){ assert_equals(document.all.length,12)}, "Test for HTMLAllCollection size");
|
||||
@ -18,8 +18,6 @@ test(function(){ assert_equals(document.all.item(0).tagName,"HTML")}, "Test look
|
||||
|
||||
test(function(){ assert_equals(document.all[0].tagName,"HTML")}, "Test lookup by index using []");
|
||||
|
||||
test(function(){ assert_equals(document.all.tags("script").length,3)}, "Test for multiple occurence 3 <script> found");
|
||||
|
||||
test(function(){ assert_equals(document.all.item("picture").nodeName,"IMG")}, "Test lookup IMG by name");
|
||||
|
||||
test(function(){ assert_equals(document.all.namedItem("picture").nodeName,"IMG")}, "Test lookup IMG by namedItem ");
|
||||
@ -27,7 +25,11 @@ test(function(){ assert_equals(document.all.namedItem("picture").nodeName,"IMG")
|
||||
test(function(){ assert_equals(document.all("picture").nodeName,"IMG")}, "Test lookup IMG in collection using ()");
|
||||
|
||||
test(function(){ assert_equals(document.all["picture"].nodeName,"IMG")}, "Test lookup IMG in collection using []");
|
||||
|
||||
test(function(){ assert_equals(document.all.picture.nodeName,"IMG")}, "Test lookup IMG in collection using .");
|
||||
|
||||
test(function(){ assert_equals(document.all.tags.id,"tags")}, "Test lookup tags in collection using .");
|
||||
</script>
|
||||
<div id="log"></div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
@ -18,8 +18,12 @@
|
||||
<input type="checkbox" name="cb">
|
||||
</td>
|
||||
</tr>
|
||||
<button id="btn"></button>
|
||||
<button name="btn"></button>
|
||||
<tr>
|
||||
<td>
|
||||
<button id="btn"></button>
|
||||
<button name="btn"></button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
@ -50,8 +54,8 @@ test(function () {
|
||||
|
||||
//getter - name
|
||||
test(function () {
|
||||
assert_equals(coll1("r1"), rdo, "HTMLFormControlsCollection(name) should return the 'input' element in radio status.");
|
||||
}, "HTMLFormControlsCollection(name) must return the named item");
|
||||
assert_throws(TypeError(), function() { coll1("r1") });
|
||||
}, "HTMLFormControlsCollection is not callable");
|
||||
|
||||
test(function () {
|
||||
assert_equals(coll1["r1"], rdo, "HTMLFormControlsCollection[name] should return the 'input' element in radio status.");
|
||||
|
@ -16,8 +16,8 @@ test(function() {
|
||||
var script = document.createElement("script");
|
||||
script.setAttribute("event", "blah");
|
||||
script.setAttribute("for", "blah");
|
||||
assert_equals(script.event, "");
|
||||
assert_equals(script.htmlFor, "");
|
||||
assert_equals(script.event, "blah");
|
||||
assert_equals(script.htmlFor, "blah");
|
||||
assert_equals(script.getAttribute("event"), "blah");
|
||||
assert_equals(script.getAttribute("for"), "blah");
|
||||
})
|
||||
@ -27,10 +27,10 @@ test(function() {
|
||||
script.setAttribute("for", "blah");
|
||||
script.event = "foo";
|
||||
script.htmlFor = "foo";
|
||||
assert_equals(script.event, "");
|
||||
assert_equals(script.htmlFor, "");
|
||||
assert_equals(script.getAttribute("event"), "blah");
|
||||
assert_equals(script.getAttribute("for"), "blah");
|
||||
assert_equals(script.event, "foo");
|
||||
assert_equals(script.htmlFor, "foo");
|
||||
assert_equals(script.getAttribute("event"), "foo");
|
||||
assert_equals(script.getAttribute("for"), "foo");
|
||||
})
|
||||
test(function() {
|
||||
var script = document.createElement("script");
|
||||
@ -38,10 +38,10 @@ test(function() {
|
||||
script.setAttribute("for", "blah");
|
||||
script.event = null;
|
||||
script.htmlFor = null;
|
||||
assert_equals(script.event, "");
|
||||
assert_equals(script.htmlFor, "");
|
||||
assert_equals(script.getAttribute("event"), "blah");
|
||||
assert_equals(script.getAttribute("for"), "blah");
|
||||
assert_equals(script.event, "null");
|
||||
assert_equals(script.htmlFor, "null");
|
||||
assert_equals(script.getAttribute("event"), "null");
|
||||
assert_equals(script.getAttribute("for"), "null");
|
||||
})
|
||||
test(function() {
|
||||
var script = document.createElement("script");
|
||||
@ -49,9 +49,9 @@ test(function() {
|
||||
script.setAttribute("for", "blah");
|
||||
script.event = undefined;
|
||||
script.htmlFor = undefined;
|
||||
assert_equals(script.event, "");
|
||||
assert_equals(script.htmlFor, "");
|
||||
assert_equals(script.getAttribute("event"), "blah");
|
||||
assert_equals(script.getAttribute("for"), "blah");
|
||||
assert_equals(script.event, "undefined");
|
||||
assert_equals(script.htmlFor, "undefined");
|
||||
assert_equals(script.getAttribute("event"), "undefined");
|
||||
assert_equals(script.getAttribute("for"), "undefined");
|
||||
})
|
||||
</script>
|
||||
|
@ -0,0 +1,77 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=utf-8>
|
||||
<link rel="match" href="div-align-ref.html">
|
||||
<style>
|
||||
.test { width: 50px; background-color: yellow; }
|
||||
.center { text-align: center; }
|
||||
.center .test { margin: 0 auto; }
|
||||
.left { text-align: left; }
|
||||
.left .test { margin-right: auto; }
|
||||
.right { text-align: right; }
|
||||
.right .test { margin-left: auto; }
|
||||
.rtl { direction: rtl; }
|
||||
.ltr { direction: ltr; }
|
||||
.left .margin { margin-left: 1em; }
|
||||
.right .margin { margin-right: 1em; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Centered tests -->
|
||||
<div class=center>
|
||||
<div class=test>t א</div>
|
||||
<div class="test rtl">t א</div>
|
||||
<div class="test margin">t א</div>
|
||||
</div>
|
||||
|
||||
<div class=center>
|
||||
<div class="test left">t א</div>
|
||||
<div class="test right">t א</div>
|
||||
</div>
|
||||
|
||||
<div class=left>
|
||||
<div class=center>
|
||||
<div class=test>t א</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Left-aligned tests -->
|
||||
<div class=left>
|
||||
<div class=test>t א</div>
|
||||
<div class="test rtl">t א</div>
|
||||
<div class="test margin">t א</div>
|
||||
</div>
|
||||
|
||||
<div class="left rtl">
|
||||
<div class=test>t א</div>
|
||||
<div class="test ltr">t א</div>
|
||||
<div class="test margin">t א</div>
|
||||
</div>
|
||||
|
||||
<div class=left>
|
||||
<div class="test center">t א</div>
|
||||
<div class="test right">t א</div>
|
||||
</div>
|
||||
|
||||
<!-- Right-aligned tests -->
|
||||
<div class=right>
|
||||
<div class=test>t א</div>
|
||||
<div class="test rtl">t א</div>
|
||||
<div class="test margin">t א</div>
|
||||
</div>
|
||||
|
||||
<div class="right rtl">
|
||||
<div class=test>t א</div>
|
||||
<div class="test ltr">t א</div>
|
||||
<div class="test margin">t א</div>
|
||||
</div>
|
||||
|
||||
<div class=right>
|
||||
<div class="test left">t א</div>
|
||||
<div class="test center">t א</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -0,0 +1,70 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=utf-8>
|
||||
<style>
|
||||
.test { width: 50px; background-color: yellow; }
|
||||
.rtl { direction: rtl; }
|
||||
.ltr { direction: ltr; }
|
||||
[align=left] .margin { margin-left: 1em }
|
||||
[align=right] .margin { margin-right: 1em }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Centered tests -->
|
||||
<div align=center>
|
||||
<div class=test>t א</div>
|
||||
<div class="test rtl">t א</div>
|
||||
<div class="test margin">t א</div>
|
||||
</div>
|
||||
|
||||
<div align=center>
|
||||
<div class=test align=left>t א</div>
|
||||
<div class=test align=right>t א</div>
|
||||
</div>
|
||||
|
||||
<div align=left>
|
||||
<div align=center>
|
||||
<div class=test>t א</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Left-aligned tests -->
|
||||
<div align=left>
|
||||
<div class=test>t א</div>
|
||||
<div class="test rtl">t א</div>
|
||||
<div class="test margin">t א</div>
|
||||
</div>
|
||||
|
||||
<div align=left class=rtl>
|
||||
<div class=test>t א</div>
|
||||
<div class="test ltr">t א</div>
|
||||
<div class="test margin">t א</div>
|
||||
</div>
|
||||
|
||||
<div align=left>
|
||||
<div class=test align=center>t א</div>
|
||||
<div class=test align=right>t א</div>
|
||||
</div>
|
||||
|
||||
<!-- Right-aligned tests -->
|
||||
<div align=right>
|
||||
<div class=test>t א</div>
|
||||
<div class="test rtl">t א</div>
|
||||
<div class="test margin">t א</div>
|
||||
</div>
|
||||
|
||||
<div align=right class=rtl>
|
||||
<div class=test>t א</div>
|
||||
<div class="test ltr">t א</div>
|
||||
<div class="test margin">t א</div>
|
||||
</div>
|
||||
|
||||
<div align=right>
|
||||
<div class=test align=left>t א</div>
|
||||
<div class=test align=center>t א</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -285,30 +285,10 @@ var validator = {
|
||||
},
|
||||
|
||||
set_dirty: function(ctl) {
|
||||
document.designMode = "on";
|
||||
ctl.focus();
|
||||
var old_value = ctl.value;
|
||||
ctl.value = "a";
|
||||
ctl.value = old_value;
|
||||
if (
|
||||
// See https://html.spec.whatwg.org/multipage/#input-type-attr-summary
|
||||
// and https://html.spec.whatwg.org/multipage/#textFieldSelection
|
||||
(
|
||||
ctl.tagName === "INPUT" && (
|
||||
ctl.type === "text" ||
|
||||
ctl.type === "search" ||
|
||||
ctl.type === "tel" ||
|
||||
ctl.type === "url" ||
|
||||
ctl.type === "password"
|
||||
)
|
||||
) ||
|
||||
ctl.tagName === "TEXTAREA"
|
||||
) {
|
||||
ctl.value += "1";
|
||||
ctl.setSelectionRange(ctl.value.length - 1, ctl.value.length);
|
||||
document.execCommand("Delete");
|
||||
}
|
||||
document.designMode = "off";
|
||||
},
|
||||
|
||||
pre_check: function(ctl, item) {
|
||||
|
@ -74,4 +74,19 @@ test(function() {
|
||||
option.appendChild(document.createTextNode("text"));
|
||||
assert_equals(option.text, "text");
|
||||
}, "option.text should work if the option is in a MathML script element");
|
||||
|
||||
test(function() {
|
||||
var option = document.createElement("option");
|
||||
option.appendChild(document.createTextNode("te"));
|
||||
option.appendChild(document.createComment("comment"));
|
||||
option.appendChild(document.createTextNode("xt"));
|
||||
assert_equals(option.text, "text");
|
||||
}, "option.text should ignore comment children");
|
||||
test(function() {
|
||||
var option = document.createElement("option");
|
||||
option.appendChild(document.createTextNode("te"));
|
||||
option.appendChild(document.createProcessingInstruction("target", "data"));
|
||||
option.appendChild(document.createTextNode("xt"));
|
||||
assert_equals(option.text, "text");
|
||||
}, "option.text should ignore PI children");
|
||||
</script>
|
||||
|
@ -5,6 +5,8 @@
|
||||
<title id='title'>HTMLOptionsCollection</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<select id="selly">
|
||||
<option id="id1" name="name1">1</option>
|
||||
@ -37,26 +39,16 @@ test(function () {
|
||||
}, "if no item has a name or id value matching the parameter, return null and stop");
|
||||
|
||||
test(function () {
|
||||
var testarr = [];
|
||||
for (var i = 0; i < selly.namedItem('id3').length; i++) {
|
||||
testarr.push(selly.namedItem('id3')[i].text);
|
||||
}
|
||||
assert_array_equals(testarr, ['3','duplicate ID']);
|
||||
}, "return an HTMLOptionsCollection in correct order for repeated 'id' value");
|
||||
assert_equals(selly.namedItem('id3')["value"], "3");
|
||||
}, "if multiple items have a name or *id* value matching the parameter, return the first object and stop");
|
||||
|
||||
test(function () {
|
||||
var testarr = [];
|
||||
for (var i = 0; i < selly.namedItem('name4').length; i++) {
|
||||
testarr.push(selly.namedItem('name4')[i].text);
|
||||
}
|
||||
assert_array_equals(testarr, ['4', 'duplicate name']);
|
||||
}, "return an HTMLOptionsCollection in correct order for repeated 'name' value");
|
||||
assert_equals(selly.namedItem('name4')["value"], "4");
|
||||
}, "if multiple items have a *name* or id value matching the parameter, return the first object and stop");
|
||||
|
||||
test(function () {
|
||||
var testarr = [];
|
||||
for (var i = 0; i < selly.namedItem('mixed1').length; i++) {
|
||||
testarr.push(selly.namedItem('mixed1')[i].text);
|
||||
}
|
||||
assert_array_equals(testarr, ['mixed ID', 'mixed name']);
|
||||
}, "return an HTMLOptionsCollection in correct order for repeated mixed value");
|
||||
assert_equals(selly.namedItem('mixed1')["value"], "mixed ID");
|
||||
}, "if multiple items have a *name* or *id* value matching the parameter, return the first object and stop");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -0,0 +1,97 @@
|
||||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>HTMLSelectElement ask for reset</title>
|
||||
<link rel="author" title="Dongie Agnir" href="dongie.agnir@gmail.com">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
test(function() {
|
||||
var select = makeSelect(5);
|
||||
|
||||
select.children[4].selected = true;
|
||||
unselectedExcept(select, 4);
|
||||
|
||||
select.children[4].remove();
|
||||
unselectedExcept(select, 0); // remove selected node, should default to first
|
||||
|
||||
select.children[3].selected = true;
|
||||
|
||||
select.children[0].remove();
|
||||
unselectedExcept(select, 2); // last node still selected
|
||||
|
||||
select.size = 2;
|
||||
select.children[2].remove();
|
||||
|
||||
unselectedExcept(select, null);
|
||||
}, "ask for reset on node remove, non multiple.");
|
||||
|
||||
test(function() {
|
||||
var select = makeSelect(3);
|
||||
select.children[1].selected = true;
|
||||
|
||||
// insert selected option, should remain selected
|
||||
var opt4 = document.createElement("option");
|
||||
opt4.selected = true;
|
||||
select.appendChild(opt4);
|
||||
unselectedExcept(select, 3);
|
||||
|
||||
// insert unselected, 3 should remain selected
|
||||
var opt5 = document.createElement("option");
|
||||
select.appendChild(opt5);
|
||||
unselectedExcept(select, 3);
|
||||
}, "ask for reset on node insert, non multiple.");
|
||||
|
||||
test(function() {
|
||||
var select = makeSelect(3);
|
||||
|
||||
var options = select.children;
|
||||
|
||||
// select options from first to last
|
||||
for (var i = 0; i < options.length; ++i) {
|
||||
options[i].selected = true;
|
||||
unselectedExcept(select, i);
|
||||
}
|
||||
|
||||
// select options from last to first
|
||||
for (var i = options.length - 1; i >= 0; --i) {
|
||||
options[i].selected = true;
|
||||
unselectedExcept(select, i);
|
||||
}
|
||||
|
||||
options[2].selected = true;
|
||||
options[2].selected = false; // none selected
|
||||
unselectedExcept(select, 0);
|
||||
|
||||
// disable first so option at index 1 is first eligible
|
||||
options[0].disabled = true;
|
||||
options[2].selected = true;
|
||||
options[2].selected = false; // none selected
|
||||
unselectedExcept(select, 1);
|
||||
|
||||
select.size = 2;
|
||||
options[1].selected = false;
|
||||
unselectedExcept(select, null); // size > 1 so should not default to any
|
||||
}, "change selectedness of option, non multiple.");
|
||||
|
||||
|
||||
function unselectedExcept(sel, opt) {
|
||||
for (var i = 0; i < sel.children.length; ++i) {
|
||||
if (i != opt) {
|
||||
assert_false(sel.children[i].selected, "option should not be selected.");
|
||||
}
|
||||
if (opt != null) {
|
||||
assert_true(sel.children[opt].selected, "option should be selected.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function makeSelect(n) {
|
||||
var sel = document.createElement("select");
|
||||
for (var i = 0; i < n; ++i) {
|
||||
opt = document.createElement("option");
|
||||
sel.appendChild(opt);
|
||||
}
|
||||
return sel;
|
||||
}
|
||||
</script>
|
@ -38,4 +38,13 @@ test(function() {
|
||||
var td = tr.appendChild(document.createElement("td"));
|
||||
assert_equals(td.cellIndex, 1);
|
||||
}, "For cells whose parent is a tr, cellIndex should be the index.")
|
||||
test(function() {
|
||||
var tr = document.createElement("tr");
|
||||
var th = tr.appendChild(document.createElement("th"));
|
||||
assert_equals(th.cellIndex, 0);
|
||||
tr.appendChild(document.createElement("div"));
|
||||
tr.appendChild(document.createTextNode("Hello World"));
|
||||
var td = tr.appendChild(document.createElement("td"));
|
||||
assert_equals(td.cellIndex, 1)
|
||||
}, "For cells whose parent is a tr with non td/th sibling, cellIndex should skip those non td/th siblings.")
|
||||
</script>
|
||||
|
@ -43,4 +43,12 @@ test(function () {
|
||||
});
|
||||
}, "HTMLTableSectionElement deleteRow(-2)");
|
||||
|
||||
test(function () {
|
||||
assert_equals(tbody.rows.length, 1);
|
||||
tbody.deleteRow(-1);
|
||||
assert_equals(tbody.rows.length, 0);
|
||||
tbody.deleteRow(-1);
|
||||
assert_equals(tbody.rows.length, 0);
|
||||
}, "HTMLTableSectionElement deleteRow(-1) with no rows");
|
||||
|
||||
</script>
|
||||
|
@ -35,6 +35,12 @@ test(function () {
|
||||
assert_equals(tbody.rows.length, 4);
|
||||
}, "HTMLTableSectionElement insertRow()");
|
||||
|
||||
test(function () {
|
||||
var trEle = tbody.insertRow(tbody.rows.length);
|
||||
assert_equals(tbody.rows[tbody.rows.length - 1], trEle);
|
||||
assert_equals(tbody.rows.length, 5);
|
||||
}, "HTMLTableSectionElement insertRow(rows.length)");
|
||||
|
||||
test(function () {
|
||||
assert_throws("IndexSizeError", function () {
|
||||
tbody.insertRow(-2);
|
||||
|
@ -43,4 +43,12 @@ test(function () {
|
||||
});
|
||||
}, "HTMLTableRowElement deleteCell(cells.length)");
|
||||
|
||||
test(function () {
|
||||
assert_equals(tr.cells.length, 1);
|
||||
tr.deleteCell(-1);
|
||||
assert_equals(tr.cells.length, 0);
|
||||
tr.deleteCell(-1);
|
||||
assert_equals(tr.cells.length, 0);
|
||||
}, "HTMLTableRowElement deleteCell(-1) with no cells");
|
||||
|
||||
</script>
|
||||
|
@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>AnimationTiming Test: multiple calls to requestAnimationFrame with the same callback</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/webappapis.html#dom-window-requestanimationframe">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
|
||||
async_test(function(t) {
|
||||
var counter = 0;
|
||||
window.requestAnimationFrame(callback);
|
||||
|
||||
function callback() {
|
||||
++counter;
|
||||
if (counter == 2) {
|
||||
t.done();
|
||||
} else {
|
||||
window.requestAnimationFrame(callback);
|
||||
}
|
||||
};
|
||||
|
||||
}, "Check that multiple calls to requestAnimationFrame with the same callback will result in multiple entries being in the list with that same callback.");
|
||||
|
||||
</script>
|
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<title>HTMLBodyElement event handlers</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<body>
|
||||
<script>
|
||||
function f() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var handlers = ['blur','error','focus','load','resize','scroll',
|
||||
'afterprint','beforeprint','beforeunload','hashchange',
|
||||
'languagechange','message','offline','online','pagehide',
|
||||
'pageshow','popstate','storage','unload'];
|
||||
handlers.forEach(function(handler) {
|
||||
test(function() {
|
||||
document.body['on' + handler] = f;
|
||||
assert_equals(window['on' + handler], f);
|
||||
}, handler);
|
||||
});
|
||||
|
||||
</script>
|
@ -24,7 +24,6 @@ INDENT TABS: tools/*
|
||||
INDENT TABS: touch-events/*
|
||||
INDENT TABS: web-animations/*
|
||||
INDENT TABS: webaudio/*
|
||||
INDENT TABS: webdriver/*
|
||||
INDENT TABS: webvtt/*
|
||||
INDENT TABS: XMLHttpRequest/*
|
||||
|
||||
@ -43,7 +42,6 @@ TRAILING WHITESPACE: shadow-dom/*
|
||||
TRAILING WHITESPACE: svg/import/*
|
||||
TRAILING WHITESPACE: tools/*
|
||||
TRAILING WHITESPACE: webaudio/*
|
||||
TRAILING WHITESPACE: webdriver/*
|
||||
TRAILING WHITESPACE: WebIDL/*
|
||||
TRAILING WHITESPACE: webvtt/*
|
||||
TRAILING WHITESPACE: XMLHttpRequest/*
|
||||
@ -108,3 +106,6 @@ W3C-TEST.ORG:subresource-integrity/refresh-header.js.headers
|
||||
# Lint doesn't know about sub.svg I guess
|
||||
PARSE-FAILED:content-security-policy/svg/including.sub.svg
|
||||
|
||||
#Helper files that aren't valid XML
|
||||
PARSE-FAILED:dom/nodes/Document-createElement-namespace-tests/empty.xml
|
||||
PARSE-FAILED:dom/nodes/Document-createElement-namespace-tests/minimal_html.xml
|
@ -34,6 +34,7 @@
|
||||
<script type='text/javascript'>
|
||||
var isPointerCapture = false;
|
||||
var isRelatedTargetValueTested = false;
|
||||
var isTargetAuthenticityTested = false;
|
||||
var count = 0;
|
||||
|
||||
var detected_pointertypes = {};
|
||||
@ -92,6 +93,13 @@
|
||||
}, "relatedTarget is null when the capture is set. relatedTarget is " + event.relatedTarget);
|
||||
isRelatedTargetValueTested = true;
|
||||
}
|
||||
var hitTest = document.elementFromPoint(event.clientX, event.clientY);
|
||||
if(event.target !== hitTest && !isTargetAuthenticityTested) {
|
||||
test(function () {
|
||||
assert_unreached("pointerover for this target shouldn't trigger events on capture target");
|
||||
}, "pointerover should only trigger over the black rectangle");
|
||||
isTargetAuthenticityTested = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
test_pointerover_no_capture.done();
|
||||
|
@ -1176,6 +1176,7 @@ policies and contribution forms [3].
|
||||
NO_MODIFICATION_ALLOWED_ERR: 'NoModificationAllowedError',
|
||||
NOT_FOUND_ERR: 'NotFoundError',
|
||||
NOT_SUPPORTED_ERR: 'NotSupportedError',
|
||||
INUSE_ATTRIBUTE_ERR: 'InUseAttributeError',
|
||||
INVALID_STATE_ERR: 'InvalidStateError',
|
||||
SYNTAX_ERR: 'SyntaxError',
|
||||
INVALID_MODIFICATION_ERR: 'InvalidModificationError',
|
||||
@ -1202,6 +1203,7 @@ policies and contribution forms [3].
|
||||
NoModificationAllowedError: 7,
|
||||
NotFoundError: 8,
|
||||
NotSupportedError: 9,
|
||||
InUseAttributeError: 10,
|
||||
InvalidStateError: 11,
|
||||
SyntaxError: 12,
|
||||
InvalidModificationError: 13,
|
||||
|
@ -1,2 +1,2 @@
|
||||
Access-Control-Allow-Origin: {{location[scheme]}}://{{domains[]}}:{{location[port]}}
|
||||
Access-Control-Allow-Origin: {{location[scheme]}}://{{domains[]}}{{GET[acao_port]}}
|
||||
Access-Control-Allow-Credentials: true
|
||||
|
@ -1,2 +1,2 @@
|
||||
Access-Control-Allow-Origin: {{location[scheme]}}://{{domains[]}}:{{location[port]}}
|
||||
Access-Control-Allow-Origin: {{location[scheme]}}://{{domains[]}}{{GET[acao_port]}}
|
||||
Access-Control-Allow-Credentials: true
|
||||
|
@ -1,24 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Subresource Integrity</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../../resources/testharness.js"></script>
|
||||
<script src="../../../resources/testharnessreport.js"></script>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<div id="container"></div>
|
||||
<script>
|
||||
// This horrible hack is needed for the 'use-credentials' tests because, on
|
||||
// response, if port 80 or 443 is the current port, it will not appear to
|
||||
// the browser as part of the origin string. Since the origin *string* is
|
||||
// used for CORS access control, instead of the origin itself, if there
|
||||
// isn't an exact string match, the check will fail. For example,
|
||||
// "http://example.com" would not match "http://example.com:80", because
|
||||
// they are not exact string matches, even though the origins are the same.
|
||||
//
|
||||
// Thus, we only want the Access-Control-Allow-Origin header to have
|
||||
// the port if it's not port 80 or 443, since the user agent will elide the
|
||||
// ports in those cases.
|
||||
var main_domain = "{{domains[]}}";
|
||||
var www_domain = "{{domains[www]}}";
|
||||
var default_port = "{{ports[http][0]}}";
|
||||
if (location.protocol === "https:") {
|
||||
default_port = "{{ports[https][0]}}";
|
||||
}
|
||||
|
||||
var port_string = "";
|
||||
if (default_port !== "80" && default_port !== "443")
|
||||
port_string = ":" + default_port;
|
||||
|
||||
www_host_and_port = www_domain + port_string;
|
||||
|
||||
// <script> tests
|
||||
var xorigin_anon_script = location.protocol
|
||||
+ '//www1.' + location.hostname + ':' + location.port
|
||||
+ '//' + www_host_and_port
|
||||
+ '/subresource-integrity/crossorigin-anon-script.js';
|
||||
|
||||
var xorigin_creds_script = location.protocol
|
||||
+ '//www1.' + location.hostname + ':' + location.port
|
||||
+ '/subresource-integrity/crossorigin-creds-script.js';
|
||||
+ '//' + www_host_and_port
|
||||
+ '/subresource-integrity/crossorigin-creds-script.js?acao_port='
|
||||
+ port_string;
|
||||
|
||||
var xorigin_ineligible_script = location.protocol
|
||||
+ '//www1.' + location.hostname + ':' + location.port
|
||||
+ '//' + www_host_and_port
|
||||
+ '/subresource-integrity/crossorigin-ineligible-script.js';
|
||||
|
||||
var SRIScriptTest = function(pass, name, src, integrityValue, crossoriginValue) {
|
||||
@ -51,17 +76,20 @@
|
||||
document.body.appendChild(e);
|
||||
};
|
||||
|
||||
// Note that all of these style URLs have query parameters started, so any
|
||||
// additional parameters should be appended starting with '&'.
|
||||
var xorigin_anon_style = location.protocol
|
||||
+ '//www1.' + location.hostname + ':' + location.port
|
||||
+ '/subresource-integrity/crossorigin-anon-style.css';
|
||||
+ '//' + www_host_and_port
|
||||
+ '/subresource-integrity/crossorigin-anon-style.css?';
|
||||
|
||||
var xorigin_creds_style = location.protocol
|
||||
+ '//www1.' + location.hostname + ':' + location.port
|
||||
+ '/subresource-integrity/crossorigin-creds-style.css';
|
||||
+ '//' + www_host_and_port
|
||||
+ '/subresource-integrity/crossorigin-creds-style.css?acao_port='
|
||||
+ port_string;
|
||||
|
||||
var xorigin_ineligible_style = location.protocol
|
||||
+ '//www1.' + location.hostname + ':' + location.port
|
||||
+ '/subresource-integrity/crossorigin-ineligible-style.css';
|
||||
+ '//' + www_host_and_port
|
||||
+ '/subresource-integrity/crossorigin-ineligible-style.css?';
|
||||
|
||||
// <link> tests
|
||||
// Style tests must be done synchronously because they rely on the presence
|
||||
@ -376,7 +404,7 @@
|
||||
true,
|
||||
"<crossorigin='anonymous'> with correct hash, ACAO: *",
|
||||
{
|
||||
href: xorigin_anon_style + '?1',
|
||||
href: xorigin_anon_style + '&1',
|
||||
integrity: "sha256-CzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk7gyCWUV4=",
|
||||
crossorigin: "anonymous"
|
||||
}
|
||||
@ -387,7 +415,7 @@
|
||||
false,
|
||||
"<crossorigin='anonymous'> with incorrect hash, ACAO: *",
|
||||
{
|
||||
href: xorigin_anon_style + '?2',
|
||||
href: xorigin_anon_style + '&2',
|
||||
integrity: "sha256-deadbeefCzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk=",
|
||||
crossorigin: "anonymous"
|
||||
}
|
||||
@ -398,7 +426,7 @@
|
||||
true,
|
||||
"<crossorigin='use-credentials'> with correct hash, CORS-eligible",
|
||||
{
|
||||
href: xorigin_creds_style + '?1',
|
||||
href: xorigin_creds_style + '&1',
|
||||
integrity: "sha256-CzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk7gyCWUV4=",
|
||||
crossorigin: "use-credentials"
|
||||
}
|
||||
@ -409,7 +437,7 @@
|
||||
false,
|
||||
"<crossorigin='use-credentials'> with incorrect hash CORS-eligible",
|
||||
{
|
||||
href: xorigin_creds_style + '?2',
|
||||
href: xorigin_creds_style + '&2',
|
||||
integrity: "sha256-deadbeefCzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk=",
|
||||
crossorigin: "use-credentials"
|
||||
}
|
||||
@ -420,7 +448,7 @@
|
||||
false,
|
||||
"<crossorigin='anonymous'> with CORS-ineligible resource",
|
||||
{
|
||||
href: xorigin_ineligible_style + '?1',
|
||||
href: xorigin_ineligible_style + '&1',
|
||||
integrity: "sha256-CzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk7gyCWUV4=",
|
||||
crossorigin: "anonymous"
|
||||
}
|
||||
@ -431,7 +459,7 @@
|
||||
false,
|
||||
"Cross-origin, not CORS request, with correct hash",
|
||||
{
|
||||
href: xorigin_anon_style + '?3',
|
||||
href: xorigin_anon_style + '&3',
|
||||
integrity: "sha256-CzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk7gyCWUV4="
|
||||
}
|
||||
);
|
||||
@ -441,7 +469,7 @@
|
||||
false,
|
||||
"Cross-origin, not CORS request, with hash mismatch",
|
||||
{
|
||||
href: xorigin_anon_style + '?4',
|
||||
href: xorigin_anon_style + '&4',
|
||||
integrity: "sha256-deadbeefCzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk="
|
||||
}
|
||||
);
|
||||
@ -451,7 +479,7 @@
|
||||
true,
|
||||
"Cross-origin, empty integrity",
|
||||
{
|
||||
href: xorigin_anon_style + '?5',
|
||||
href: xorigin_anon_style + '&5',
|
||||
integrity: ""
|
||||
}
|
||||
);
|
||||
@ -540,6 +568,6 @@
|
||||
style_tests.execute();
|
||||
|
||||
</script>
|
||||
<!--TODO check cache-poisoned resources, transfer-encoding, 3xx redirect
|
||||
<!-- TODO check cache-poisoned resources, transfer-encoding, 3xx redirect
|
||||
to resource with matching hash, and cross-origin leakage test as in sec5.3.
|
||||
-->
|
||||
-->
|
@ -376,3 +376,4 @@ def load(tests_root, manifest):
|
||||
def write(manifest, manifest_path):
|
||||
with open(manifest_path, "w") as f:
|
||||
json.dump(manifest.to_json(), f, sort_keys=True, indent=2, separators=(',', ': '))
|
||||
f.write("\n")
|
||||
|
@ -134,7 +134,7 @@ class SourceFile(object):
|
||||
ext = ext[1:]
|
||||
if ext in ["html", "htm"]:
|
||||
return "html"
|
||||
if ext in ["xhtml", "xht"]:
|
||||
if ext in ["xhtml", "xht", "xml"]:
|
||||
return "xhtml"
|
||||
if ext == "svg":
|
||||
return "svg"
|
||||
|
@ -85,7 +85,7 @@ class WebDriver(searchcontext.SearchContext):
|
||||
def get_window_size(self):
|
||||
"""Get the dimensions of the current window."""
|
||||
result = self._window_command('GET', '/size', 'getWindowSize')
|
||||
return { 'height': result[height], 'width': result[width] }
|
||||
return {'height': result['height'], 'width': result['width']}
|
||||
|
||||
def set_window_size(self, height, width):
|
||||
"""Set the size of the current window."""
|
||||
|
@ -9,54 +9,38 @@
|
||||
<div id=log></div>
|
||||
|
||||
<script type=text/plain>
|
||||
[Constructor(DOMString url, optional DOMString base = "about:blank"),
|
||||
Exposed=Window,Worker]
|
||||
[Constructor(USVString url, optional USVString base),
|
||||
Exposed=(Window,Worker)]
|
||||
interface URL {
|
||||
static DOMString domainToASCII(ScalarValueString domain);
|
||||
static DOMString domainToUnicode(ScalarValueString domain);
|
||||
};
|
||||
URL implements URLUtils;
|
||||
static USVString domainToASCII(USVString domain);
|
||||
static USVString domainToUnicode(USVString domain);
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface URLUtils {
|
||||
stringifier attribute ScalarValueString href;
|
||||
readonly attribute DOMString origin;
|
||||
|
||||
attribute ScalarValueString protocol;
|
||||
attribute ScalarValueString username;
|
||||
attribute ScalarValueString password;
|
||||
attribute ScalarValueString host;
|
||||
attribute ScalarValueString hostname;
|
||||
attribute ScalarValueString port;
|
||||
attribute ScalarValueString pathname;
|
||||
attribute ScalarValueString search;
|
||||
readonly attribute URLSearchParams searchParams;
|
||||
attribute ScalarValueString hash;
|
||||
stringifier attribute USVString href;
|
||||
readonly attribute USVString origin;
|
||||
attribute USVString protocol;
|
||||
attribute USVString username;
|
||||
attribute USVString password;
|
||||
attribute USVString host;
|
||||
attribute USVString hostname;
|
||||
attribute USVString port;
|
||||
attribute USVString pathname;
|
||||
attribute USVString search;
|
||||
readonly attribute URLSearchParams searchParams;
|
||||
attribute USVString hash;
|
||||
};
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface URLUtilsReadOnly {
|
||||
stringifier readonly attribute DOMString href;
|
||||
readonly attribute DOMString origin;
|
||||
|
||||
readonly attribute DOMString protocol;
|
||||
readonly attribute DOMString host;
|
||||
readonly attribute DOMString hostname;
|
||||
readonly attribute DOMString port;
|
||||
readonly attribute DOMString pathname;
|
||||
readonly attribute DOMString search;
|
||||
readonly attribute DOMString hash;
|
||||
};
|
||||
[Constructor(optional (USVString or URLSearchParams) init = ""),
|
||||
Exposed=(Window,Worker)]
|
||||
interface URLSearchParams {
|
||||
void append(ScalarValueString name, ScalarValueString value);
|
||||
void delete(ScalarValueString name);
|
||||
DOMString? get(ScalarValueString name);
|
||||
sequence<DOMString> getAll(ScalarValueString name);
|
||||
boolean has(ScalarValueString name);
|
||||
void set(ScalarValueString name, ScalarValueString value);
|
||||
void append(USVString name, USVString value);
|
||||
void delete(USVString name);
|
||||
USVString? get(USVString name);
|
||||
sequence<USVString> getAll(USVString name);
|
||||
boolean has(USVString name);
|
||||
void set(USVString name, USVString value);
|
||||
iterable<USVString, USVString>;
|
||||
stringifier;
|
||||
};
|
||||
typedef DOMString ScalarValueString;
|
||||
</script>
|
||||
<script>
|
||||
"use strict";
|
||||
|
@ -10,7 +10,7 @@ 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
|
||||
from selenium import webdriver
|
||||
|
||||
|
||||
class WebDriverBaseTest(unittest.TestCase):
|
||||
@ -33,9 +33,10 @@ 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")
|
||||
else:
|
||||
url = 'http://127.0.0.1:4444/wd/hub'
|
||||
capabilities = None
|
||||
if config.has_option(section, 'capabilities'):
|
||||
try:
|
||||
@ -45,5 +46,15 @@ def create_driver():
|
||||
mode = 'compatibility'
|
||||
if config.has_option(section, 'mode'):
|
||||
mode = config.get(section, 'mode')
|
||||
if section == 'firefox':
|
||||
driver = webdriver.Firefox()
|
||||
elif section == 'chrome':
|
||||
driver = webdriver.Chrome()
|
||||
elif section == 'edge':
|
||||
driver = webdriver.Remote()
|
||||
elif section == 'ie':
|
||||
driver = webdriver.Ie()
|
||||
elif section == 'selendroid':
|
||||
driver = webdriver.Android()
|
||||
|
||||
return WebDriver(url, {}, capabilities, mode)
|
||||
return driver
|
||||
|
@ -0,0 +1,64 @@
|
||||
import os
|
||||
import sys
|
||||
import random
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
|
||||
repo_root = os.path.abspath(os.path.join(__file__, "../../.."))
|
||||
sys.path.insert(1, os.path.join(repo_root, "tools", "webdriver"))
|
||||
from webdriver import exceptions
|
||||
|
||||
|
||||
class OpenAndCloseWindowTest(base_test.WebDriverBaseTest):
|
||||
def setUp(self):
|
||||
self.driver.get(self.webserver.where_is("command_contexts/res/first-page.html"))
|
||||
|
||||
def tearDown(self):
|
||||
handles = self.driver.get_window_handles()
|
||||
|
||||
for i in range(len(handles) - 1):
|
||||
self.driver.switch_to_window(handles[i])
|
||||
self.driver.close()
|
||||
|
||||
self.driver.switch_to_window(self.driver.get_window_handles()[0])
|
||||
|
||||
def test_open_new_window(self):
|
||||
handles = self.driver.get_window_handles()
|
||||
self.driver.find_element_by_id("open_new_window").click()
|
||||
self.assertEquals(len(handles) + 1, len(self.driver.get_window_handles()))
|
||||
|
||||
def test_get_window_handles_returns_the_windows_that_have_been_opened(self):
|
||||
self.driver.find_element_by_id("open_new_window").click()
|
||||
handles = self.driver.get_window_handles()
|
||||
self.driver.switch_to_window(handles[0])
|
||||
url1 = self.driver.get_current_url()
|
||||
self.driver.switch_to_window(handles[1])
|
||||
url2 = self.driver.get_current_url()
|
||||
|
||||
if url1 == self.webserver.where_is("controlling_windows/res/other-page.html"):
|
||||
self.assertEquals(url2, self.webserver.where_is("controlling_windows/res/first-page.html"))
|
||||
elif url1 == self.webserver.where_is("controlling_windows/res/first-page.html"):
|
||||
self.assertEquals(url2, self.webserver.where_is("controlling_windows/res/other-page.html"))
|
||||
else:
|
||||
self.fail("The wrong set of URLs were returned")
|
||||
|
||||
def test_close_window(self):
|
||||
open_windows = len(self.driver.get_window_handles())
|
||||
|
||||
self.driver.find_element_by_id("open_new_window").click()
|
||||
self.assertEquals(1 + open_windows, len(self.driver.get_window_handles()))
|
||||
|
||||
self.driver.close()
|
||||
self.assertEquals(open_windows, len(self.driver.get_window_handles()))
|
||||
|
||||
def test_command_sent_to_closed_window_returns_no_such_window_exception(self):
|
||||
self.driver.find_element_by_id("open_new_window").click()
|
||||
self.driver.close()
|
||||
|
||||
with self.assertRaises(exceptions.NoSuchWindowException):
|
||||
self.driver.get_window_handle()
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>First Page</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="./other-page.html" target="_blank" id="open_new_window">Open new window</a>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Other Page</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="./other-page.html" target="_blank" id="open_new_window">Open new window</a>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,33 @@
|
||||
import os
|
||||
import sys
|
||||
import random
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
|
||||
repo_root = os.path.abspath(os.path.join(__file__, "../../.."))
|
||||
sys.path.insert(1, os.path.join(repo_root, "tools", "webdriver"))
|
||||
from webdriver import exceptions
|
||||
|
||||
|
||||
class WindowHandleTest(base_test.WebDriverBaseTest):
|
||||
def setUp(self):
|
||||
self.driver.get(self.webserver.where_is("command_contexts/res/first-page.html"))
|
||||
|
||||
def test_window_handle_is_not_current(self):
|
||||
handle = self.driver.get_window_handle()
|
||||
self.assertNotEquals(handle, "current")
|
||||
|
||||
def test_window_handles_are_unique(self):
|
||||
number_of_windows = 20
|
||||
new_window_button = self.driver.find_element_by_id("open_new_window")
|
||||
for i in range(0, number_of_windows):
|
||||
new_window_button.click()
|
||||
|
||||
handles = self.driver.get_window_handles()
|
||||
if len(handles) > len(set(handles)):
|
||||
self.fail('At least one window handle was repeated')
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
@ -0,0 +1,35 @@
|
||||
import os
|
||||
import sys
|
||||
import random
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
|
||||
repo_root = os.path.abspath(os.path.join(__file__, "../../.."))
|
||||
sys.path.insert(1, os.path.join(repo_root, "tools", "webdriver"))
|
||||
from webdriver import exceptions
|
||||
|
||||
class WindowSizeTest(base_test.WebDriverBaseTest):
|
||||
|
||||
def test_set_and_get_window_size(self):
|
||||
self.driver.get(self.webserver.where_is("command_contexts/res/first-page.html"))
|
||||
|
||||
initial_dimensions = self.driver.get_window_size()
|
||||
|
||||
new_dimensions = {
|
||||
"height": initial_dimensions["height"] - 100,
|
||||
"width": initial_dimensions["width"] - 100}
|
||||
|
||||
try:
|
||||
self.driver.set_window_size(new_dimensions["height"], new_dimensions["width"])
|
||||
|
||||
actual_dimensions = self.driver.get_window_size()
|
||||
|
||||
self.assertDictEqual(new_dimensions, actual_dimensions)
|
||||
except exceptions.UnsupportedOperationException:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
@ -4,7 +4,7 @@ import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
from webdriver import exceptions
|
||||
from selenium.common import exceptions
|
||||
|
||||
|
||||
class CookieTest(base_test.WebDriverBaseTest):
|
||||
@ -12,20 +12,14 @@ class CookieTest(base_test.WebDriverBaseTest):
|
||||
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 })
|
||||
self.driver.add_cookie({'name': 'foo', 'value': 'bar'})
|
||||
|
||||
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.driver.add_cookie({'name': name,
|
||||
'value': 'bar',
|
||||
'path': '/',
|
||||
'secure': (True)})
|
||||
self.assertTrue(self.driver.get_cookie(name)[0]['secure'])
|
||||
|
||||
def test_secure_defaults_to_false( self ):
|
||||
@ -39,10 +33,8 @@ class CookieTest(base_test.WebDriverBaseTest):
|
||||
|
||||
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.driver.add_cookie({'name': invalid_name, 'value': 'foobar'})
|
||||
self.fail( 'should have thrown exceptions.' )
|
||||
|
||||
except exceptions.UnableToSetCookieException:
|
||||
@ -51,10 +43,8 @@ class CookieTest(base_test.WebDriverBaseTest):
|
||||
pass
|
||||
|
||||
def test_should_throw_an_exception_the_name_is_null(self):
|
||||
val = 'foobar'
|
||||
|
||||
try:
|
||||
self.driver.add_cookie({ 'name': None, 'value': val })
|
||||
self.driver.add_cookie({'name': None, 'value': 'foobar'})
|
||||
self.fail( 'should have thrown exceptions.' )
|
||||
|
||||
except exceptions.UnableToSetCookieException:
|
||||
|
@ -5,16 +5,15 @@ 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']")
|
||||
e = self.driver.find_element_by_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")
|
||||
e = self.driver.find_element_by_css_selector("#id")
|
||||
self.assertEquals("id", e.text)
|
||||
|
||||
def test_find_element_by_link_text(self):
|
||||
@ -32,6 +31,30 @@ class ElementLocationTest(base_test.WebDriverBaseTest):
|
||||
e = self.driver.find_element_by_xpath("//*[@id='id']")
|
||||
self.assertEquals("id", e.text)
|
||||
|
||||
def test_find_elements_by_name(self):
|
||||
self.driver.get(self.webserver.where_is("element_location/res/elements.html"))
|
||||
e = self.driver.find_elements_by_name("name")
|
||||
self.assertEquals("name", e[0].text)
|
||||
|
||||
def test_find_elements_by_css_selector(self):
|
||||
self.driver.get(self.webserver.where_is("element_location/res/elements.html"))
|
||||
e = self.driver.find_elements_by_css_selector("#id")
|
||||
self.assertEquals("id", e[0].text)
|
||||
|
||||
def test_find_elements_by_link_text(self):
|
||||
self.driver.get(self.webserver.where_is("element_location/res/elements.html"))
|
||||
e = self.driver.find_elements_by_link_text("link text")
|
||||
self.assertEquals("link text", e[0].text)
|
||||
|
||||
def test_find_elements_by_partial_link_text(self):
|
||||
self.driver.get(self.webserver.where_is("element_location/res/elements.html"))
|
||||
e = self.driver.find_elements_by_partial_link_text("link tex")
|
||||
self.assertEquals("link text", e[0].text)
|
||||
|
||||
def test_find_elements_by_xpath(self):
|
||||
self.driver.get(self.webserver.where_is("element_location/res/elements.html"))
|
||||
e = self.driver.find_elements_by_xpath("//*[@id='id']")
|
||||
self.assertEquals("id", e[0].text)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -9,12 +9,12 @@ 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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
el = self.driver.find_element_by_css_selector("div")
|
||||
expected_style = """
|
||||
font-family: \"Gill Sans Extrabold\",Helvetica,sans-serif;
|
||||
line-height: 1.2; font-weight: bold;
|
||||
@ -23,49 +23,85 @@ class GetElementAttributeTest(base_test.WebDriverBaseTest):
|
||||
|
||||
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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
el = self.driver.find_element_by_css_selector("div")
|
||||
self.assertIsNone(el.get_attribute("class"))
|
||||
|
||||
def test_find_attribute_with_special_characters(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/get-element-attribute-extended.html"))
|
||||
element = self.driver.find_element_by_id("id_special_char_attribute_name")
|
||||
attribute = element.get_attribute("*")
|
||||
self.assertEquals("special_char_attribute_name", attribute)
|
||||
|
||||
def test_find_attribute_with_special_char_name_and_value(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/get-element-attribute-extended.html"))
|
||||
element = self.driver.find_element_by_id("id_special_char_attribute_name_and_value")
|
||||
attribute = element.get_attribute("@")
|
||||
self.assertEquals("(", attribute)
|
||||
|
||||
def test_find_attribute_with_numeric_name(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/get-element-attribute-extended.html"))
|
||||
element = self.driver.find_element_by_id("id_attribute_name_numeric")
|
||||
attribute = element.get_attribute("1")
|
||||
self.assertEquals("numeric attribute name", attribute)
|
||||
|
||||
def test_find_attribute_with_numeric_value(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/get-element-attribute-extended.html"))
|
||||
element = self.driver.find_element_by_id("id_attribute_value_numeric")
|
||||
attribute = element.get_attribute("one")
|
||||
self.assertEquals("2", attribute)
|
||||
|
||||
def test_find_attribute_with_negative_numeric_name(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/get-element-attribute-extended.html"))
|
||||
element = self.driver.find_element_by_id("id_attribute_negative_numeric_name")
|
||||
attribute = element.get_attribute("-5")
|
||||
self.assertEquals("attribute name is -5", attribute)
|
||||
|
||||
def test_find_attribute_with_negative_numeric_value(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/get-element-attribute-extended.html"))
|
||||
element = self.driver.find_element_by_id("id_attribute_negative_numeric_value")
|
||||
attribute = element.get_attribute("negative_numeric_value")
|
||||
self.assertEquals("-9", attribute)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -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 GetElementPropertiesTest(base_test.WebDriverBaseTest):
|
||||
def test_get_element_text(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/elements_text.html"))
|
||||
e = self.driver.find_element_by_name("name")
|
||||
self.assertEquals("name", e.text)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
@ -10,7 +10,7 @@
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
|
||||
#overlay {
|
||||
background: blue;
|
||||
|
||||
|
@ -4,20 +4,20 @@
|
||||
|
||||
<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 */
|
||||
|
@ -7,7 +7,7 @@
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
|
||||
#partial {
|
||||
background: yellow;
|
||||
}
|
||||
|
@ -0,0 +1,89 @@
|
||||
<html>
|
||||
<body>
|
||||
<select>
|
||||
<option id="selected-1">selected-1</option>
|
||||
</select>
|
||||
<select>
|
||||
<option id="selected-2">selected-2</option>
|
||||
<option id="unselected-1">unselected-1</option>
|
||||
</select>
|
||||
<select disabled>
|
||||
<option id="unselected-2">unselected-2</option>
|
||||
<option id="selected-3" selected>selected-3</option>
|
||||
<option id="unselected-3">unselected-3</option>
|
||||
</select>
|
||||
<select>
|
||||
<option id="unselected-4" checked>unselected-4</option>
|
||||
<option id="unselected-5">unselected-5</option>
|
||||
<option id="selected-4" selected>selected-4</option>
|
||||
</select>
|
||||
<select>
|
||||
<option id="unselected-6" selected>unselected-6</option>
|
||||
<option id="selected-5">selected-5</option>
|
||||
</select>
|
||||
<script>
|
||||
document.getElementById("selected-5").selected = true;
|
||||
</script>
|
||||
<select multiple>
|
||||
<option id="unselected-7">unselected-7</option>
|
||||
<option id="unselected-8">unselected-8</option>
|
||||
</select>
|
||||
<select multiple>
|
||||
<option id="selected-6" selected>selected-6</option>
|
||||
<option id="unselected-9" selected>unselected-9</option>
|
||||
<option id="selected-7">selected-7</option>
|
||||
</select>
|
||||
<script>
|
||||
document.getElementById("unselected-9").selected = false;
|
||||
document.getElementById("selected-7").selected = true;
|
||||
</script>
|
||||
|
||||
<h1>Input Checkbox Elements</h1>
|
||||
<input type="checkbox" id="selected-8" />selected-8
|
||||
<script>
|
||||
document.getElementById("selected-8").checked = true;
|
||||
</script>
|
||||
<input type="checkbox" id="selected-9" checked />selected-9
|
||||
<script>
|
||||
document.getElementById("selected-9").indeterminate = true;
|
||||
</script>
|
||||
<input type="checkbox" id="unselected-10" />unselected-10
|
||||
<input type="checkbox" id="unselected-11" checked />unselected-11
|
||||
<script>
|
||||
document.getElementById("unselected-11").checked = false;
|
||||
</script>
|
||||
<input type="checkbox" id="unselected-12" />unselected-12
|
||||
<script>
|
||||
document.getElementById("unselected-12").indeterminate = true;
|
||||
</script>
|
||||
<input type="checkbox" id="unselected-13" selected />unselected-13
|
||||
<input type="checkbox" id="selected-10" checked />selected-10
|
||||
|
||||
<h1>Input Radio Elements</h1>
|
||||
<br>Group 1:<br>
|
||||
<input type="radio" name="group1" id="selected-11" checked />selected-11
|
||||
<br>Group 2:<br>
|
||||
<input type="radio" name="group2" id="selected-12" />selected-12
|
||||
<script>
|
||||
document.getElementById("selected-12").checked = true;
|
||||
</script>
|
||||
<br>Group 3:<br>
|
||||
<input type="radio" name="group3" id="unselected-14" />unselected-14
|
||||
<input type="radio" name="group3" id="selected-13" checked />selected-13
|
||||
<br>Group 4:<br>
|
||||
<input type="radio" name="group4" id="unselected-15" checked />unselected-15
|
||||
<input type="radio" name="group4" id="selected-14" checked />selected-14
|
||||
<br>Group 5:<br>
|
||||
<input type="radio" name="group5" id="unselected-16" />unselected-16
|
||||
<input type="radio" name="group5" id="unselected-17" checked />unselected-17
|
||||
<script>
|
||||
document.getElementById("unselected-17").checked = false;
|
||||
</script>
|
||||
<br>Group 6<br>
|
||||
<input type="radio" name="group6" id="selected-15" />selected-15
|
||||
<input type="radio" name="group6" id="unselected-18" checked />unselected-18
|
||||
<script>
|
||||
document.getElementById("selected-15").checked = true;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -8,7 +8,7 @@
|
||||
background: blue;
|
||||
width: 50px; height: 50px;
|
||||
}
|
||||
|
||||
|
||||
#hidden {
|
||||
margin-top: -50px;
|
||||
}
|
||||
|
@ -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,72 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Get Element Attribute Extended</title>
|
||||
|
||||
<span id=my_id_with_a_relatively_long_name_test class=my_id_with_a_relatively_long_name_test_class>Span</span>
|
||||
<span id=my-id>Span</span>
|
||||
|
||||
<div class=container>
|
||||
<div id=div1 name=div-name>
|
||||
<div id=div1-1_div1>
|
||||
<h1 id=h1_div1.1_div1 class=span-class>h1 element, id:h1_div1.1_div1</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class=div-depth-2>
|
||||
<div class=div-depth-3>
|
||||
<div class=div-depth-4>
|
||||
<span id=my_id_with_a_relatively_long_name_test class=my_id_with_a_relatively_long_name_test_class>Span</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a>anchor text 123</a>
|
||||
<a>anchor text 123</a>
|
||||
|
||||
<select>
|
||||
<option id="opt-1" style="font-size: 11px; display: block;" selected>My Option 1</option>
|
||||
<option class="opt" >My Option 2</option>
|
||||
<option value="one">My Option 3</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<a id="no-vi-1" class="cant-see" style="display:none">no visibility</a><br/>
|
||||
<a id="no-vi-2" style="display:none">no visibility</a><br/>
|
||||
<a id="no-vi-2" style="display:none">no visibility</a><br/>
|
||||
|
||||
<span id=my_id_with_a_relatively_long_name_test2>Span</span>
|
||||
<span id="id.period">Span</span>
|
||||
</div>
|
||||
|
||||
<div id=id_attribute_accesskey accesskey=nothing></div>
|
||||
|
||||
<!-- Multiple elements with same class -->
|
||||
|
||||
<div id=id_div_multiple_elements_same_class_nested_depth_0 class=multiple_elements_same_class_nested>
|
||||
<div id=id_multiple_elements_same_class_nested_div_depth_1 class=multiple_elements_same_class_nested>
|
||||
<div id=id_multiple_elements_same_class_nested_div_depth_2 class=multiple_elements_same_class_nested>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Attribute name with special characters -->
|
||||
<div id=id_special_char_attribute_name *=special_char_attribute_name></div>
|
||||
|
||||
<!-- Attribute value with special characters -->
|
||||
<div id=id_special_char_attribute_value name="*"></div>
|
||||
|
||||
<!-- Attribute value and name with special characters -->
|
||||
<div id=id_special_char_attribute_name_and_value @="("></div>
|
||||
|
||||
<!-- Attribute name is numeric. -->
|
||||
<div id"id_attribute_name_numeric 1="numeric attribute name"></div>
|
||||
|
||||
<!-- Attribute value is numeric. -->
|
||||
<div id=id_attribute_value_numeric one=2></div>
|
||||
|
||||
<!-- Attribute name is negative numeric. -->
|
||||
<div id=id_attribute_negative_numeric_name -5="attribute name is -5"></div>
|
||||
|
||||
<!-- Attribute value is negative numeric. -->
|
||||
<div id=id_attribute_negative_numeric_value negative_numeric_value=-9></div>
|
@ -0,0 +1,210 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
|
||||
|
||||
class GetElementSelectedTest(base_test.WebDriverBaseTest):
|
||||
def test_selected_1(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("selected-1")
|
||||
|
||||
self.assertEquals(element.is_selected(), True)
|
||||
|
||||
def test_selected_2(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("selected-2")
|
||||
|
||||
self.assertEquals(element.is_selected(), True)
|
||||
|
||||
def test_selected_3(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("selected-3")
|
||||
|
||||
self.assertEquals(element.is_selected(), True)
|
||||
|
||||
def test_selected_4(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("selected-4")
|
||||
|
||||
self.assertEquals(element.is_selected(), True)
|
||||
|
||||
def test_selected_5(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("selected-5")
|
||||
|
||||
self.assertEquals(element.is_selected(), True)
|
||||
|
||||
def test_selected_6(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("selected-6")
|
||||
|
||||
self.assertEquals(element.is_selected(), True)
|
||||
|
||||
def test_selected_7(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("selected-7")
|
||||
|
||||
self.assertEquals(element.is_selected(), True)
|
||||
|
||||
def test_selected_8(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("selected-8")
|
||||
|
||||
self.assertEquals(element.is_selected(), True)
|
||||
|
||||
def test_selected_9(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("selected-9")
|
||||
|
||||
self.assertEquals(element.is_selected(), True)
|
||||
|
||||
def test_selected_10(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("selected-10")
|
||||
|
||||
self.assertEquals(element.is_selected(), True)
|
||||
|
||||
def test_selected_11(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("selected-11")
|
||||
|
||||
self.assertEquals(element.is_selected(), True)
|
||||
|
||||
def test_selected_12(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("selected-12")
|
||||
|
||||
self.assertEquals(element.is_selected(), True)
|
||||
|
||||
def test_selected_13(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("selected-13")
|
||||
|
||||
self.assertEquals(element.is_selected(), True)
|
||||
|
||||
def test_selected_14(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("selected-14")
|
||||
|
||||
self.assertEquals(element.is_selected(), True)
|
||||
|
||||
def test_selected_15(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("selected-15")
|
||||
|
||||
self.assertEquals(element.is_selected(), True)
|
||||
|
||||
def test_unselected_1(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-1")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_2(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-2")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_3(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-3")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_4(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-4")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_5(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-5")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_6(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-6")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_7(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-7")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_8(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-8")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_9(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-9")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_10(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-10")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_11(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-11")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_12(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-12")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_13(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-13")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_14(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-14")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_15(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-15")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_16(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-16")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_17(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-17")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
def test_unselected_18(self):
|
||||
self.driver.get(self.webserver.where_is("element_state/res/element-selected.html"))
|
||||
element = self.driver.find_element_by_id("unselected-18")
|
||||
|
||||
self.assertEquals(element.is_selected(), False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
@ -4,41 +4,41 @@ import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
from webdriver import exceptions
|
||||
from selenium.common 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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
parent = self.driver.find_element_by_css_selector("#parent")
|
||||
child = self.driver.find_element_by_css_selector("#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")
|
||||
input = self.driver.find_element_by_css_selector("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")
|
||||
input = self.driver.find_element_by_css_selector("input")
|
||||
self.assertFalse(input.is_displayed())
|
||||
|
||||
def test_parent_node_visible_when_all_children_are_absolutely_positioned_and_overflow_is_hidden(self):
|
||||
@ -51,10 +51,10 @@ class NaturalNonVisibleElementsTest(base_test.WebDriverBaseTest):
|
||||
|
||||
self.driver.get(self.webserver.where_is("element_state/res/absolute-children-ancestor-hidden-overflow.html"))
|
||||
|
||||
children = self.driver.find_elements_by_css(".child")
|
||||
children = self.driver.find_elements_by_css_selector(".child")
|
||||
assert all(child.is_displayed() for child in children)
|
||||
|
||||
parent = self.driver.find_element_by_css("#parent")
|
||||
parent = self.driver.find_element_by_css_selector("#parent")
|
||||
assert parent.is_displayed()
|
||||
|
||||
def test_element_hidden_by_overflow_x_is_not_visible(self):
|
||||
@ -66,8 +66,8 @@ class NaturalNonVisibleElementsTest(base_test.WebDriverBaseTest):
|
||||
|
||||
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")
|
||||
right = self.driver.find_element_by_css_selector("#right")
|
||||
bottom_right = self.driver.find_element_by_css_selector("#bottom-right")
|
||||
|
||||
self.assertFalse(right.is_displayed())
|
||||
self.assertFalse(bottom_right.is_displayed())
|
||||
@ -81,8 +81,8 @@ class NaturalNonVisibleElementsTest(base_test.WebDriverBaseTest):
|
||||
|
||||
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")
|
||||
bottom = self.driver.find_element_by_css_selector("#bottom")
|
||||
bottom_right = self.driver.find_element_by_css_selector("#bottom-right")
|
||||
|
||||
self.assertFalse(bottom.is_displayed())
|
||||
self.assertFalse(bottom_right.is_displayed())
|
||||
@ -104,78 +104,78 @@ class NaturalNonVisibleElementsTest(base_test.WebDriverBaseTest):
|
||||
|
||||
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")
|
||||
hidden = self.driver.find_element_by_css_selector("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")
|
||||
hidden = self.driver.find_element_by_css_selector("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")
|
||||
overlay = self.driver.find_element_by_css_selector("#overlay")
|
||||
hidden = self.driver.find_element_by_css_selector("#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")
|
||||
partial = self.driver.find_element_by_css_selector("#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")
|
||||
overlay = self.driver.find_element_by_css_selector("#overlay")
|
||||
hidden = self.driver.find_element_by_css_selector("#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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
overlay = self.driver.find_element_by_css_selector("#overlay")
|
||||
hidden = self.driver.find_element_by_css_selector("#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")
|
||||
p = self.driver.find_element_by_css_selector("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")
|
||||
p = self.driver.find_element_by_css_selector("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")
|
||||
p = self.driver.find_element_by_css_selector("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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
hidden = self.driver.find_element_by_css_selector("#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")
|
||||
body = self.driver.find_element_by_css_selector("body")
|
||||
assert body.is_displayed()
|
||||
|
||||
def test_implicit(self):
|
||||
@ -194,86 +194,86 @@ class BodyElementIsAlwaysDisplayedTest(base_test.WebDriverBaseTest):
|
||||
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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
parent = self.driver.find_element_by_css_selector("#parent")
|
||||
child = self.driver.find_element_by_css_selector("#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")
|
||||
child = self.driver.find_element_by_css_selector("#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")
|
||||
child = self.driver.find_element_by_css_selector("#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")
|
||||
child = self.driver.find_element_by_css_selector("#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")
|
||||
child = self.driver.find_element_by_css_selector("#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")
|
||||
hidden = self.driver.find_element_by_css_selector("#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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
el = self.driver.find_element_by_css_selector("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")
|
||||
parent = self.driver.find_element_by_css_selector("#parent")
|
||||
child = self.driver.find_element_by_css_selector("#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")
|
||||
parent = self.driver.find_element_by_css_selector("#parent")
|
||||
child = self.driver.find_element_by_css_selector("#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")
|
||||
parent = self.driver.find_element_by_css_selector("#parent")
|
||||
child = self.driver.find_element_by_css_selector("#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")
|
||||
child = self.driver.find_element_by_css_selector("#child")
|
||||
self.assertTrue(child.is_displayed())
|
||||
|
||||
def test_visibility_hidden_on_parent_takes_precedence_over_display_block(self):
|
||||
@ -284,33 +284,33 @@ class VisibilityTest(base_test.WebDriverBaseTest):
|
||||
|
||||
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')
|
||||
singleHidden = self.driver.find_element_by_css_selector('#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')
|
||||
child = self.driver.find_element_by_css_selector('#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")
|
||||
input = self.driver.find_element_by_css_selector("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")
|
||||
checkbox = self.driver.find_element_by_css_selector("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")
|
||||
textfield = self.driver.find_element_by_css_selector("input")
|
||||
|
||||
with self.assertRaises(exceptions.ElementNotVisibleException):
|
||||
textfield.send_keys("Koha is a popular Indian cheese")
|
||||
|
@ -4,6 +4,7 @@ import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
from selenium.webdriver.remote.webelement import WebElement
|
||||
|
||||
|
||||
class ExecuteScriptTest(base_test.WebDriverBaseTest):
|
||||
|
@ -4,16 +4,17 @@ import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
from webdriver import exceptions, wait
|
||||
from selenium.common import exceptions
|
||||
from selenium.webdriver.support import wait
|
||||
|
||||
|
||||
class AlertsQuitTest(base_test.WebDriverBaseTest):
|
||||
def setUp(self):
|
||||
self.wait = wait.WebDriverWait(self.driver, 5, ignored_exceptions=[exceptions.NoSuchAlertException])
|
||||
self.wait = wait.WebDriverWait(self.driver, 5, ignored_exceptions=[exceptions.NoAlertPresentException])
|
||||
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()
|
||||
self.driver.find_element_by_css_selector('#alert').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
self.driver.quit()
|
||||
with self.assertRaises(Exception):
|
||||
|
@ -4,144 +4,145 @@ import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
from webdriver import exceptions, wait
|
||||
|
||||
from selenium.common import exceptions
|
||||
from selenium.webdriver.support import wait
|
||||
|
||||
class AlertsTest(base_test.WebDriverBaseTest):
|
||||
def setUp(self):
|
||||
self.wait = wait.WebDriverWait(self.driver, 5, ignored_exceptions = [exceptions.NoSuchAlertException])
|
||||
self.wait = wait.WebDriverWait(self.driver, 5, ignored_exceptions = [exceptions.NoAlertPresentException])
|
||||
self.driver.get(self.webserver.where_is('modal/res/alerts.html'))
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
self.driver.switch_to_alert().dismiss()
|
||||
except exceptions.NoSuchAlertException:
|
||||
except exceptions.NoAlertPresentException:
|
||||
pass
|
||||
|
||||
# Alerts
|
||||
def test_should_allow_user_to_accept_an_alert(self):
|
||||
self.driver.find_element_by_css('#alert').click()
|
||||
self.driver.find_element_by_css_selector('#alert').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.accept()
|
||||
self.driver.get_current_url()
|
||||
self.driver.current_url
|
||||
|
||||
def test_should_allow_user_to_accept_an_alert_with_no_text(self):
|
||||
self.driver.find_element_by_css('#empty-alert').click()
|
||||
self.driver.find_element_by_css_selector('#empty-alert').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.accept()
|
||||
self.driver.get_current_url()
|
||||
self.driver.current_url
|
||||
|
||||
def test_should_allow_user_to_dismiss_an_alert(self):
|
||||
self.driver.find_element_by_css('#alert').click()
|
||||
self.driver.find_element_by_css_selector('#alert').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.dismiss()
|
||||
self.driver.get_current_url()
|
||||
self.driver.current_url
|
||||
|
||||
def test_should_allow_user_to_get_text_of_an_alert(self):
|
||||
self.driver.find_element_by_css('#alert').click()
|
||||
self.driver.find_element_by_css_selector('#alert').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
value = alert.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()
|
||||
self.driver.find_element_by_css_selector('#alert').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
with self.assertRaises(exceptions.ElementNotVisibleException):
|
||||
alert.send_keys('cheese')
|
||||
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()
|
||||
self.driver.find_element_by_css_selector('#alert').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.accept()
|
||||
with self.assertRaises(exceptions.NoSuchAlertException):
|
||||
alert.get_text()
|
||||
with self.assertRaises(exceptions.NoAlertPresentException):
|
||||
alert.text
|
||||
|
||||
# Prompts
|
||||
def test_should_allow_user_to_accept_a_prompt(self):
|
||||
self.driver.find_element_by_css('#prompt').click()
|
||||
self.driver.find_element_by_css_selector('#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 == '')
|
||||
self.wait.until(lambda x: x.find_element_by_css_selector('#text').text == '')
|
||||
|
||||
def test_should_allow_user_to_dismiss_a_prompt(self):
|
||||
self.driver.find_element_by_css('#prompt').click()
|
||||
self.driver.find_element_by_css_selector('#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')
|
||||
self.wait.until(lambda x: x.find_element_by_css_selector('#text').text == 'null')
|
||||
|
||||
def test_should_allow_user_to_set_the_value_of_a_prompt(self):
|
||||
self.driver.find_element_by_css('#prompt').click()
|
||||
self.driver.find_element_by_css_selector('#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')
|
||||
self.wait.until(lambda x: x.find_element_by_css_selector('#text').text == 'cheese')
|
||||
|
||||
def test_should_allow_user_to_get_text_of_a_prompt(self):
|
||||
self.driver.find_element_by_css('#prompt').click()
|
||||
self.driver.find_element_by_css_selector('#prompt').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
value = alert.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()
|
||||
self.driver.find_element_by_css_selector('#prompt').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.accept()
|
||||
with self.assertRaises(exceptions.NoSuchAlertException):
|
||||
alert.get_text()
|
||||
with self.assertRaises(exceptions.NoAlertPresentException):
|
||||
alert.text
|
||||
|
||||
def test_prompt_should_use_default_value_if_no_keys_sent(self):
|
||||
self.driver.find_element_by_css('#prompt-with-default').click()
|
||||
self.driver.find_element_by_css_selector('#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')
|
||||
self.wait.until(lambda x: x.find_element_by_css_selector('#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()
|
||||
self.driver.find_element_by_css_selector('#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')
|
||||
self.wait.until(lambda x: x.find_element_by_css_selector('#text').text == 'null')
|
||||
|
||||
# Confirmations
|
||||
def test_should_allow_user_to_accept_a_confirm(self):
|
||||
self.driver.find_element_by_css('#confirm').click()
|
||||
self.driver.find_element_by_css_selector('#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')
|
||||
self.wait.until(lambda x: x.find_element_by_css_selector('#text').text == 'true')
|
||||
|
||||
def test_should_allow_user_to_dismiss_a_confirm(self):
|
||||
self.driver.find_element_by_css('#confirm').click()
|
||||
self.driver.find_element_by_css_selector('#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')
|
||||
self.wait.until(lambda x: x.find_element_by_css_selector('#text').text == 'false')
|
||||
|
||||
def test_setting_the_value_of_a_confirm_throws(self):
|
||||
self.driver.find_element_by_css('#confirm').click()
|
||||
self.driver.find_element_by_css_selector('#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()
|
||||
self.driver.find_element_by_css_selector('#confirm').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
value = alert.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()
|
||||
self.driver.find_element_by_css_selector('#confirm').click()
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
alert.accept()
|
||||
with self.assertRaises(exceptions.NoSuchAlertException):
|
||||
alert.get_text()
|
||||
with self.assertRaises(exceptions.NoAlertPresentException):
|
||||
alert.text
|
||||
|
||||
"""
|
||||
def test_switch_to_missing_alert_fails(self):
|
||||
with self.assertRaises(exceptions.NoSuchAlertException):
|
||||
with self.assertRaises(exceptions.NoAlertPresentException):
|
||||
self.driver.switch_to_alert()
|
||||
|
||||
"""
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -5,14 +5,14 @@ import ConfigParser
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
from webdriver import exceptions
|
||||
from selenium.common 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
|
||||
# Set up class to start HTTP Server that responds to
|
||||
# test URLs with various 401 responses
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -11,12 +11,12 @@ class ForwardTest(base_test.WebDriverBaseTest):
|
||||
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
|
||||
nextbody = self.driver.find_element_by_css_selector("body").text
|
||||
self.driver.back()
|
||||
currbody = self.driver.find_element_by_css_selector("body").text
|
||||
self.assertNotEqual(nextbody, currbody)
|
||||
self.driver.go_forward()
|
||||
currbody = self.driver.find_element_by_css("body").text
|
||||
self.driver.forward()
|
||||
currbody = self.driver.find_element_by_css_selector("body").text
|
||||
self.assertEqual(nextbody, currbody)
|
||||
|
||||
|
||||
|
@ -10,9 +10,9 @@ 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
|
||||
body = self.driver.find_element_by_css_selector("body").text
|
||||
self.driver.forward()
|
||||
currbody = self.driver.find_element_by_css_selector("body").text
|
||||
self.assertEqual(body, currbody)
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@ 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()
|
||||
url = self.driver.current_url
|
||||
self.assertEquals(page, url)
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ class GetFromHttpTest(base_test.WebDriverBaseTest):
|
||||
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()
|
||||
url = self.driver.current_url
|
||||
self.assertEquals(expected, url)
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ class GetFromHttpTest(base_test.WebDriverBaseTest):
|
||||
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()
|
||||
url = self.driver.current_url
|
||||
self.assertEquals(expected, url)
|
||||
|
||||
|
||||
@ -34,14 +34,14 @@ class GetFromHttpTest(base_test.WebDriverBaseTest):
|
||||
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()
|
||||
url = self.driver.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()
|
||||
url = self.driver.current_url
|
||||
self.assertEquals(page, url)
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@ class InvalidCertTest(base_test.WebDriverBaseTest):
|
||||
'navigation/res/empty.html').replace('http:', 'https:', 1)
|
||||
|
||||
self.driver.get(expected)
|
||||
self.assertEquals(expected, self.driver.get_current_url())
|
||||
self.assertEquals(expected, self.driver.current_url)
|
||||
|
||||
|
||||
if __name__ == '__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_selector("body").text
|
||||
self.driver.execute_script("document.getElementById('body').innerHTML=''")
|
||||
self.driver.refresh()
|
||||
newbody = self.driver.find_element_by_css_selector("body").text
|
||||
self.assertEqual(body, newbody)
|
||||
|
||||
self.driver.get(self.webserver.where_is('navigation/res/refreshPageDynamic.html'))
|
||||
body = self.driver.find_element_by_css_selector("body").text
|
||||
self.driver.refresh()
|
||||
newbody = self.driver.find_element_by_css_selector("body").text
|
||||
self.assertNotEqual(body, newbody)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
42
testing/web-platform/tests/webdriver/runtests_p0.py
Normal file
42
testing/web-platform/tests/webdriver/runtests_p0.py
Normal file
@ -0,0 +1,42 @@
|
||||
import unittest
|
||||
|
||||
from unittest import TestLoader, TextTestRunner, TestSuite
|
||||
|
||||
from cookie import cookie_test
|
||||
from navigation import forward
|
||||
from navigation import forwardToNothing
|
||||
from navigation import get_from_http_test
|
||||
from navigation import refresh_page
|
||||
from element_location import element_location_test
|
||||
from element_state import visibility_test
|
||||
from element_state import method_test
|
||||
from element_state import properties
|
||||
from javascript import execute_script_test
|
||||
from user_input import clear_test
|
||||
from windows import window_manipulation
|
||||
from windows import tabbing
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
loader = TestLoader()
|
||||
suite = TestSuite((
|
||||
loader.loadTestsFromModule(cookie_test),
|
||||
loader.loadTestsFromModule(forward),
|
||||
loader.loadTestsFromModule(forwardToNothing),
|
||||
loader.loadTestsFromModule(element_location_test),
|
||||
loader.loadTestsFromModule(visibility_test),
|
||||
loader.loadTestsFromModule(execute_script_test),
|
||||
loader.loadTestsFromModule(clear_test),
|
||||
loader.loadTestsFromModule(method_test),
|
||||
loader.loadTestsFromModule(properties),
|
||||
loader.loadTestsFromModule(refresh_page),
|
||||
loader.loadTestsFromModule(get_from_http_test),
|
||||
loader.loadTestsFromModule(window_manipulation),
|
||||
loader.loadTestsFromModule(tabbing)
|
||||
))
|
||||
|
||||
runner = TextTestRunner(verbosity=2)
|
||||
runner.run(suite)
|
||||
unittest.main()
|
@ -0,0 +1 @@
|
||||
__author__ = 'b-redeg'
|
@ -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,15 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
|
||||
|
||||
class ScreenShotTest(base_test.WebDriverBaseTest):
|
||||
# Get a static page that must be the same upon refresh
|
||||
def test_screenShot(self):
|
||||
self.driver.get(self.webserver.where_is('screenshot/res/screen.html'))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -4,7 +4,7 @@ import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
from webdriver import exceptions
|
||||
from selenium.common import exceptions
|
||||
|
||||
|
||||
class ImplicitWaitsTests(base_test.WebDriverBaseTest):
|
||||
@ -12,15 +12,15 @@ class ImplicitWaitsTests(base_test.WebDriverBaseTest):
|
||||
self.driver.get(self.webserver.where_is('timeouts/res/implicit_waits_tests.html'))
|
||||
|
||||
def test_find_element_by_id(self):
|
||||
add = self.driver.find_element_by_css("#adder")
|
||||
self.driver.set_implicit_timeout(3)
|
||||
add = self.driver.find_element_by_css_selector("#adder")
|
||||
self.driver.implicitly_wait(3)
|
||||
add.click()
|
||||
self.driver.find_element_by_css("#box0") # All is well if this doesn't throw.
|
||||
self.driver.find_element_by_css_selector("#box0") # All is well if this doesn't throw.
|
||||
|
||||
def test_should_still_fail_to_find_an_element_when_implicit_waits_are_enabled(self):
|
||||
self.driver.set_implicit_timeout(0.5)
|
||||
self.driver.implicitly_wait(0.5)
|
||||
try:
|
||||
self.driver.find_element_by_css("#box0")
|
||||
self.driver.find_element_by_css_selector("#box0")
|
||||
self.fail("Expected NoSuchElementException to have been thrown")
|
||||
except exceptions.NoSuchElementException as e:
|
||||
pass
|
||||
@ -28,10 +28,10 @@ class ImplicitWaitsTests(base_test.WebDriverBaseTest):
|
||||
self.fail("Expected NoSuchElementException but got " + str(e))
|
||||
|
||||
def test_should_return_after_first_attempt_to_find_one_after_disabling_implicit_waits(self):
|
||||
self.driver.set_implicit_timeout(3)
|
||||
self.driver.set_implicit_timeout(0)
|
||||
self.driver.implicitly_wait(3)
|
||||
self.driver.implicitly_wait(0)
|
||||
try:
|
||||
self.driver.find_element_by_css("#box0")
|
||||
self.driver.find_element_by_css_selector("#box0")
|
||||
self.fail("Expected NoSuchElementException to have been thrown")
|
||||
except exceptions.NoSuchElementException as e:
|
||||
pass
|
||||
@ -39,24 +39,24 @@ class ImplicitWaitsTests(base_test.WebDriverBaseTest):
|
||||
self.fail("Expected NoSuchElementException but got " + str(e))
|
||||
|
||||
def test_should_implicitly_wait_until_at_least_one_element_is_found_when_searching_for_many(self):
|
||||
add = self.driver.find_element_by_css("#adder")
|
||||
self.driver.set_implicit_timeout(2)
|
||||
add = self.driver.find_element_by_css_selector("#adder")
|
||||
self.driver.implicitly_wait(2)
|
||||
add.click()
|
||||
add.click()
|
||||
elements = self.driver.find_elements_by_css(".redbox")
|
||||
elements = self.driver.find_elements_by_css_selector(".redbox")
|
||||
self.assertTrue(len(elements) >= 1)
|
||||
|
||||
def test_should_still_fail_to_find_an_element_by_class_when_implicit_waits_are_enabled(self):
|
||||
self.driver.set_implicit_timeout(0.5)
|
||||
elements = self.driver.find_elements_by_css(".redbox")
|
||||
self.driver.implicitly_wait(0.5)
|
||||
elements = self.driver.find_elements_by_css_selector(".redbox")
|
||||
self.assertEqual(0, len(elements))
|
||||
|
||||
def test_should_return_after_first_attempt_to_find_many_after_disabling_implicit_waits(self):
|
||||
add = self.driver.find_element_by_css("#adder")
|
||||
self.driver.set_implicit_timeout(1.1)
|
||||
self.driver.set_implicit_timeout(0)
|
||||
add = self.driver.find_element_by_css_selector("#adder")
|
||||
self.driver.implicitly_wait(1.1)
|
||||
self.driver.implicitly_wait(0)
|
||||
add.click()
|
||||
elements = self.driver.find_elements_by_css(".redbox")
|
||||
elements = self.driver.find_elements_by_css_selector(".redbox")
|
||||
self.assertEqual(0, len(elements))
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
from webdriver import exceptions
|
||||
from selenium.common import exceptions
|
||||
|
||||
|
||||
class PageLoadTimeoutTest(base_test.WebDriverBaseTest):
|
||||
|
@ -6,45 +6,45 @@ import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
from webdriver import exceptions
|
||||
from selenium.common import exceptions
|
||||
|
||||
|
||||
class ElementClearTest(base_test.WebDriverBaseTest):
|
||||
def test_writable_text_input_element_should_clear(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/element_clear_writable_input_page.html"))
|
||||
e = self.driver.find_element_by_css("#writableTextInput")
|
||||
e = self.driver.find_element_by_css_selector("#writableTextInput")
|
||||
e.clear()
|
||||
self.assertEquals("", e.get_attribute("value"))
|
||||
|
||||
def test_disabled_text_input_element_should_not_clear(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/element_clear_disabled_input_page.html"))
|
||||
e = self.driver.find_element_by_css("#disabledTextInput")
|
||||
e = self.driver.find_element_by_css_selector("#disabledTextInput")
|
||||
self.assertRaises(exceptions.InvalidElementStateException, lambda: e.clear())
|
||||
|
||||
def test_read_only_text_input_element_should_not_clear(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/element_clear_readonly_input_page.html"))
|
||||
e = self.driver.find_element_by_css("#readOnlyTextInput")
|
||||
e = self.driver.find_element_by_css_selector("#readOnlyTextInput")
|
||||
self.assertRaises(exceptions.InvalidElementStateException, lambda: e.clear())
|
||||
|
||||
def test_writable_text_area_element_should_clear(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/element_clear_writable_textarea_page.html"))
|
||||
e = self.driver.find_element_by_css("#writableTextArea")
|
||||
e = self.driver.find_element_by_css_selector("#writableTextArea")
|
||||
e.clear()
|
||||
self.assertEquals("", e.get_attribute("value"))
|
||||
|
||||
def test_disabled_text_area_element_should_not_clear(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/element_clear_disabled_textarea_page.html"))
|
||||
e = self.driver.find_element_by_css("#disabledTextArea")
|
||||
e = self.driver.find_element_by_css_selector("#disabledTextArea")
|
||||
self.assertRaises(exceptions.InvalidElementStateException, lambda: e.clear())
|
||||
|
||||
def test_read_only_text_input_element_should_not_clear(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/element_clear_readonly_textarea_page.html"))
|
||||
e = self.driver.find_element_by_css("#readOnlyTextArea")
|
||||
e = self.driver.find_element_by_css_selector("#readOnlyTextArea")
|
||||
self.assertRaises(exceptions.InvalidElementStateException, lambda: e.clear())
|
||||
|
||||
def test_content_editable_area_should_clear(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/element_clear_contenteditable_page.html"))
|
||||
e = self.driver.find_element_by_css("#contentEditableElement")
|
||||
e = self.driver.find_element_by_css_selector("#contentEditableElement")
|
||||
e.clear()
|
||||
self.assertEquals("", e.text)
|
||||
|
||||
|
349
testing/web-platform/tests/webdriver/user_input/click_test.py
Normal file
349
testing/web-platform/tests/webdriver/user_input/click_test.py
Normal file
@ -0,0 +1,349 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
|
||||
repo_root = os.path.abspath(os.path.join(__file__, "../../.."))
|
||||
sys.path.insert(1, os.path.join(repo_root, "tools", "webdriver"))
|
||||
from webdriver import exceptions, wait
|
||||
|
||||
|
||||
class ClickTest(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
|
||||
|
||||
def test_click_div(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("div")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "div")
|
||||
|
||||
def test_click_p(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("p")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "p")
|
||||
|
||||
def test_click_h1(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("h1")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "h1")
|
||||
|
||||
def test_click_pre(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("pre")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "pre")
|
||||
|
||||
def test_click_ol(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("ol")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "ol")
|
||||
|
||||
def test_click_ul(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("ul")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "ul")
|
||||
|
||||
def test_click_a(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("a")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "a")
|
||||
|
||||
def test_click_img(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("img")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "img")
|
||||
|
||||
def test_click_video(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("video")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "video")
|
||||
|
||||
def test_click_canvas(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("canvas")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "canvas")
|
||||
|
||||
def test_click_progress(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("progress")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "progress")
|
||||
|
||||
def test_click_textarea(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("textarea")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "textarea")
|
||||
|
||||
def test_click_button(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("button")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "button")
|
||||
|
||||
def test_click_svg(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("svg")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "svg")
|
||||
|
||||
def test_click_input_range(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("input_range")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "input_range")
|
||||
|
||||
def test_click_input_button(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("input_button")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "input_button")
|
||||
|
||||
def test_click_input_submit(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("input_submit")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "input_submit")
|
||||
|
||||
def test_click_input_reset(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("input_reset")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "input_reset")
|
||||
|
||||
def test_click_input_checkbox(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("input_checkbox")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "input_checkbox")
|
||||
|
||||
def test_click_input_radio(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("input_radio")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "input_radio")
|
||||
|
||||
def test_click_input_text(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("input_text")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "input_text")
|
||||
|
||||
def test_click_input_number(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("input_number")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "input_number")
|
||||
|
||||
def test_click_input_tel(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("input_tel")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "input_tel")
|
||||
|
||||
def test_click_input_url(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("input_url")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "input_url")
|
||||
|
||||
def test_click_input_email(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("input_email")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "input_email")
|
||||
|
||||
def test_click_input_search(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("input_search")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "input_search")
|
||||
|
||||
def test_click_input_image(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/click.html"))
|
||||
|
||||
element = self.driver.find_element_by_id("input_image")
|
||||
element.click()
|
||||
|
||||
alert = self.wait.until(lambda x: x.switch_to_alert())
|
||||
value = alert.get_text()
|
||||
alert.accept()
|
||||
|
||||
self.assertEquals(value, "input_image")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Text Form Landing</title>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,25 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Text Form</title>
|
||||
<meta charset="utf-8" />
|
||||
<script>
|
||||
function key_press() {
|
||||
document.getElementById("text").textContent = document.getElementById("Text1").value;
|
||||
}
|
||||
|
||||
function got_focus() {
|
||||
var output = document.getElementById("output");
|
||||
output.checked = true;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p id="text"></p>
|
||||
<form action="text-form-landing.html">
|
||||
<input id="Text1" type="text" onkeyup="key_press()"/>
|
||||
<input id="Text2" type="text" onfocus="got_focus()" />
|
||||
<input id="output" type="checkbox" />
|
||||
<input type="submit" name="e" value="mc2" />
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,96 @@
|
||||
import os
|
||||
import sys
|
||||
import random
|
||||
import unittest
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
|
||||
import base_test
|
||||
|
||||
repo_root = os.path.abspath(os.path.join(__file__, "../../.."))
|
||||
sys.path.insert(1, os.path.join(repo_root, "tools", "webdriver"))
|
||||
from webdriver import exceptions
|
||||
|
||||
|
||||
class SendKeysTest(base_test.WebDriverBaseTest):
|
||||
def setUp(self):
|
||||
self.driver.get(self.webserver.where_is("user_input/res/text-form.html"))
|
||||
|
||||
def test_send_simple_string(self):
|
||||
element = self.driver.find_element_by_id("Text1")
|
||||
element.send_keys("lorem ipsum")
|
||||
|
||||
self.assertEquals(self.driver.find_element_by_id("text").get_text(), u"lorem ipsum")
|
||||
|
||||
def test_send_return(self):
|
||||
element = self.driver.find_element_by_id("Text1")
|
||||
returnkey = unichr(int("E006", 16))
|
||||
element.send_keys([returnkey])
|
||||
|
||||
self.assertEquals(u"" + self.driver.get_current_url(), u"" + self.webserver.where_is("user_input/res/text-form-landing.html?e=mc2"))
|
||||
|
||||
def test_send_backspace(self):
|
||||
element = self.driver.find_element_by_id("Text1")
|
||||
element.send_keys("world ")
|
||||
element.send_keys("wide ")
|
||||
element.send_keys("web ")
|
||||
element.send_keys("consortium")
|
||||
|
||||
backspace= unichr(int("E003", 16))
|
||||
for i in range(0, 11):
|
||||
element.send_keys([backspace])
|
||||
|
||||
self.assertEquals(self.driver.find_element_by_id("text").get_text(), u"world wide web")
|
||||
|
||||
def test_send_tab(self):
|
||||
element1 = self.driver.find_element_by_id("Text1")
|
||||
element2 = self.driver.find_element_by_id("Text2")
|
||||
element1.send_keys("typing here")
|
||||
|
||||
tab= unichr(int("E004", 16))
|
||||
element1.send_keys([tab])
|
||||
|
||||
output = self.driver.find_element_by_id("output")
|
||||
tab_pressed = output.get_attribute("checked")
|
||||
self.assertEquals(tab_pressed, u"true")
|
||||
|
||||
def test_send_shift(self):
|
||||
element = self.driver.find_element_by_id("Text1")
|
||||
element.send_keys("low ")
|
||||
|
||||
shift= unichr(int("E008", 16))
|
||||
element.send_keys([shift , "u", "p", shift])
|
||||
|
||||
self.assertEquals(self.driver.find_element_by_id("text").get_text(), u"low UP")
|
||||
|
||||
def test_send_arrow_keys(self):
|
||||
element = self.driver.find_element_by_id("Text1")
|
||||
|
||||
element.send_keys("internet")
|
||||
|
||||
backspace= unichr(int("E003", 16))
|
||||
left= unichr(int("E012", 16))
|
||||
right= unichr(int("E014", 16))
|
||||
for i in range(0, 4):
|
||||
element.send_keys([left])
|
||||
|
||||
element.send_keys([backspace])
|
||||
element.send_keys([right])
|
||||
element.send_keys("a")
|
||||
|
||||
self.assertEquals(self.driver.find_element_by_id("text").get_text(), u"intranet")
|
||||
|
||||
def test_select_text_with_shift(self):
|
||||
element = self.driver.find_element_by_id("Text1")
|
||||
|
||||
element.send_keys("WebDriver")
|
||||
backspace= unichr(int("E003", 16))
|
||||
shift= unichr(int("E008", 16))
|
||||
left= unichr(int("E012", 16))
|
||||
|
||||
element.send_keys([shift, left, left, left, left, left, left, backspace])
|
||||
|
||||
self.assertEquals(self.driver.find_element_by_id("text").get_text(), u"Web")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
@ -21,6 +21,10 @@ mode: compatibility
|
||||
capabilities: {"browserName": "ie"}
|
||||
mode: compatibility
|
||||
|
||||
[edge]
|
||||
capabilities: {"browserName": "edge"}
|
||||
mode: compatibility
|
||||
|
||||
[ios-driver]
|
||||
capabilities: {"browserName": "iphone"}
|
||||
mode: compatibility
|
||||
|
1
testing/web-platform/tests/webdriver/windows/__init__.py
Normal file
1
testing/web-platform/tests/webdriver/windows/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
__author__ = 'b-redeg'
|
@ -0,0 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>window one</title>
|
||||
|
||||
<div onclick="window.open('win2.html')">win2</div>
|
@ -0,0 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>window two</title>
|
||||
|
||||
<img src="//web-platform.test:8000/images/blue.png"> </a>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user