Update web-platform-tests to revision 5a754b40cd49c0404863c431b58cc311dc5d167c

This commit is contained in:
Ms2ger 2015-11-17 09:56:30 +01:00
parent 8950345e0e
commit 32efe41299
107 changed files with 4243 additions and 435 deletions

View file

@ -4489,7 +4489,7 @@
"path": "html/rendering/non-replaced-elements/the-hr-element-0/color.html", "path": "html/rendering/non-replaced-elements/the-hr-element-0/color.html",
"references": [ "references": [
[ [
"html/rendering/non-replaced-elements/the-hr-element-0/color-ref.html", "/html/rendering/non-replaced-elements/the-hr-element-0/color-ref.html",
"==" "=="
] ]
], ],
@ -11181,6 +11181,14 @@
"path": "IndexedDB/idbindex_get7.htm", "path": "IndexedDB/idbindex_get7.htm",
"url": "/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", "path": "IndexedDB/idbindex_getKey.htm",
"url": "/IndexedDB/idbindex_getKey.htm" "url": "/IndexedDB/idbindex_getKey.htm"
@ -11445,6 +11453,14 @@
"path": "IndexedDB/idbobjectstore_get7.htm", "path": "IndexedDB/idbobjectstore_get7.htm",
"url": "/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", "path": "IndexedDB/idbobjectstore_index.htm",
"url": "/IndexedDB/idbobjectstore_index.htm" "url": "/IndexedDB/idbobjectstore_index.htm"
@ -11537,6 +11553,10 @@
"path": "IndexedDB/idbtransaction_abort.htm", "path": "IndexedDB/idbtransaction_abort.htm",
"url": "/IndexedDB/idbtransaction_abort.htm" "url": "/IndexedDB/idbtransaction_abort.htm"
}, },
{
"path": "IndexedDB/idbtransaction_objectStoreNames.html",
"url": "/IndexedDB/idbtransaction_objectStoreNames.html"
},
{ {
"path": "IndexedDB/idbversionchangeevent.htm", "path": "IndexedDB/idbversionchangeevent.htm",
"url": "/IndexedDB/idbversionchangeevent.htm" "url": "/IndexedDB/idbversionchangeevent.htm"
@ -13869,6 +13889,10 @@
"path": "dom/nodes/Node-contains.html", "path": "dom/nodes/Node-contains.html",
"url": "/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", "path": "dom/nodes/Node-insertBefore.html",
"url": "/dom/nodes/Node-insertBefore.html" "url": "/dom/nodes/Node-insertBefore.html"
@ -14005,6 +14029,14 @@
"path": "dom/nodes/getElementsByClassName-09.htm", "path": "dom/nodes/getElementsByClassName-09.htm",
"url": "/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", "path": "dom/nodes/getElementsByClassName-12.htm",
"url": "/dom/nodes/getElementsByClassName-12.htm" "url": "/dom/nodes/getElementsByClassName-12.htm"
@ -14669,6 +14701,10 @@
"path": "hr-time/basic.html", "path": "hr-time/basic.html",
"url": "/hr-time/basic.html" "url": "/hr-time/basic.html"
}, },
{
"path": "hr-time/basic.worker.js",
"url": "/hr-time/basic.worker"
},
{ {
"path": "hr-time/idlharness.html", "path": "hr-time/idlharness.html",
"url": "/hr-time/idlharness.html" "url": "/hr-time/idlharness.html"
@ -14817,6 +14853,10 @@
"path": "html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit.html", "path": "html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit.html",
"url": "/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit.html" "url": "/html/browsers/browsing-the-web/navigating-across-documents/child_navigates_parent_submit.html"
}, },
{
"path": "html/browsers/browsing-the-web/navigating-across-documents/javascript-url-query-fragment-components.html",
"url": "/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-query-fragment-components.html"
},
{ {
"path": "html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_data_url.html", "path": "html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_data_url.html",
"url": "/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_data_url.html" "url": "/html/browsers/browsing-the-web/navigating-across-documents/navigation_unload_data_url.html"
@ -18509,6 +18549,10 @@
"path": "html/webappapis/animation-frames/callback-invoked.html", "path": "html/webappapis/animation-frames/callback-invoked.html",
"url": "/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", "path": "html/webappapis/animation-frames/cancel-invoked.html",
"url": "/html/webappapis/animation-frames/cancel-invoked.html" "url": "/html/webappapis/animation-frames/cancel-invoked.html"
@ -18533,6 +18577,10 @@
"path": "html/webappapis/scripting/events/body-onload.html", "path": "html/webappapis/scripting/events/body-onload.html",
"url": "/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", "path": "html/webappapis/scripting/events/event-handler-javascript.html",
"url": "/html/webappapis/scripting/events/event-handler-javascript.html" "url": "/html/webappapis/scripting/events/event-handler-javascript.html"
@ -18541,6 +18589,10 @@
"path": "html/webappapis/scripting/events/event-handler-spec-example.html", "path": "html/webappapis/scripting/events/event-handler-spec-example.html",
"url": "/html/webappapis/scripting/events/event-handler-spec-example.html" "url": "/html/webappapis/scripting/events/event-handler-spec-example.html"
}, },
{
"path": "html/webappapis/scripting/events/onerroreventhandler.html",
"url": "/html/webappapis/scripting/events/onerroreventhandler.html"
},
{ {
"path": "html/webappapis/scripting/processing-model-2/addEventListener.html", "path": "html/webappapis/scripting/processing-model-2/addEventListener.html",
"url": "/html/webappapis/scripting/processing-model-2/addEventListener.html" "url": "/html/webappapis/scripting/processing-model-2/addEventListener.html"
@ -18737,6 +18789,14 @@
"path": "infrastructure/failing-test.html", "path": "infrastructure/failing-test.html",
"url": "/infrastructure/failing-test.html" "url": "/infrastructure/failing-test.html"
}, },
{
"path": "innerText/getter.html",
"url": "/innerText/getter.html"
},
{
"path": "innerText/setter.html",
"url": "/innerText/setter.html"
},
{ {
"path": "js/behaviours/SetPrototypeOf-window.html", "path": "js/behaviours/SetPrototypeOf-window.html",
"url": "/js/behaviours/SetPrototypeOf-window.html" "url": "/js/behaviours/SetPrototypeOf-window.html"
@ -26217,6 +26277,38 @@
"path": "url/url-constructor.html", "path": "url/url-constructor.html",
"url": "/url/url-constructor.html" "url": "/url/url-constructor.html"
}, },
{
"path": "url/urlsearchparams-append.html",
"url": "/url/urlsearchparams-append.html"
},
{
"path": "url/urlsearchparams-constructor.html",
"url": "/url/urlsearchparams-constructor.html"
},
{
"path": "url/urlsearchparams-delete.html",
"url": "/url/urlsearchparams-delete.html"
},
{
"path": "url/urlsearchparams-get.html",
"url": "/url/urlsearchparams-get.html"
},
{
"path": "url/urlsearchparams-getall.html",
"url": "/url/urlsearchparams-getall.html"
},
{
"path": "url/urlsearchparams-has.html",
"url": "/url/urlsearchparams-has.html"
},
{
"path": "url/urlsearchparams-set.html",
"url": "/url/urlsearchparams-set.html"
},
{
"path": "url/urlsearchparams-stringifier.html",
"url": "/url/urlsearchparams-stringifier.html"
},
{ {
"path": "user-timing/idlharness.html", "path": "user-timing/idlharness.html",
"url": "/user-timing/idlharness.html" "url": "/user-timing/idlharness.html"
@ -26321,6 +26413,10 @@
"path": "web-animations/animation-timeline/idlharness.html", "path": "web-animations/animation-timeline/idlharness.html",
"url": "/web-animations/animation-timeline/idlharness.html" "url": "/web-animations/animation-timeline/idlharness.html"
}, },
{
"path": "web-animations/keyframe-effect/constructor.html",
"url": "/web-animations/keyframe-effect/constructor.html"
},
{ {
"path": "webaudio/the-audio-api/the-audiobuffer-interface/idl-test.html", "path": "webaudio/the-audio-api/the-audiobuffer-interface/idl-test.html",
"url": "/webaudio/the-audio-api/the-audiobuffer-interface/idl-test.html" "url": "/webaudio/the-audio-api/the-audiobuffer-interface/idl-test.html"
@ -26329,6 +26425,10 @@
"path": "webaudio/the-audio-api/the-audiodestinationnode-interface/idl-test.html", "path": "webaudio/the-audio-api/the-audiodestinationnode-interface/idl-test.html",
"url": "/webaudio/the-audio-api/the-audiodestinationnode-interface/idl-test.html" "url": "/webaudio/the-audio-api/the-audiodestinationnode-interface/idl-test.html"
}, },
{
"path": "webaudio/the-audio-api/the-audionode-interface/audionode-connect-return-value.html",
"url": "/webaudio/the-audio-api/the-audionode-interface/audionode-connect-return-value.html"
},
{ {
"path": "webaudio/the-audio-api/the-audioparam-interface/retrospective-setValueAtTime.html", "path": "webaudio/the-audio-api/the-audioparam-interface/retrospective-setValueAtTime.html",
"url": "/webaudio/the-audio-api/the-audioparam-interface/retrospective-setValueAtTime.html" "url": "/webaudio/the-audio-api/the-audioparam-interface/retrospective-setValueAtTime.html"
@ -29759,6 +29859,15 @@
} }
], ],
"wdspec": [ "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" "path": "webdriver/cookie/cookie_test.py"
}, },
@ -29774,6 +29883,9 @@
{ {
"path": "webdriver/element_state/properties.py" "path": "webdriver/element_state/properties.py"
}, },
{
"path": "webdriver/element_state/selected_test.py"
},
{ {
"path": "webdriver/element_state/visibility_test.py" "path": "webdriver/element_state/visibility_test.py"
}, },
@ -29819,6 +29931,12 @@
{ {
"path": "webdriver/user_input/clear_test.py" "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/tabbing.py"
}, },
@ -29829,40 +29947,7 @@
}, },
"local_changes": { "local_changes": {
"deleted": [], "deleted": [],
"items": { "items": {},
"testharness": {
"dom/nodes/Node-contains.xml": [
{
"path": "dom/nodes/Node-contains.xml",
"url": "/dom/nodes/Node-contains.xml"
}
],
"dom/nodes/getElementsByClassName-10.xml": [
{
"path": "dom/nodes/getElementsByClassName-10.xml",
"url": "/dom/nodes/getElementsByClassName-10.xml"
}
],
"dom/nodes/getElementsByClassName-11.xml": [
{
"path": "dom/nodes/getElementsByClassName-11.xml",
"url": "/dom/nodes/getElementsByClassName-11.xml"
}
],
"html/browsers/browsing-the-web/navigating-across-documents/javascript-url-query-fragment-components.html": [
{
"path": "html/browsers/browsing-the-web/navigating-across-documents/javascript-url-query-fragment-components.html",
"url": "/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-query-fragment-components.html"
}
],
"html/webappapis/scripting/events/onerroreventhandler.html": [
{
"path": "html/webappapis/scripting/events/onerroreventhandler.html",
"url": "/html/webappapis/scripting/events/onerroreventhandler.html"
}
]
}
},
"reftest_nodes": {} "reftest_nodes": {}
}, },
"reftest_nodes": { "reftest_nodes": {
@ -31858,6 +31943,30 @@
"url": "/html/rendering/non-replaced-elements/the-fieldset-element-0/min-width-not-important.html" "url": "/html/rendering/non-replaced-elements/the-fieldset-element-0/min-width-not-important.html"
} }
], ],
"html/rendering/non-replaced-elements/the-hr-element-0/color.html": [
{
"path": "html/rendering/non-replaced-elements/the-hr-element-0/color.html",
"references": [
[
"/html/rendering/non-replaced-elements/the-hr-element-0/color-ref.html",
"=="
]
],
"url": "/html/rendering/non-replaced-elements/the-hr-element-0/color.html"
}
],
"html/rendering/non-replaced-elements/the-hr-element-0/width.html": [
{
"path": "html/rendering/non-replaced-elements/the-hr-element-0/width.html",
"references": [
[
"/html/rendering/non-replaced-elements/the-hr-element-0/width-ref.html",
"=="
]
],
"url": "/html/rendering/non-replaced-elements/the-hr-element-0/width.html"
}
],
"html/rendering/non-replaced-elements/the-page/body_text_00ffff.xhtml": [ "html/rendering/non-replaced-elements/the-page/body_text_00ffff.xhtml": [
{ {
"path": "html/rendering/non-replaced-elements/the-page/body_text_00ffff.xhtml", "path": "html/rendering/non-replaced-elements/the-page/body_text_00ffff.xhtml",
@ -35399,7 +35508,7 @@
} }
] ]
}, },
"rev": "7123012427f92f0dc38a120e6e86a75b6c03aab5", "rev": "5a754b40cd49c0404863c431b58cc311dc5d167c",
"url_base": "/", "url_base": "/",
"version": 2 "version": 2
} }

View file

@ -0,0 +1,11 @@
[basic.worker]
type: testharness
[WorkerGlobalScope.performance.now() is a function]
expected: FAIL
[WorkerGlobalScope.performance.now() returns a positive number]
expected: FAIL
[WorkerGlobalScope.performance.now() difference is not negative]
expected: FAIL

View file

@ -1,6 +1,5 @@
[javascript-url-query-fragment-components.html] [javascript-url-query-fragment-components.html]
type: testharness type: testharness
expected: OK
[iframes with javascript src] [iframes with javascript src]
expected: FAIL expected: FAIL

View file

@ -18,3 +18,12 @@
[return an HTMLOptionsCollection in correct order for repeated mixed value] [return an HTMLOptionsCollection in correct order for repeated mixed value]
expected: FAIL expected: FAIL
[if multiple items have a name or *id* value matching the parameter, return the first object and stop]
expected: FAIL
[if multiple items have a *name* or id value matching the parameter, return the first object and stop]
expected: FAIL
[if multiple items have a *name* or *id* value matching the parameter, return the first object and stop]
expected: FAIL

View file

@ -0,0 +1,50 @@
[event-handler-attributes-body-window.html]
type: testharness
[blur]
expected: FAIL
[error]
expected: FAIL
[focus]
expected: FAIL
[resize]
expected: FAIL
[scroll]
expected: FAIL
[afterprint]
expected: FAIL
[beforeprint]
expected: FAIL
[beforeunload]
expected: FAIL
[hashchange]
expected: FAIL
[languagechange]
expected: FAIL
[message]
expected: FAIL
[offline]
expected: FAIL
[online]
expected: FAIL
[pagehide]
expected: FAIL
[pageshow]
expected: FAIL
[popstate]
expected: FAIL

View file

@ -1 +1 @@
521a87180a85709f8f704df33537f79bd131bf71 8950345e0e2c803cfa87105374dfdb30a550cfe0

View file

@ -0,0 +1,5 @@
[urlsearchparams-constructor.html]
type: testharness
[URLSearchParams constructor, empty.]
expected: FAIL

View file

@ -0,0 +1,8 @@
[urlsearchparams-getall.html]
type: testharness
[getAll() basics]
expected: FAIL
[getAll() multiples]
expected: FAIL

View file

@ -1,9 +1,8 @@
[event_case_sensitive.html] [event_case_sensitive.html]
type: testharness type: testharness
expected: TIMEOUT
[sessionStorage storage events fire even when only the case of the value changes.] [sessionStorage storage events fire even when only the case of the value changes.]
expected: TIMEOUT expected: FAIL
[localStorage storage events fire even when only the case of the value changes.] [localStorage storage events fire even when only the case of the value changes.]
expected: TIMEOUT expected: FAIL

View file

@ -5,3 +5,4 @@
[submodule "tools"] [submodule "tools"]
path = tools path = tools
url = https://github.com/w3c/wpt-tools.git url = https://github.com/w3c/wpt-tools.git
ignore = dirty

View 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>

View 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>

View 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>

View file

@ -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>

View file

@ -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>

View file

@ -126,13 +126,13 @@
/** /**
* ContentType reponse * ContentType response
* *
* rules for dereferencing an app: URI => * rules for dereferencing an app: URI =>
8. Let potential-file be the result of attempting locate the file at path 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"; TC_name += "Content-Type header, and the contents of potential-file as the response body";
var ContentTypeResponsetests = [ /* scheme:[ TC name, URI, content-type] */ var ContentTypeResponsetests = [ /* scheme:[ TC name, URI, content-type] */
@ -334,7 +334,7 @@
xhr.send(); 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', ""); window.location.protocol + "//f15a6d20-cefa-13e5-1972-800e20d19a76/" + 'resources/ExamPLE/mmY/index.html', "");

View file

@ -31,6 +31,10 @@ connect-src 'self'; script-src 'self' 'unsafe-inline'; child-src 'self';
worker.onmessage = function(event) { worker.onmessage = function(event) {
alert_assert(event.data); alert_assert(event.data);
}; };
worker.onerror = function(event) {
alert_assert('TEST COMPLETE');
event.preventDefault();
}
} catch (e) { } catch (e) {
alert_assert('TEST COMPLETE'); alert_assert('TEST COMPLETE');
} }

View file

@ -31,6 +31,10 @@ connect-src 'self'; script-src 'self' 'unsafe-inline'; child-src *;
worker.onmessage = function(event) { worker.onmessage = function(event) {
alert_assert(event.data); alert_assert(event.data);
}; };
worker.onerror = function(event) {
event.preventDefault();
alert_assert('TEST COMPLETE');
}
} catch (e) { } catch (e) {
alert_assert('TEST COMPLETE'); alert_assert('TEST COMPLETE');
} }

View file

@ -50,19 +50,44 @@ function test_getElementsByTagName(context, element) {
}, "Should be able to set expando shadowing a proto prop (namedItem)") }, "Should be able to set expando shadowing a proto prop (namedItem)")
test(function() { test(function() {
var t = element.appendChild(document.createElement("pre")); var t1 = element.appendChild(document.createElement("pre"));
t.id = "x"; t1.id = "x";
this.add_cleanup(function() {element.removeChild(t)}); var t2 = element.appendChild(document.createElement("pre"));
t2.setAttribute("name", "y");
var t3 = element.appendChild(document.createElementNS("", "pre"));
t3.setAttribute("id", "z");
var t4 = element.appendChild(document.createElementNS("", "pre"));
t4.setAttribute("name", "w");
this.add_cleanup(function() {
element.removeChild(t1)
element.removeChild(t2)
element.removeChild(t3)
element.removeChild(t4)
});
var list = context.getElementsByTagName('pre'); var list = context.getElementsByTagName('pre');
var pre = list[0]; var pre = list[0];
assert_equals(pre.id, "x"); assert_equals(pre.id, "x");
assert_equals(list['x'], pre);
assert_true('x' in list, "'x' in list"); var exposedNames = { 'x': 0, 'y': 1, 'z': 2 };
assert_true(list.hasOwnProperty('x'), "list.hasOwnProperty('x')"); for (var exposedName in exposedNames) {
assert_equals(list[exposedName], list[exposedNames[exposedName]]);
assert_equals(list[exposedName], list.namedItem(exposedName));
assert_true(exposedName in list, "'" + exposedName + "' in list");
assert_true(list.hasOwnProperty(exposedName),
"list.hasOwnProperty('" + exposedName + "')");
}
assert_array_equals(Object.getOwnPropertyNames(list).sort(), ["0", "x"]); var unexposedNames = ["w"];
for (var unexposedName of unexposedNames) {
assert_false(unexposedName in list);
assert_false(list.hasOwnProperty(unexposedName));
assert_equals(list[unexposedName], undefined);
assert_equals(list.namedItem(unexposedName), null);
}
assert_array_equals(Object.getOwnPropertyNames(list).sort(),
["0", "1", "2", "3", "x", "y", "z"]);
var desc = Object.getOwnPropertyDescriptor(list, '0'); var desc = Object.getOwnPropertyDescriptor(list, '0');
assert_equals(typeof desc, "object", "descriptor should be an object"); assert_equals(typeof desc, "object", "descriptor should be an object");

View file

@ -3,14 +3,27 @@
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<div id="log"></div> <div id="log"></div>
<div id="test"><img><img id=foo><img id=foo></div> <div id="test"><img><img id=foo><img id=foo><img name="bar"></div>
<script> <script>
setup(function() {
// Add some non-HTML elements in there to test what happens with those.
var container = document.getElementById("test");
var child = document.createElementNS("", "img");
child.setAttribute("id", "baz");
container.appendChild(child);
child = document.createElementNS("", "img");
child.setAttribute("name", "qux");
container.appendChild(child);
});
test(function() { test(function() {
var container = document.getElementById("test"); var container = document.getElementById("test");
var result = container.children.item("foo"); var result = container.children.item("foo");
assert_true(result instanceof Element, "Expected an Element."); assert_true(result instanceof Element, "Expected an Element.");
assert_false(result.hasAttribute("id"), "Expected the IDless Element.") assert_false(result.hasAttribute("id"), "Expected the IDless Element.")
}) })
test(function() { test(function() {
var container = document.getElementById("test"); var container = document.getElementById("test");
var list = container.children; var list = container.children;
@ -20,8 +33,26 @@ test(function() {
result.push(p); result.push(p);
} }
} }
assert_array_equals(result, ['0', '1', '2']); assert_array_equals(result, ['0', '1', '2', '3', '4', '5']);
result = Object.getOwnPropertyNames(list); result = Object.getOwnPropertyNames(list);
assert_array_equals(result, ['0', '1', '2', 'foo']); assert_array_equals(result, ['0', '1', '2', '3', '4', '5', 'foo', 'bar', 'baz']);
// Mapping of exposed names to their indices in the list.
var exposedNames = { 'foo': 1, 'bar': 3, 'baz': 4 };
for (var exposedName in exposedNames) {
assert_true(exposedName in list);
assert_true(list.hasOwnProperty(exposedName));
assert_equals(list[exposedName], list.namedItem(exposedName));
assert_equals(list[exposedName], list.item(exposedNames[exposedName]));
assert_true(list[exposedName] instanceof Element);
}
var unexposedNames = ['qux'];
for (var unexposedName of unexposedNames) {
assert_false(unexposedName in list);
assert_false(list.hasOwnProperty(unexposedName));
assert_equals(list[unexposedName], undefined);
assert_equals(list.namedItem(unexposedName), null);
}
}); });
</script> </script>

View file

@ -0,0 +1,18 @@
importScripts("/resources/testharness.js");
test(function() {
assert_true((performance !== undefined), "WorkerGlobalScope.performance exists");
assert_equals((typeof performance.now), "function");
}, "WorkerGlobalScope.performance.now() is a function");
test(function() {
assert_true(performance.now() > 0);
}, "WorkerGlobalScope.performance.now() returns a positive number");
test(function() {
var now1 = performance.now();
var now2 = performance.now();
assert_true((now2-now1) >= 0);
}, "WorkerGlobalScope.performance.now() difference is not negative");
done();

View file

@ -1,5 +1,5 @@
<!doctype html> <!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/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<div id="log"></div> <div id="log"></div>

View file

@ -1,5 +1,6 @@
<!doctype html> <!doctype html>
<script> <script>
onload = function() {opener.postMessage("loaded", "*")};
onbeforeunload = function() { onbeforeunload = function() {
opener.callback(); opener.callback();
} }

View file

@ -6,8 +6,11 @@
<script> <script>
var t = async_test(); var t = async_test();
var w = window.open("close_beforeunload-1.html"); var w = window.open("close_beforeunload-1.html");
setTimeout(function() { onmessage = t.step_func(function(event) {
if (event.data != "loaded") {
return;
}
w.close(); w.close();
}, 1000); });
callback = function() {t.done()} callback = function() {t.done()}
</script> </script>

View file

@ -1,5 +1,6 @@
<!doctype html> <!doctype html>
<script> <script>
onload = function() {opener.postMessage("loaded", "*")};
onunload = function() { onunload = function() {
opener.callback(); opener.callback();
} }

View file

@ -6,8 +6,11 @@
<script> <script>
var t = async_test(); var t = async_test();
var w = window.open("close_unload-1.html"); var w = window.open("close_unload-1.html");
setTimeout(function() { onmessage = t.step_func(function(event) {
if (event.data != "loaded") {
return;
}
w.close(); w.close();
}, 1000); });
callback = function() {t.done()} callback = function() {t.done()}
</script> </script>

View file

@ -38,7 +38,7 @@ function on_load() {
if (data.name == "testcase3") { if (data.name == "testcase3") {
t3.step(function () { t3.step(function () {
assert_equals(data.result, "window.frameElement = null", assert_equals(data.result, "window.frameElement = null",
"The frameElement attribute shoudl be null."); "The frameElement attribute should be null.");
}); });
t3.done(); t3.done();
} }

View file

@ -25,6 +25,10 @@
var minutes = d.getMinutes() var minutes = d.getMinutes()
var seconds = d.getSeconds() var seconds = d.getSeconds()
// 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() { test(function() {
var local_time = hours * 60 * 60 + minutes * 60 + seconds; var local_time = hours * 60 * 60 + minutes * 60 + seconds;
var m = pattern.exec(last_modified); var m = pattern.exec(last_modified);
@ -32,7 +36,7 @@
assert_approx_equals(last_modified_time, local_time, 2, assert_approx_equals(last_modified_time, local_time, 2,
"Hours and minutes should match local time."); "Hours and minutes should match local time.");
}, "Date returned by lastModified is in the user's local time zone."); }, "Date returned by lastModified is in the user's local time zone.");
}
var t = async_test("Date returned by lastModified is current after timeout."); var t = async_test("Date returned by lastModified is current after timeout.");
setTimeout(function() { setTimeout(function() {

View file

@ -16,8 +16,8 @@ test(function() {
var script = document.createElement("script"); var script = document.createElement("script");
script.setAttribute("event", "blah"); script.setAttribute("event", "blah");
script.setAttribute("for", "blah"); script.setAttribute("for", "blah");
assert_equals(script.event, ""); assert_equals(script.event, "blah");
assert_equals(script.htmlFor, ""); assert_equals(script.htmlFor, "blah");
assert_equals(script.getAttribute("event"), "blah"); assert_equals(script.getAttribute("event"), "blah");
assert_equals(script.getAttribute("for"), "blah"); assert_equals(script.getAttribute("for"), "blah");
}) })
@ -27,10 +27,10 @@ test(function() {
script.setAttribute("for", "blah"); script.setAttribute("for", "blah");
script.event = "foo"; script.event = "foo";
script.htmlFor = "foo"; script.htmlFor = "foo";
assert_equals(script.event, ""); assert_equals(script.event, "foo");
assert_equals(script.htmlFor, ""); assert_equals(script.htmlFor, "foo");
assert_equals(script.getAttribute("event"), "blah"); assert_equals(script.getAttribute("event"), "foo");
assert_equals(script.getAttribute("for"), "blah"); assert_equals(script.getAttribute("for"), "foo");
}) })
test(function() { test(function() {
var script = document.createElement("script"); var script = document.createElement("script");
@ -38,10 +38,10 @@ test(function() {
script.setAttribute("for", "blah"); script.setAttribute("for", "blah");
script.event = null; script.event = null;
script.htmlFor = null; script.htmlFor = null;
assert_equals(script.event, ""); assert_equals(script.event, "null");
assert_equals(script.htmlFor, ""); assert_equals(script.htmlFor, "null");
assert_equals(script.getAttribute("event"), "blah"); assert_equals(script.getAttribute("event"), "null");
assert_equals(script.getAttribute("for"), "blah"); assert_equals(script.getAttribute("for"), "null");
}) })
test(function() { test(function() {
var script = document.createElement("script"); var script = document.createElement("script");
@ -49,9 +49,9 @@ test(function() {
script.setAttribute("for", "blah"); script.setAttribute("for", "blah");
script.event = undefined; script.event = undefined;
script.htmlFor = undefined; script.htmlFor = undefined;
assert_equals(script.event, ""); assert_equals(script.event, "undefined");
assert_equals(script.htmlFor, ""); assert_equals(script.htmlFor, "undefined");
assert_equals(script.getAttribute("event"), "blah"); assert_equals(script.getAttribute("event"), "undefined");
assert_equals(script.getAttribute("for"), "blah"); assert_equals(script.getAttribute("for"), "undefined");
}) })
</script> </script>

View file

@ -285,30 +285,10 @@ var validator = {
}, },
set_dirty: function(ctl) { set_dirty: function(ctl) {
document.designMode = "on";
ctl.focus(); ctl.focus();
var old_value = ctl.value; var old_value = ctl.value;
ctl.value = "a"; ctl.value = "a";
ctl.value = old_value; 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) { pre_check: function(ctl, item) {

View file

@ -5,6 +5,8 @@
<title id='title'>HTMLOptionsCollection</title> <title id='title'>HTMLOptionsCollection</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div> <div id="log"></div>
<select id="selly"> <select id="selly">
<option id="id1" name="name1">1</option> <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"); }, "if no item has a name or id value matching the parameter, return null and stop");
test(function () { test(function () {
var testarr = []; assert_equals(selly.namedItem('id3')["value"], "3");
for (var i = 0; i < selly.namedItem('id3').length; i++) { }, "if multiple items have a name or *id* value matching the parameter, return the first object and stop");
testarr.push(selly.namedItem('id3')[i].text);
}
assert_array_equals(testarr, ['3','duplicate ID']);
}, "return an HTMLOptionsCollection in correct order for repeated 'id' value");
test(function () { test(function () {
var testarr = []; assert_equals(selly.namedItem('name4')["value"], "4");
for (var i = 0; i < selly.namedItem('name4').length; i++) { }, "if multiple items have a *name* or id value matching the parameter, return the first object and stop");
testarr.push(selly.namedItem('name4')[i].text);
}
assert_array_equals(testarr, ['4', 'duplicate name']);
}, "return an HTMLOptionsCollection in correct order for repeated 'name' value");
test(function () { test(function () {
var testarr = []; assert_equals(selly.namedItem('mixed1')["value"], "mixed ID");
for (var i = 0; i < selly.namedItem('mixed1').length; i++) { }, "if multiple items have a *name* or *id* value matching the parameter, return the first object and stop");
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");
</script> </script>
</body>
</html>

View file

@ -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>

View file

@ -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>

View file

@ -0,0 +1,324 @@
testText("<div>abc", "abc", "Simplest possible test");
/**** white-space:normal ****/
testText("<div> abc", "abc", "Leading whitespace removed");
testText("<div>abc ", "abc", "Trailing whitespace removed");
testText("<div>abc def", "abc def", "Internal whitespace compressed");
testText("<div>abc\ndef", "abc def", "\\n converted to space");
testText("<div>abc\rdef", "abc def", "\\r converted to space");
testText("<div>abc\tdef", "abc def", "\\t converted to space");
testText("<div>abc <br>def", "abc\ndef", "Trailing whitespace before hard line break removed");
/**** <pre> ****/
testText("<pre> abc", " abc", "Leading whitespace preserved");
testText("<pre>abc ", "abc ", "Trailing whitespace preserved");
testText("<pre>abc def", "abc def", "Internal whitespace preserved");
testText("<pre>abc\ndef", "abc\ndef", "\\n preserved");
testText("<pre>abc\rdef", "abc\ndef", "\\r converted to newline");
testText("<pre>abc\tdef", "abc\tdef", "\\t preserved");
/**** <div style="white-space:pre"> ****/
testText("<div style='white-space:pre'> abc", " abc", "Leading whitespace preserved");
testText("<div style='white-space:pre'>abc ", "abc ", "Trailing whitespace preserved");
testText("<div style='white-space:pre'>abc def", "abc def", "Internal whitespace preserved");
testText("<div style='white-space:pre'>abc\ndef", "abc\ndef", "\\n preserved");
testText("<div style='white-space:pre'>abc\rdef", "abc\ndef", "\\r converted to newline");
testText("<div style='white-space:pre'>abc\tdef", "abc\tdef", "\\t preserved");
/**** <span style="white-space:pre"> ****/
testText("<span style='white-space:pre'> abc", " abc", "Leading whitespace preserved");
testText("<span style='white-space:pre'>abc ", "abc ", "Trailing whitespace preserved");
testText("<span style='white-space:pre'>abc def", "abc def", "Internal whitespace preserved");
testText("<span style='white-space:pre'>abc\ndef", "abc\ndef", "\\n preserved");
testText("<span style='white-space:pre'>abc\rdef", "abc\ndef", "\\r converted to newline");
testText("<span style='white-space:pre'>abc\tdef", "abc\tdef", "\\t preserved");
/**** <div style="white-space:pre-line"> ****/
testText("<div style='white-space:pre-line'> abc", "abc", "Leading whitespace removed");
testText("<div style='white-space:pre-line'>abc ", "abc", "Trailing whitespace removed");
testText("<div style='white-space:pre-line'>abc def", "abc def", "Internal whitespace collapsed");
testText("<div style='white-space:pre-line'>abc\ndef", "abc\ndef", "\\n preserved");
testText("<div style='white-space:pre-line'>abc\rdef", "abc\ndef", "\\r converted to newline");
testText("<div style='white-space:pre-line'>abc\tdef", "abc def", "\\t converted to space");
/**** Collapsing whitespace across element boundaries ****/
testText("<div><span>abc </span> def", "abc def", "Whitespace collapses across element boundaries");
testText("<div><span>abc </span><span></span> def", "abc def", "Whitespace collapses across element boundaries");
testText("<div><span>abc </span><span style='white-space:pre'></span> def", "abc def", "Whitespace collapses across element boundaries");
/**** Soft line breaks ****/
testText("<div style='width:0'>abc def", "abc def", "Soft line breaks ignored");
/**** first-line/first-letter ****/
testText("<div class='first-line-uppercase' style='width:0'>abc def", "ABC def", "::first-line styles applied");
testText("<div class='first-letter-uppercase' style='width:0'>abc def", "Abc def", "::first-letter styles applied");
testText("<div class='first-letter-float' style='width:0'>abc def", "abc def", "::first-letter float ignored");
/**** &nbsp; ****/
testText("<div>&nbsp;", "\xA0", "&nbsp; preserved");
/**** display:none ****/
testText("<div style='display:none'>abc", "abc", "display:none container");
testText("<div style='display:none'>abc def", "abc def", "No whitespace compression in display:none container");
testText("<div style='display:none'> abc def ", " abc def ", "No removal of leading/trailing whitespace in display:none container");
testText("<div>123<span style='display:none'>abc", "123", "display:none child not rendered");
/**** display:contents ****/
if (CSS.supports("display", "contents")) {
testText("<div style='display:contents'>abc", "abc", "display:contents container");
testText("<div><div style='display:contents'>abc", "abc", "display:contents container");
testText("<div>123<span style='display:contents'>abc", "123abc", "display:contents rendered");
testText("<div>123<span style='display:contents'>abc", "123abc", "display:contents rendered");
testText("<div style='display:contents'> ", "", "display:contents not processed via textContent");
testText("<div><div style='display:contents'> ", "", "display:contents not processed via textContent");
}
/**** visibility:hidden ****/
testText("<div style='visibility:hidden'>abc", "", "visibility:hidden container");
testText("<div>123<span style='visibility:hidden'>abc", "123", "visibility:hidden child not rendered");
testText("<div style='visibility:hidden'>123<span style='visibility:visible'>abc", "abc", "visibility:visible child rendered");
/**** visibility:collapse ****/
testText("<table><tbody style='visibility:collapse'><tr><td>abc", "", "visibility:collapse row-group");
testText("<table><tr style='visibility:collapse'><td>abc", "", "visibility:collapse row");
testText("<table><tr><td style='visibility:collapse'>abc", "", "visibility:collapse cell");
testText("<table><tbody style='visibility:collapse'><tr><td style='visibility:visible'>abc", "abc",
"visibility:collapse row-group with visible cell");
testText("<table><tr style='visibility:collapse'><td style='visibility:visible'>abc", "abc",
"visibility:collapse row with visible cell");
testText("<div style='display:flex'><span style='visibility:collapse'>1</span><span>2</span></div>",
"2", "visibility:collapse honored on flex item");
testText("<div style='display:grid'><span style='visibility:collapse'>1</span><span>2</span></div>",
"2", "visibility:collapse honored on grid item");
/**** opacity:0 ****/
testText("<div style='opacity:0'>abc", "abc", "opacity:0 container");
testText("<div style='opacity:0'>abc def", "abc def", "Whitespace compression in opacity:0 container");
testText("<div style='opacity:0'> abc def ", "abc def", "Remove leading/trailing whitespace in opacity:0 container");
testText("<div>123<span style='opacity:0'>abc", "123abc", "opacity:0 child rendered");
/**** generated content ****/
testText("<div class='before'>", "", "Generated content not included");
testText("<div><div class='before'>", "", "Generated content on child not included");
/**** innerText on replaced elements ****/
testText("<button>abc", "abc", "<button> contents preserved");
testText("<fieldset>abc", "abc", "<fieldset> contents preserved");
testText("<fieldset><legend>abc", "abc", "<fieldset> <legend> contents preserved");
testText("<input type='text' value='abc'>", "", "<input> contents ignored");
testText("<textarea>abc", "", "<textarea> contents ignored");
testText("<select size='1'><option>abc</option><option>def", "", "<select size='1'> contents ignored");
testText("<select size='2'><option>abc</option><option>def", "", "<select size='2'> contents ignored");
testText("<select size='1'><option id='target'>abc</option><option>def", "", "<select size='1'> contents ignored");
testText("<select size='2'><option id='target'>abc</option><option>def", "", "<select size='2'> contents ignored");
testText("<iframe>abc", "", "<iframe> contents ignored");
testText("<iframe><div id='target'>abc", "", "<iframe> contents ignored");
testText("<iframe src='data:text/html,abc'>", "","<iframe> subdocument ignored");
testText("<audio style='display:block'>abc", "", "<audio> contents ignored");
testText("<audio style='display:block'><source id='target' class='poke' style='display:block'>", "", "<audio> contents ignored");
testText("<audio style='display:block'><source id='target' class='poke' style='display:none'>", "abc", "<audio> contents ok if display:none");
testText("<video>abc", "", "<video> contents ignored");
testText("<video style='display:block'><source id='target' class='poke' style='display:block'>", "", "<video> contents ignored");
testText("<video style='display:block'><source id='target' class='poke' style='display:none'>", "abc", "<video> contents ok if display:none");
testText("<canvas>abc", "", "<canvas> contents ignored");
testText("<canvas><div id='target'>abc", "", "<canvas><div id='target'> contents ignored");
testText("<img alt='abc'>", "", "<img> alt text ignored");
testText("<img src='about:blank' class='poke'>", "", "<img> contents ignored");
/**** innerText on replaced element children ****/
testText("<div><button>abc", "abc", "<button> contents preserved");
testText("<div><fieldset>abc", "abc", "<fieldset> contents preserved");
testText("<div><fieldset><legend>abc", "abc", "<fieldset> <legend> contents preserved");
testText("<div><input type='text' value='abc'>", "", "<input> contents ignored");
testText("<div><textarea>abc", "", "<textarea> contents ignored");
testText("<div><select size='1'><option>abc</option><option>def", "", "<select size='1'> contents ignored");
testText("<div><select size='2'><option>abc</option><option>def", "", "<select size='2'> contents ignored");
testText("<div><iframe>abc", "", "<iframe> contents ignored");
testText("<div><iframe src='data:text/html,abc'>", ""," <iframe> subdocument ignored");
testText("<div><audio>abc", "", "<audio> contents ignored");
testText("<div><video>abc", "", "<video> contents ignored");
testText("<div><canvas>abc", "", "<canvas> contents ignored");
testText("<div><img alt='abc'>", "", "<img> alt text ignored");
/**** Lines around blocks ****/
testText("<div>123<div>abc</div>def", "123\nabc\ndef", "Newline at block boundary");
testText("<div>123<span style='display:block'>abc</span>def", "123\nabc\ndef", "Newline at display:block boundary");
testText("<div>abc<div></div>def", "abc\ndef", "Empty block induces single line break");
testText("<div>abc<div></div><div></div>def", "abc\ndef", "Consecutive empty blocks ignored");
testText("<div><p>abc", "abc", "No blank lines around <p> alone");
testText("<div><p>abc</p> ", "abc", "No blank lines around <p> followed by only collapsible whitespace");
testText("<div> <p>abc</p>", "abc", "No blank lines around <p> preceded by only collapsible whitespace");
testText("<div><p>abc<p>def", "abc\n\ndef", "Blank line between consecutive <p>s");
testText("<div><p>abc</p> <p>def", "abc\n\ndef", "Blank line between consecutive <p>s separated only by collapsible whitespace");
testText("<div><p>abc</p><div></div><p>def", "abc\n\ndef", "Blank line between consecutive <p>s separated only by empty block");
testText("<div><p>abc</p><div>123</div><p>def", "abc\n\n123\n\ndef", "Blank lines between <p>s separated by non-empty block");
testText("<div>abc<div><p>123</p></div>def", "abc\n\n123\n\ndef", "Blank lines around a <p> in its own block");
testText("<div>abc<p>def", "abc\n\ndef", "Blank line before <p>");
testText("<div><p>abc</p>def", "abc\n\ndef", "Blank line after <p>");
testText("<div><p>abc<p></p><p></p><p>def", "abc\n\ndef", "One blank line between <p>s, ignoring empty <p>s");
testText("<div style='visibility:hidden'><p><span style='visibility:visible'>abc</span></p>\n<div style='visibility:visible'>def</div>",
"abc\ndef", "Invisible <p> doesn't induce extra line breaks");
testText("<div>abc<div style='margin:2em'>def", "abc\ndef", "No blank lines around <div> with margin");
testText("<div>123<span style='display:inline-block'>abc</span>def", "123abcdef", "No newlines at display:inline-block boundary");
testText("<div>123<span style='display:inline-block'> abc </span>def", "123abcdef", "Leading/trailing space removal at display:inline-block boundary");
/**** Spans ****/
testText("<div>123<span>abc</span>def", "123abcdef", "<span> boundaries are irrelevant");
testText("<div>123 <span>abc</span> def", "123 abc def", "<span> boundaries are irrelevant");
testText("<div style='width:0'>123 <span>abc</span> def", "123 abc def", "<span> boundaries are irrelevant");
testText("<div>123<em>abc</em>def", "123abcdef", "<em> gets no special treatment");
testText("<div>123<b>abc</b>def", "123abcdef", "<b> gets no special treatment");
testText("<div>123<i>abc</i>def", "123abcdef", "<i> gets no special treatment");
testText("<div>123<strong>abc</strong>def", "123abcdef", "<strong> gets no special treatment");
testText("<div>123<tt>abc</tt>def", "123abcdef", "<tt> gets no special treatment");
testText("<div>123<code>abc</code>def", "123abcdef", "<code> gets no special treatment");
/**** Soft hyphen ****/
testText("<div>abc&shy;def", "abc\xADdef", "soft hyphen preserved");
testText("<div style='width:0'>abc&shy;def", "abc\xADdef", "soft hyphen preserved");
/**** Tables ****/
testText("<div><table style='white-space:pre'> <td>abc</td> </table>", "abc", "Ignoring non-rendered table whitespace");
testText("<div><table><tr><td>abc<td>def</table>", "abc\tdef", "Tab-separated table cells");
testText("<div><table><tr><td>abc<td><td>def</table>", "abc\t\tdef", "Tab-separated table cells including empty cells");
testText("<div><table><tr><td>abc<td><td></table>", "abc\t\t", "Tab-separated table cells including trailing empty cells");
testText("<div><table><tr><td>abc<tr><td>def</table>", "abc\ndef", "Newline-separated table rows");
testText("<div>abc<table><td>def</table>ghi", "abc\ndef\nghi", "Newlines around table");
testText("<div><table style='border-collapse:collapse'><tr><td>abc<td>def</table>", "abc\tdef",
"Tab-separated table cells in a border-collapse table");
testText("<div><table><tfoot>x</tfoot><tbody>y</tbody></table>", "xy", "tfoot not reordered");
testText("<table><tfoot><tr><td>footer</tfoot><thead><tr><td style='visibility:collapse'>thead</thead><tbody><tr><td>tbody</tbody></table>",
"footer\n\ntbody", "");
/**** Table captions ****/
testText("<div><table><tr><td>abc<caption>def</caption></table>", "abc\ndef", "Newline between cells and caption");
/**** display:table ****/
testText("<div><div class='table'><span class='cell'>abc</span>\n<span class='cell'>def</span></div>",
"abc\tdef", "Tab-separated table cells");
testText("<div><div class='table'><span class='row'><span class='cell'>abc</span></span>\n<span class='row'><span class='cell'>def</span></span></div>",
"abc\ndef", "Newline-separated table rows");
testText("<div>abc<div class='table'><span class='cell'>def</span></div>ghi", "abc\ndef\nghi", "Newlines around table");
/**** display:inline-table ****/
testText("<div><div class='itable'><span class='cell'>abc</span>\n<span class='cell'>def</span></div>", "abc\tdef", "Tab-separated table cells");
testText("<div><div class='itable'><span class='row'><span class='cell'>abc</span></span>\n<span class='row'><span class='cell'>def</span></span></div>",
"abc\ndef", "Newline-separated table rows");
testText("<div>abc<div class='itable'><span class='cell'>def</span></div>ghi", "abcdefghi", "No newlines around inline-table");
testText("<div>abc<div class='itable'><span class='row'><span class='cell'>def</span></span>\n<span class='row'><span class='cell'>123</span></span></div>ghi",
"abcdef\n123ghi", "Single newline in two-row inline-table");
/**** Lists ****/
testText("<div><ol><li>abc", "abc", "<ol> list items get no special treatment");
testText("<div><ul><li>abc", "abc", "<ul> list items get no special treatment");
/**** Misc elements ****/
testText("<div><script style='display:block'>abc", "abc", "display:block <script> is rendered");
testText("<div><style style='display:block'>abc", "abc", "display:block <style> is rendered");
testText("<div><noscript style='display:block'>abc", "", "display:block <noscript> is not rendered (it's not parsed!)");
testText("<div><template style='display:block'>abc", "",
"display:block <template> contents are not rendered (the contents are in a different document)");
testText("<div>abc<br>def", "abc\ndef", "<br> induces line break");
testText("<div>abc<br>", "abc\n", "<br> induces line break even at end of block");
testText("<div><br class='poke'>", "\n", "<br> content ignored");
testText("<div>abc<hr>def", "abc\ndef", "<hr> induces line break");
testText("<div>abc<hr><hr>def", "abc\ndef", "<hr><hr> induces just one line break");
testText("<div>abc<hr><hr><hr>def", "abc\ndef", "<hr><hr><hr> induces just one line break");
testText("<div><hr class='poke'>", "abc", "<hr> content rendered");
testText("<div>abc<!--comment-->def", "abcdef", "comment ignored");
/**** text-transform ****/
testText("<div><div style='text-transform:uppercase'>abc", "ABC", "text-transform is applied");
/**** block-in-inline ****/
testText("<div>abc<span>123<div>456</div>789</span>def", "abc123\n456\n789def", "block-in-inline doesn't add unnecessary newlines");
/**** floats ****/
testText("<div>abc<div style='float:left'>123</div>def", "abc\n123\ndef", "floats induce a block boundary");
testText("<div>abc<span style='float:left'>123</span>def", "abc\n123\ndef", "floats induce a block boundary");
/**** position ****/
testText("<div>abc<div style='position:absolute'>123</div>def", "abc\n123\ndef", "position:absolute induces a block boundary");
testText("<div>abc<span style='position:absolute'>123</span>def", "abc\n123\ndef", "position:absolute induces a block boundary");
testText("<div>abc<div style='position:relative'>123</div>def", "abc\n123\ndef", "position:relative has no effect");
testText("<div>abc<span style='position:relative'>123</span>def", "abc123def", "position:relative has no effect");
/**** text-overflow:ellipsis ****/
testText("<div style='overflow:hidden'>abc", "abc", "overflow:hidden ignored");
// XXX Chrome skips content with width:0 or height:0 and overflow:hidden;
// should we spec that?
testText("<div style='width:0; overflow:hidden'>abc", "abc", "overflow:hidden ignored even with zero width");
testText("<div style='height:0; overflow:hidden'>abc", "abc", "overflow:hidden ignored even with zero height");
testText("<div style='width:0; overflow:hidden; text-overflow:ellipsis'>abc", "abc", "text-overflow:ellipsis ignored");
/**** Support on non-HTML elements ****/
testText("<svg>abc", undefined, "innerText not supported on SVG elements");
testText("<math>abc", undefined, "innerText not supported on MathML elements");
/**** Ruby ****/
testText("<div><ruby>abc<rp>(</rp><rt>def</rt><rp>)</rp></ruby>", "abc(def)", "<rp> rendered");
testText("<div><rp>abc</rp>", "abc", "Lone <rp> rendered");
testText("<div><rp style='visibility:hidden'>abc</rp>", "", "visibility:hidden <rp> not rendered");
testText("<div><rp> abc </rp>", " abc ", "Lone <rp> rendered without whitespace trimming");
testText("<div><rp style='display:block'>abc</rp>def", "abc\ndef", "display:block <rp> induces line breaks");
testText("<div><rp style='display:block'> abc </rp>def", " abc \ndef", "display:block <rp> induces line breaks but doesn't trim whitespace");
// XXX this is not desirable but the spec currently requires it.
testText("<div><select class='poke-rp'></select>", "abc", "<rp> in a replaced element still renders");
/**** Shadow DOM ****/
if ("createShadowRoot" in document.body) {
testText("<div class='shadow'>", "", "Shadow DOM contents ignored");
testText("<div><div class='shadow'>", "", "Shadow DOM contents ignored");
}
/**** Flexbox ****/
if (CSS.supports('display', 'flex')) {
testText("<div style='display:flex'><div style='order:1'>1</div><div>2</div></div>",
"1\n2", "CSS 'order' property ignored");
testText("<div style='display:flex'><span>1</span><span>2</span></div>",
"1\n2", "Flex items blockified");
}
/**** Grid ****/
if (CSS.supports('display', 'grid')) {
testText("<div style='display:grid'><div style='order:1'>1</div><div>2</div></div>",
"1\n2", "CSS 'order' property ignored");
testText("<div style='display:grid'><span>1</span><span>2</span></div>",
"1\n2", "Grid items blockified");
}

View file

@ -0,0 +1,46 @@
<!DOCTYPE html>
<title>innerText getter test</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
.before::before { content:'abc'; }
.table { display:table; }
.itable { display:inline-table; }
.row { display:table-row; }
.cell { display:table-cell; }
.first-line-uppercase::first-line { text-transform:uppercase; }
.first-letter-uppercase::first-letter { text-transform:uppercase; }
.first-letter-float::first-letter { float:left; }
</style>
<div id="container"></div>
<script>
function testText(html, expectedPlain, msg) {
test(function() {
container.innerHTML = html;
var e = document.getElementById('target');
if (!e) {
e = container.firstChild;
}
var pokes = document.getElementsByClassName('poke');
for (var i = 0; i < pokes.length; ++i) {
pokes[i].textContent = 'abc';
}
pokes = document.getElementsByClassName('poke-rp');
for (var i = 0; i < pokes.length; ++i) {
var rp = document.createElement("rp");
rp.textContent = "abc";
pokes[i].appendChild(rp);
}
var shadows = document.getElementsByClassName('shadow');
for (var i = 0; i < shadows.length; ++i) {
var s = shadows[i].createShadowRoot();
s.textContent = 'abc';
}
while (e && e.nodeType != Node.ELEMENT_NODE) {
e = e.nextSibling;
}
assert_equals(e.innerText, expectedPlain);
}, msg);
}
</script>
<script src="getter-tests.js"></script>

View file

@ -0,0 +1,24 @@
testText("<div>", "abc", "abc", "Simplest possible test");
testHTML("<div>", "abc\ndef", "abc<br>def", "Newlines convert to <br> in non-white-space:pre elements");
testHTML("<pre>", "abc\ndef", "abc<br>def", "Newlines convert to <br> in <pre> element");
testHTML("<div style='white-space:pre'>", "abc\ndef", "abc<br>def", "Newlines convert to <br> in white-space:pre element");
testHTML("<div>", "abc\rdef", "abc<br>def", "CRs convert to <br> in non-white-space:pre elements");
testHTML("<pre>", "abc\rdef", "abc<br>def", "CRs convert to <br> in <pre> element");
testHTML("<div>", "abc\r\ndef", "abc<br>def", "Newline/CR pair converts to <br> in non-white-space:pre element");
testHTML("<div>", "abc\n\ndef", "abc<br><br>def", "Newline/newline pair converts to two <br>s in non-white-space:pre element");
testHTML("<div>", "abc\r\rdef", "abc<br><br>def", "CR/CR pair converts to two <br>s in non-white-space:pre element");
testHTML("<div style='white-space:pre'>", "abc\rdef", "abc<br>def", "CRs convert to <br> in white-space:pre element");
testText("<div>", "abc<def", "abc<def", "< preserved");
testText("<div>", "abc>def", "abc>def", "> preserved");
testText("<div>", "abc&", "abc&", "& preserved");
testText("<div>", "abc\"def", "abc\"def", "\" preserved");
testText("<div>", "abc\'def", "abc\'def", "\' preserved");
testHTML("<svg>", "abc", "", "innerText not supported on SVG elements");
testHTML("<math>", "abc", "", "innerText not supported on MathML elements");
testText("<div>", "abc\0def", "abc\0def", "Null characters preserved");
testText("<div>", "abc\tdef", "abc\tdef", "Tabs preserved");
testText("<div>", " abc", " abc", "Leading whitespace preserved");
testText("<div>", "abc ", "abc ", "Trailing whitespace preserved");
testText("<div>", "abc def", "abc def", "Whitespace not compressed");
testHTML("<div>abc\n\n", "abc", "abc", "Existing text deleted");
testHTML("<div><br>", "abc", "abc", "Existing <br> deleted");

View file

@ -0,0 +1,32 @@
<!DOCTYPE html>
<title>innerText setter test</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="container"></div>
<script>
function setupTest(context, plain) {
container.innerHTML = context;
var e = container.firstChild;
while (e && e.nodeType != Node.ELEMENT_NODE) {
e = e.nextSibling;
}
e.innerText = plain;
return e;
}
function testText(context, plain, expectedText, msg) {
test(function(){
var e = setupTest(context, plain);
assert_not_equals(e.firstChild, null, "Should have a child");
assert_equals(e.firstChild.nodeType, Node.TEXT_NODE, "Child should be a text node");
assert_equals(e.firstChild.nextSibling, null, "Should have only one child");
assert_equals(e.firstChild.data, expectedText);
}, msg);
}
function testHTML(context, plain, expectedHTML, msg) {
test(function(){
var e = setupTest(context, plain);
assert_equals(e.innerHTML, expectedHTML);
}, msg);
}
</script>
<script src="setter-tests.js"></script>

View file

@ -24,7 +24,6 @@ INDENT TABS: tools/*
INDENT TABS: touch-events/* INDENT TABS: touch-events/*
INDENT TABS: web-animations/* INDENT TABS: web-animations/*
INDENT TABS: webaudio/* INDENT TABS: webaudio/*
INDENT TABS: webdriver/*
INDENT TABS: webvtt/* INDENT TABS: webvtt/*
INDENT TABS: XMLHttpRequest/* INDENT TABS: XMLHttpRequest/*
@ -43,7 +42,6 @@ TRAILING WHITESPACE: shadow-dom/*
TRAILING WHITESPACE: svg/import/* TRAILING WHITESPACE: svg/import/*
TRAILING WHITESPACE: tools/* TRAILING WHITESPACE: tools/*
TRAILING WHITESPACE: webaudio/* TRAILING WHITESPACE: webaudio/*
TRAILING WHITESPACE: webdriver/*
TRAILING WHITESPACE: WebIDL/* TRAILING WHITESPACE: WebIDL/*
TRAILING WHITESPACE: webvtt/* TRAILING WHITESPACE: webvtt/*
TRAILING WHITESPACE: XMLHttpRequest/* TRAILING WHITESPACE: XMLHttpRequest/*

View file

@ -83,7 +83,8 @@ function setAttributes(el, attrs) {
function bindEvents(element, resolveEventName, rejectEventName) { function bindEvents(element, resolveEventName, rejectEventName) {
element.eventPromise = new Promise(function(resolve, reject) { element.eventPromise = new Promise(function(resolve, reject) {
element.addEventListener(resolveEventName || "load", resolve); element.addEventListener(resolveEventName || "load", resolve);
element.addEventListener(rejectEventName || "error", reject); element.addEventListener(rejectEventName || "error",
function(e) { e.preventDefault(); reject(); } );
}); });
} }

View file

@ -34,6 +34,7 @@
<script type='text/javascript'> <script type='text/javascript'>
var isPointerCapture = false; var isPointerCapture = false;
var isRelatedTargetValueTested = false; var isRelatedTargetValueTested = false;
var isTargetAuthenticityTested = false;
var count = 0; var count = 0;
var detected_pointertypes = {}; var detected_pointertypes = {};
@ -92,6 +93,13 @@
}, "relatedTarget is null when the capture is set. relatedTarget is " + event.relatedTarget); }, "relatedTarget is null when the capture is set. relatedTarget is " + event.relatedTarget);
isRelatedTargetValueTested = true; 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 { else {
test_pointerover_no_capture.done(); test_pointerover_no_capture.done();

View file

@ -11,11 +11,16 @@
<iframe id=quirks></iframe> <iframe id=quirks></iframe>
<iframe id=almost></iframe> <iframe id=almost></iframe>
<iframe id=standards></iframe> <iframe id=standards></iframe>
<img id="preload">
<script> <script>
var png = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==";
// Ensure png is loaded and cached before we run the tests. Otherwise
// the tests that use it may run while it's not fully loaded and get <img>
// fallback layout (i.e., not an image with a 1x1 intrinsic size).
document.getElementById('preload').src = png;
setup({explicit_done:true}); setup({explicit_done:true});
onload = function() { onload = function() {
var html = "<style id=style></style>"; var html = "<style id=style></style>";
var png = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==";
var a_doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'; var a_doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
var s_doctype = '<!DOCTYPE HTML>'; var s_doctype = '<!DOCTYPE HTML>';
var q = document.getElementById('quirks').contentWindow; var q = document.getElementById('quirks').contentWindow;
@ -80,7 +85,9 @@
tests.forEach(function(t) { tests.forEach(function(t) {
test(function() { test(function() {
var style = t.style.replace(/\{png\}/g, png); // Hide scrollbars in all subdocuments so that a horizontal
// scrollbar doesn't appear and upset our calculations.
var style = t.style.replace(/\{png\}/g, png) + " html { overflow:hidden; }";
var body = t.body.replace(/\{png\}/g, png); var body = t.body.replace(/\{png\}/g, png);
q.style.textContent = style; q.style.textContent = style;
a.style.textContent = style; a.style.textContent = style;

View file

@ -1,2 +1,2 @@
Access-Control-Allow-Origin: {{location[scheme]}}://{{location[hostname]}}:{{ports[http][0]}} Access-Control-Allow-Origin: {{location[scheme]}}://{{domains[]}}{{GET[acao_port]}}
Access-Control-Allow-Credentials: true Access-Control-Allow-Credentials: true

View file

@ -1,2 +1,2 @@
Access-Control-Allow-Origin: {{location[scheme]}}://{{location[hostname]}}:{{ports[http][0]}} Access-Control-Allow-Origin: {{location[scheme]}}://{{domains[]}}{{GET[acao_port]}}
Access-Control-Allow-Credentials: true Access-Control-Allow-Credentials: true

View file

@ -8,17 +8,42 @@
<div id="container"></div> <div id="container"></div>
<script> <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 // <script> tests
var xorigin_anon_script = location.protocol var xorigin_anon_script = location.protocol
+ '//' + location.hostname + ':' + {{ports[http][1]}} + '//' + www_host_and_port
+ '/subresource-integrity/crossorigin-anon-script.js'; + '/subresource-integrity/crossorigin-anon-script.js';
var xorigin_creds_script = location.protocol var xorigin_creds_script = location.protocol
+ '//' + location.hostname + ':' + {{ports[http][1]}} + '//' + www_host_and_port
+ '/subresource-integrity/crossorigin-creds-script.js'; + '/subresource-integrity/crossorigin-creds-script.js?acao_port='
+ port_string;
var xorigin_ineligible_script = location.protocol var xorigin_ineligible_script = location.protocol
+ '//' + location.hostname + ':' + {{ports[http][1]}} + '//' + www_host_and_port
+ '/subresource-integrity/crossorigin-ineligible-script.js'; + '/subresource-integrity/crossorigin-ineligible-script.js';
var SRIScriptTest = function(pass, name, src, integrityValue, crossoriginValue) { var SRIScriptTest = function(pass, name, src, integrityValue, crossoriginValue) {
@ -51,17 +76,20 @@
document.body.appendChild(e); 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 var xorigin_anon_style = location.protocol
+ '//' + location.hostname + ':' + {{ports[http][1]}} + '//' + www_host_and_port
+ '/subresource-integrity/crossorigin-anon-style.css'; + '/subresource-integrity/crossorigin-anon-style.css?';
var xorigin_creds_style = location.protocol var xorigin_creds_style = location.protocol
+ '//' + location.hostname + ':' + {{ports[http][1]}} + '//' + www_host_and_port
+ '/subresource-integrity/crossorigin-creds-style.css'; + '/subresource-integrity/crossorigin-creds-style.css?acao_port='
+ port_string;
var xorigin_ineligible_style = location.protocol var xorigin_ineligible_style = location.protocol
+ '//' + location.hostname + ':' + {{ports[http][1]}} + '//' + www_host_and_port
+ '/subresource-integrity/crossorigin-ineligible-style.css'; + '/subresource-integrity/crossorigin-ineligible-style.css?';
// <link> tests // <link> tests
// Style tests must be done synchronously because they rely on the presence // Style tests must be done synchronously because they rely on the presence
@ -376,7 +404,7 @@
true, true,
"<crossorigin='anonymous'> with correct hash, ACAO: *", "<crossorigin='anonymous'> with correct hash, ACAO: *",
{ {
href: xorigin_anon_style + '?1', href: xorigin_anon_style + '&1',
integrity: "sha256-CzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk7gyCWUV4=", integrity: "sha256-CzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk7gyCWUV4=",
crossorigin: "anonymous" crossorigin: "anonymous"
} }
@ -387,7 +415,7 @@
false, false,
"<crossorigin='anonymous'> with incorrect hash, ACAO: *", "<crossorigin='anonymous'> with incorrect hash, ACAO: *",
{ {
href: xorigin_anon_style + '?2', href: xorigin_anon_style + '&2',
integrity: "sha256-deadbeefCzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk=", integrity: "sha256-deadbeefCzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk=",
crossorigin: "anonymous" crossorigin: "anonymous"
} }
@ -398,7 +426,7 @@
true, true,
"<crossorigin='use-credentials'> with correct hash, CORS-eligible", "<crossorigin='use-credentials'> with correct hash, CORS-eligible",
{ {
href: xorigin_creds_style + '?1', href: xorigin_creds_style + '&1',
integrity: "sha256-CzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk7gyCWUV4=", integrity: "sha256-CzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk7gyCWUV4=",
crossorigin: "use-credentials" crossorigin: "use-credentials"
} }
@ -409,7 +437,7 @@
false, false,
"<crossorigin='use-credentials'> with incorrect hash CORS-eligible", "<crossorigin='use-credentials'> with incorrect hash CORS-eligible",
{ {
href: xorigin_creds_style + '?2', href: xorigin_creds_style + '&2',
integrity: "sha256-deadbeefCzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk=", integrity: "sha256-deadbeefCzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk=",
crossorigin: "use-credentials" crossorigin: "use-credentials"
} }
@ -420,7 +448,7 @@
false, false,
"<crossorigin='anonymous'> with CORS-ineligible resource", "<crossorigin='anonymous'> with CORS-ineligible resource",
{ {
href: xorigin_ineligible_style + '?1', href: xorigin_ineligible_style + '&1',
integrity: "sha256-CzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk7gyCWUV4=", integrity: "sha256-CzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk7gyCWUV4=",
crossorigin: "anonymous" crossorigin: "anonymous"
} }
@ -431,7 +459,7 @@
false, false,
"Cross-origin, not CORS request, with correct hash", "Cross-origin, not CORS request, with correct hash",
{ {
href: xorigin_anon_style + '?3', href: xorigin_anon_style + '&3',
integrity: "sha256-CzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk7gyCWUV4=" integrity: "sha256-CzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk7gyCWUV4="
} }
); );
@ -441,7 +469,7 @@
false, false,
"Cross-origin, not CORS request, with hash mismatch", "Cross-origin, not CORS request, with hash mismatch",
{ {
href: xorigin_anon_style + '?4', href: xorigin_anon_style + '&4',
integrity: "sha256-deadbeefCzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk=" integrity: "sha256-deadbeefCzHgdJ7wOccM8L89n4bhcJMz3F+SPLT7YZk="
} }
); );
@ -451,7 +479,7 @@
true, true,
"Cross-origin, empty integrity", "Cross-origin, empty integrity",
{ {
href: xorigin_anon_style + '?5', href: xorigin_anon_style + '&5',
integrity: "" integrity: ""
} }
); );

View file

@ -3,4 +3,4 @@
*.sw[po] *.sw[po]
*~ *~
\#* \#*
runner/MANIFEST.json

View file

@ -1,8 +1,18 @@
import os
import urlparse import urlparse
from abc import ABCMeta, abstractmethod, abstractproperty from abc import ABCMeta, abstractmethod, abstractproperty
item_types = ["testharness", "reftest", "manual", "stub", "wdspec"] item_types = ["testharness", "reftest", "manual", "stub", "wdspec"]
def from_os_path(path):
return path.replace(os.path.sep, "/")
def to_os_path(path):
return path.replace("/", os.path.sep)
def get_source_file(source_files, tests_root, manifest, path): def get_source_file(source_files, tests_root, manifest, path):
def make_new(): def make_new():
from sourcefile import SourceFile from sourcefile import SourceFile
@ -17,6 +27,7 @@ def get_source_file(source_files, tests_root, manifest, path):
return source_files[path] return source_files[path]
class ManifestItem(object): class ManifestItem(object):
__metaclass__ = ABCMeta __metaclass__ = ABCMeta
@ -58,7 +69,7 @@ class ManifestItem(object):
return hash(self.key() + self.meta_key()) return hash(self.key() + self.meta_key())
def to_json(self): def to_json(self):
return {"path": self.path} return {"path": from_os_path(self.path)}
@classmethod @classmethod
def from_json(self, manifest, tests_root, obj, source_files=None): def from_json(self, manifest, tests_root, obj, source_files=None):
@ -86,7 +97,8 @@ class URLManifestItem(ManifestItem):
@classmethod @classmethod
def from_json(cls, manifest, tests_root, obj, source_files=None): def from_json(cls, manifest, tests_root, obj, source_files=None):
source_file = get_source_file(source_files, tests_root, manifest, obj["path"]) source_file = get_source_file(source_files, tests_root, manifest,
to_os_path(obj["path"]))
return cls(source_file, return cls(source_file,
obj["url"], obj["url"],
url_base=manifest.url_base, url_base=manifest.url_base,
@ -111,7 +123,8 @@ class TestharnessTest(URLManifestItem):
@classmethod @classmethod
def from_json(cls, manifest, tests_root, obj, source_files=None): def from_json(cls, manifest, tests_root, obj, source_files=None):
source_file = get_source_file(source_files, tests_root, manifest, obj["path"]) source_file = get_source_file(source_files, tests_root, manifest,
to_os_path(obj["path"]))
return cls(source_file, return cls(source_file,
obj["url"], obj["url"],
url_base=manifest.url_base, url_base=manifest.url_base,
@ -147,7 +160,8 @@ class RefTest(URLManifestItem):
@classmethod @classmethod
def from_json(cls, manifest, tests_root, obj, source_files=None): def from_json(cls, manifest, tests_root, obj, source_files=None):
source_file = get_source_file(source_files, tests_root, manifest, obj["path"]) source_file = get_source_file(source_files, tests_root, manifest,
to_os_path(obj["path"]))
return cls(source_file, return cls(source_file,
obj["url"], obj["url"],
obj["references"], obj["references"],
@ -171,5 +185,6 @@ class WebdriverSpecTest(ManifestItem):
@classmethod @classmethod
def from_json(cls, manifest, tests_root, obj, source_files=None): def from_json(cls, manifest, tests_root, obj, source_files=None):
source_file = get_source_file(source_files, tests_root, manifest, obj["path"]) source_file = get_source_file(source_files, tests_root, manifest,
to_os_path(obj["path"]))
return cls(source_file, manifest=manifest) return cls(source_file, manifest=manifest)

View file

@ -376,3 +376,4 @@ def load(tests_root, manifest):
def write(manifest, manifest_path): def write(manifest, manifest_path):
with open(manifest_path, "w") as f: with open(manifest_path, "w") as f:
json.dump(manifest.to_json(), f, sort_keys=True, indent=2, separators=(',', ': ')) json.dump(manifest.to_json(), f, sort_keys=True, indent=2, separators=(',', ': '))
f.write("\n")

View file

@ -85,7 +85,7 @@ class WebDriver(searchcontext.SearchContext):
def get_window_size(self): def get_window_size(self):
"""Get the dimensions of the current window.""" """Get the dimensions of the current window."""
result = self._window_command('GET', '/size', 'getWindowSize') 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): def set_window_size(self, height, width):
"""Set the size of the current window.""" """Set the size of the current window."""

View file

@ -0,0 +1,11 @@
/*
Extending the W3C testharness.js with locally useful functionality.
*/
function assert_type_error(f, msg) {
assert_throws(TypeError(), f, msg);
}
function assert_syntax_error(f, msg) {
assert_throws(SyntaxError(), f, msg);
}

View file

@ -0,0 +1,51 @@
<!doctype html>
<html>
<head>
<meta charset="utf8">
<link rel="help" href="http://url.spec.whatwg.org/#dom-urlsearchparams-append">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/testharness-extras.js"></script>
<script>
test(function() {
var params = new URLSearchParams();
params.append('a', 'b');
assert_equals(params + '', 'a=b');
params.append('a', 'b');
assert_equals(params + '', 'a=b&a=b');
params.append('a', 'c');
assert_equals(params + '', 'a=b&a=b&a=c');
}, 'Append same name');
test(function() {
var params = new URLSearchParams();
params.append('', '');
assert_equals(params + '', '=');
params.append('', '');
assert_equals(params + '', '=&=');
}, 'Append empty strings');
test(function() {
var params = new URLSearchParams();
params.append(null, null);
assert_equals(params + '', 'null=null');
params.append(null, null);
assert_equals(params + '', 'null=null&null=null');
}, 'Append null');
test(function() {
var params = new URLSearchParams();
params.append('first', 1);
params.append('second', 2);
params.append('third', '');
params.append('first', 10);
assert_true(params.has('first'), 'Search params object has name "first"');
assert_equals(params.get('first'), '1', 'Search params object has name "first" with value "1"');
assert_equals(params.get('second'), '2', 'Search params object has name "second" with value "2"');
assert_equals(params.get('third'), '', 'Search params object has name "third" with value ""');
params.append('first', 10);
assert_equals(params.get('first'), '1', 'Search params object has name "first" with value "1"');
}, 'Append multiple');
</script>
</head>
</html>

View file

@ -0,0 +1,129 @@
<!doctype html>
<html>
<head>
<meta charset="utf8">
<link rel="help" href="http://url.spec.whatwg.org/#urlsearchparams">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/testharness-extras.js"></script>
<script>
test(function() {
var params = new URLSearchParams();
assert_equals(params + '', '');
params = new URLSearchParams('');
assert_equals(params + '', '');
params = new URLSearchParams('a=b');
assert_equals(params + '', 'a=b');
params = new URLSearchParams(params);
assert_equals(params + '', 'a=b');
}, 'Basic URLSearchParams construction');
test(function() {
assert_type_error(function () { URLSearchParams(); }, 'Failed to construct \'URLSearchParams\': Please use the \'new\' operator, this DOM object constructor cannot be called as a function.');
assert_type_error(function () { new URLSearchParams(DOMException.prototype); });
var params = new URLSearchParams('');
assert_true(params != null, 'constructor returned non-null value.');
assert_equals(params.__proto__, URLSearchParams.prototype, 'expected URLSearchParams.prototype as prototype.');
params = new URLSearchParams({});
assert_equals(params + '', '%5Bobject+Object%5D=');
}, 'URLSearchParams constructor, empty.');
test(function() {
var params = new URLSearchParams('a=b');
assert_true(params != null, 'constructor returned non-null value.');
assert_true(params.has('a'), 'Search params object has name "a"');
assert_false(params.has('b'), 'Search params object has not got name "b"');
var params = new URLSearchParams('a=b&c');
assert_true(params != null, 'constructor returned non-null value.');
assert_true(params.has('a'), 'Search params object has name "a"');
assert_true(params.has('c'), 'Search params object has name "c"');
var params = new URLSearchParams('&a&&& &&&&&a+b=& c&m%c3%b8%c3%b8');
assert_true(params != null, 'constructor returned non-null value.');
assert_true(params.has('a'), 'Search params object has name "a"');
assert_true(params.has('a b'), 'Search params object has name "a b"');
assert_true(params.has(' '), 'Search params object has name " "');
assert_false(params.has('c'), 'Search params object did not have the name "c"');
assert_true(params.has(' c'), 'Search params object has name " c"');
assert_true(params.has('møø'), 'Search params object has name "møø"');
}, 'URLSearchParams constructor, string.');
test(function() {
var seed = new URLSearchParams('a=b&c=d');
var params = new URLSearchParams(seed);
assert_true(params != null, 'constructor returned non-null value.');
assert_equals(params.get('a'), 'b');
assert_equals(params.get('c'), 'd');
assert_false(params.has('d'));
// The name-value pairs are copied when created; later updates
// should not be observable.
seed.append('e', 'f');
assert_false(params.has('e'));
params.append('g', 'h');
assert_false(seed.has('g'));
}, 'URLSearchParams constructor, object.');
test(function() {
var params = new URLSearchParams('a=b+c');
assert_equals(params.get('a'), 'b c');
params = new URLSearchParams('a+b=c');
assert_equals(params.get('a b'), 'c');
}, 'Parse +');
test(function() {
var params = new URLSearchParams('a=b c');
assert_equals(params.get('a'), 'b c');
params = new URLSearchParams('a b=c');
assert_equals(params.get('a b'), 'c');
}, 'Parse space');
test(function() {
var params = new URLSearchParams('a=b%20c');
assert_equals(params.get('a'), 'b c');
params = new URLSearchParams('a%20b=c');
assert_equals(params.get('a b'), 'c');
}, 'Parse %20');
test(function() {
var params = new URLSearchParams('a=b\0c');
assert_equals(params.get('a'), 'b\0c');
params = new URLSearchParams('a\0b=c');
assert_equals(params.get('a\0b'), 'c');
}, 'Parse \\0');
test(function() {
var params = new URLSearchParams('a=b%00c');
assert_equals(params.get('a'), 'b\0c');
params = new URLSearchParams('a%00b=c');
assert_equals(params.get('a\0b'), 'c');
}, 'Parse %00');
test(function() {
var params = new URLSearchParams('a=b\u2384');
assert_equals(params.get('a'), 'b\u2384');
params = new URLSearchParams('a\u2384b=c');
assert_equals(params.get('a\u2384b'), 'c');
}, 'Parse \u2384'); // Unicode Character 'COMPOSITION SYMBOL' (U+2384)
test(function() {
var params = new URLSearchParams('a=b%e2%8e%84');
assert_equals(params.get('a'), 'b\u2384');
params = new URLSearchParams('a%e2%8e%84b=c');
assert_equals(params.get('a\u2384b'), 'c');
}, 'Parse %e2%8e%84'); // Unicode Character 'COMPOSITION SYMBOL' (U+2384)
test(function() {
var params = new URLSearchParams('a=b\uD83D\uDCA9c');
assert_equals(params.get('a'), 'b\uD83D\uDCA9c');
params = new URLSearchParams('a\uD83D\uDCA9b=c');
assert_equals(params.get('a\uD83D\uDCA9b'), 'c');
}, 'Parse \uD83D\uDCA9'); // Unicode Character 'PILE OF POO' (U+1F4A9)
test(function() {
var params = new URLSearchParams('a=b%f0%9f%92%a9c');
assert_equals(params.get('a'), 'b\uD83D\uDCA9c');
params = new URLSearchParams('a%f0%9f%92%a9b=c');
assert_equals(params.get('a\uD83D\uDCA9b'), 'c');
}, 'Parse %f0%9f%92%a9'); // Unicode Character 'PILE OF POO' (U+1F4A9)
</script>
</head>
</html>

View file

@ -0,0 +1,42 @@
<!doctype html>
<html>
<head>
<meta charset="utf8">
<link rel="help" href="http://url.spec.whatwg.org/#dom-urlsearchparams-delete">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/testharness-extras.js"></script>
<script>
test(function() {
var params = new URLSearchParams('a=b&c=d');
params.delete('a');
assert_equals(params + '', 'c=d');
params = new URLSearchParams('a=a&b=b&a=a&c=c');
params.delete('a');
assert_equals(params + '', 'b=b&c=c');
params = new URLSearchParams('a=a&=&b=b&c=c');
params.delete('');
assert_equals(params + '', 'a=a&b=b&c=c');
params = new URLSearchParams('a=a&null=null&b=b');
params.delete(null);
assert_equals(params + '', 'a=a&b=b');
params = new URLSearchParams('a=a&undefined=undefined&b=b');
params.delete(undefined);
assert_equals(params + '', 'a=a&b=b');
}, 'Delete basics');
test(function() {
var params = new URLSearchParams();
params.append('first', 1);
assert_true(params.has('first'), 'Search params object has name "first"');
assert_equals(params.get('first'), '1', 'Search params object has name "first" with value "1"');
params.delete('first');
assert_false(params.has('first'), 'Search params object has no "first" name');
params.append('first', 1);
params.append('first', 10);
params.delete('first');
assert_false(params.has('first'), 'Search params object has no "first" name');
}, 'Deleting appended multiple');
</script>
</head>
</html>

View file

@ -0,0 +1,33 @@
<!doctype html>
<html>
<head>
<meta charset="utf8">
<link rel="help" href="http://url.spec.whatwg.org/#dom-urlsearchparams-get">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/testharness-extras.js"></script>
<script>
test(function() {
var params = new URLSearchParams('a=b&c=d');
assert_equals(params.get('a'), 'b');
assert_equals(params.get('c'), 'd');
assert_equals(params.get('e'), null);
params = new URLSearchParams('a=b&c=d&a=e');
assert_equals(params.get('a'), 'b');
params = new URLSearchParams('=b&c=d');
assert_equals(params.get(''), 'b');
params = new URLSearchParams('a=&c=d&a=e');
assert_equals(params.get('a'), '');
}, 'Get basics');
test(function() {
var params = new URLSearchParams('first=second&third&&');
assert_true(params != null, 'constructor returned non-null value.');
assert_true(params.has('first'), 'Search params object has name "first"');
assert_equals(params.get('first'), 'second', 'Search params object has name "first" with value "second"');
assert_equals(params.get('third'), '', 'Search params object has name "third" with the empty value.');
assert_equals(params.get('fourth'), null, 'Search params object has no "fourth" name and value.');
}, 'More get() basics');
</script>
</head>
</html>

View file

@ -0,0 +1,37 @@
<!doctype html>
<html>
<head>
<meta charset="utf8">
<link rel="help" href="http://url.spec.whatwg.org/#dom-urlsearchparams-getAll">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/testharness-extras.js"></script>
<script>
test(function() {
var params = new URLSearchParams('a=b&c=d');
assert_array_equals(params.getAll('a'), ['b']);
assert_array_equals(params.getAll('c'), ['d']);
assert_array_equals(params.getAll('e'), []);
params = new URLSearchParams('a=b&c=d&a=e');
assert_array_equals(params.getAll('a'), ['b', 'e']);
params = new URLSearchParams('=b&c=d');
assert_array_equals(params.getAll(''), ['b']);
params = new URLSearchParams('a=&c=d&a=e');
assert_array_equals(params.getAll('a'), ['', 'e']);
}, 'getAll() basics');
test(function() {
var params = new URLSearchParams('a=1&a=2&a=3&a');
assert_true(params.has('a'), 'Search params object has name "a"');
var matches = params.getAll('a');
assert_true(matches && matches.length == 4, 'Search params object has values for name "a"');
assert_array_equals(matches, ['1', '2', '3', ''], 'Search params object has expected name "a" values');
params.set('a', 'one');
assert_equals(params.get('a'), 'one', 'Search params object has name "a" with value "one"');
var matches = params.getAll('a');
assert_true(matches && matches.length == 1, 'Search params object has values for name "a"');
assert_array_equals(matches, ['one'], 'Search params object has expected name "a" values');
}, 'getAll() multiples');
</script>
</head>
</html>

View file

@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<meta charset="utf8">
<link rel="help" href="http://url.spec.whatwg.org/#dom-urlsearchparams-has">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/testharness-extras.js"></script>
<script>
test(function() {
var params = new URLSearchParams('a=b&c=d');
assert_true(params.has('a'));
assert_true(params.has('c'));
assert_false(params.has('e'));
params = new URLSearchParams('a=b&c=d&a=e');
assert_true(params.has('a'));
params = new URLSearchParams('=b&c=d');
assert_true(params.has(''));
params = new URLSearchParams('null=a');
assert_true(params.has(null));
}, 'Has basics');
test(function() {
var params = new URLSearchParams('a=b&c=d&&');
params.append('first', 1);
params.append('first', 2);
assert_true(params.has('a'), 'Search params object has name "a"');
assert_true(params.has('c'), 'Search params object has name "c"');
assert_true(params.has('first'), 'Search params object has name "first"');
assert_false(params.has('d'), 'Search params object has no name "d"');
params.delete('first');
assert_false(params.has('first'), 'Search params object has no name "first"');
}, 'has() following delete()');
</script>
</head>
</html>

View file

@ -0,0 +1,35 @@
<!doctype html>
<html>
<head>
<meta charset="utf8">
<link rel="help" href="http://url.spec.whatwg.org/#dom-urlsearchparams-set">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/testharness-extras.js"></script>
<script>
test(function() {
var params = new URLSearchParams('a=b&c=d');
params.set('a', 'B');
assert_equals(params + '', 'a=B&c=d');
params = new URLSearchParams('a=b&c=d&a=e');
params.set('a', 'B');
assert_equals(params + '', 'a=B&c=d')
params.set('e', 'f');
assert_equals(params + '', 'a=B&c=d&e=f')
}, 'Set basics');
test(function() {
var params = new URLSearchParams('a=1&a=2&a=3');
assert_true(params.has('a'), 'Search params object has name "a"');
assert_equals(params.get('a'), '1', 'Search params object has name "a" with value "1"');
params.set('first', 4);
assert_true(params.has('a'), 'Search params object has name "a"');
assert_equals(params.get('a'), '1', 'Search params object has name "a" with value "1"');
params.set('a', 4);
assert_true(params.has('a'), 'Search params object has name "a"');
assert_equals(params.get('a'), '4', 'Search params object has name "a" with value "4"');
}, 'URLSearchParams.set');
</script>
</head>
</html>

View file

@ -0,0 +1,123 @@
<!doctype html>
<html>
<head>
<meta charset="utf8">
<link rel="help" href="http://url.spec.whatwg.org/#dom-urlsearchparams-set">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/testharness-extras.js"></script>
<script>
test(function() {
var params = new URLSearchParams();
params.append('a', 'b c');
assert_equals(params + '', 'a=b+c');
params.delete('a');
params.append('a b', 'c');
assert_equals(params + '', 'a+b=c');
}, 'Serialize space');
test(function() {
var params = new URLSearchParams();
params.append('a', '');
assert_equals(params + '', 'a=');
params.append('a', '');
assert_equals(params + '', 'a=&a=');
params.append('', 'b');
assert_equals(params + '', 'a=&a=&=b');
params.append('', '');
assert_equals(params + '', 'a=&a=&=b&=');
params.append('', '');
assert_equals(params + '', 'a=&a=&=b&=&=');
}, 'Serialize empty value');
test(function() {
var params = new URLSearchParams();
params.append('', 'b');
assert_equals(params + '', '=b');
params.append('', 'b');
assert_equals(params + '', '=b&=b');
}, 'Serialize empty name');
test(function() {
var params = new URLSearchParams();
params.append('', '');
assert_equals(params + '', '=');
params.append('', '');
assert_equals(params + '', '=&=');
}, 'Serialize empty name and value');
test(function() {
var params = new URLSearchParams();
params.append('a', 'b+c');
assert_equals(params + '', 'a=b%2Bc');
params.delete('a');
params.append('a+b', 'c');
assert_equals(params + '', 'a%2Bb=c');
}, 'Serialize +');
test(function() {
var params = new URLSearchParams();
params.append('=', 'a');
assert_equals(params + '', '%3D=a');
params.append('b', '=');
assert_equals(params + '', '%3D=a&b=%3D');
}, 'Serialize =');
test(function() {
var params = new URLSearchParams();
params.append('&', 'a');
assert_equals(params + '', '%26=a');
params.append('b', '&');
assert_equals(params + '', '%26=a&b=%26');
}, 'Serialize &');
test(function() {
var params = new URLSearchParams();
params.append('a', '*-._');
assert_equals(params + '', 'a=*-._');
params.delete('a');
params.append('*-._', 'c');
assert_equals(params + '', '*-._=c');
}, 'Serialize *-._');
test(function() {
var params = new URLSearchParams();
params.append('a', 'b%c');
assert_equals(params + '', 'a=b%25c');
params.delete('a');
params.append('a%b', 'c');
assert_equals(params + '', 'a%25b=c');
}, 'Serialize %');
test(function() {
var params = new URLSearchParams();
params.append('a', 'b\0c');
assert_equals(params + '', 'a=b%00c');
params.delete('a');
params.append('a\0b', 'c');
assert_equals(params + '', 'a%00b=c');
}, 'Serialize \\0');
test(function() {
var params = new URLSearchParams();
params.append('a', 'b\uD83D\uDCA9c');
assert_equals(params + '', 'a=b%F0%9F%92%A9c');
params.delete('a');
params.append('a\uD83D\uDCA9b', 'c');
assert_equals(params + '', 'a%F0%9F%92%A9b=c');
}, 'Serialize \uD83D\uDCA9'); // Unicode Character 'PILE OF POO' (U+1F4A9)
test(function() {
var params;
params = new URLSearchParams('a=b&c=d&&e&&');
assert_equals(params.toString(), 'a=b&c=d&e=');
params = new URLSearchParams('a = b &a=b&c=d%20');
assert_equals(params.toString(), 'a+=+b+&a=b&c=d+');
// The lone '=' _does_ survive the roundtrip.
params = new URLSearchParams('a=&a=b');
assert_equals(params.toString(), 'a=&a=b');
}, 'URLSearchParams.toString');
</script>
</head>
</html>

View file

@ -0,0 +1,454 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>KeyframeEffectReadOnly constructor tests</title>
<link rel="help" href="http://w3c.github.io/web-animations/#the-keyframeeffect-interfaces">
<link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../testcommon.js"></script>
<link rel="stylesheet" href="/resources/testharness.css">
<body>
<div id="log"></div>
<div id="target"></div>
<style>
#target {
border-style: solid; /* so border-*-width values don't compute to 0 */
}
</style>
<script>
"use strict";
var target = document.getElementById("target");
function assert_frames_equal(a, b, name) {
assert_equals(Object.keys(a).sort().toString(),
Object.keys(b).sort().toString(),
"properties on " + name);
for (var p in a) {
assert_equals(a[p], b[p], "value for '" + p + "' on " + name);
}
}
function assert_frame_lists_equal(a, b) {
assert_equals(a.length, b.length, "number of frames");
for (var i = 0; i < Math.min(a.length, b.length); i++) {
assert_frames_equal(a[i], b[i], "ComputedKeyframe #" + i);
}
}
var gEmptyKeyframeListTests = [
[],
[{}],
[{ easing: "ease-in" }],
[{ unknown: "unknown" }, { unknown: "unknown" }],
[{ color: "invalid" }, { color: "invalid" }],
{ easing: "ease-in" },
{ unknown: "unknown" },
{ unknown: [] },
{ unknown: ["unknown"] },
{ unknown: ["unknown", "unknown"] },
{ animationName: ["none", "abc"] },
{ color: [] },
null,
undefined,
];
test(function(t) {
gEmptyKeyframeListTests.forEach(function(frames) {
assert_equals(new KeyframeEffectReadOnly(target, frames).getFrames().length,
0, "number of frames for " + JSON.stringify(frames));
});
}, "a KeyframeEffectReadOnly can be constructed with no frames");
// [specified easing value, expected easing value]
var gEasingValueTests = [
["unrecognised", "linear"],
["linear", "linear"],
["ease-in-out", "ease-in-out"],
["initial", "linear"],
["inherit", "linear"],
["var(--x)", "linear"],
["ease-in-out, ease-out", "linear"],
["Ease\\2d in-out", "ease-in-out"],
["ease /**/", "ease"],
];
test(function(t) {
gEasingValueTests.forEach(function(subtest) {
var easing = subtest[0];
var expected = subtest[1];
var effect = new KeyframeEffectReadOnly(target, {
left: ["10px", "20px"],
easing: easing
});
assert_equals(effect.getFrames()[0].easing, expected,
"resulting easing for '" + easing + "'");
});
}, "easing values are parsed correctly when passed to the " +
"KeyframeEffectReadOnly constructor in PropertyIndexedKeyframes");
test(function(t) {
gEasingValueTests.forEach(function(subtest) {
var easing = subtest[0];
var expected = subtest[1];
var effect = new KeyframeEffectReadOnly(target, [
{ offset: 0, left: "10px", easing: easing },
{ offset: 1, left: "20px" }
]);
assert_equals(effect.getFrames()[0].easing, expected,
"resulting easing for '" + easing + "'");
});
}, "easing values are parsed correctly when passed to the " +
"KeyframeEffectReadOnly constructor in Keyframe");
test(function(t) {
gEasingValueTests.forEach(function(subtest) {
var easing = subtest[0];
var expected = subtest[1];
var effect = new KeyframeEffectReadOnly(target, {
left: ["10px", "20px"]
}, { easing: easing });
assert_equals(effect.getFrames()[0].easing, expected,
"resulting easing for '" + easing + "'");
});
}, "easing values are parsed correctly when passed to the " +
"KeyframeEffectReadOnly constructor in KeyframeTimingOptions");
var gGoodCompositeValueTests = [
"replace", "add", "accumulate"
];
var gBadCompositeValueTests = [
"unrecognised", "replace ", "Replace"
];
test(function(t) {
gGoodCompositeValueTests.forEach(function(composite) {
var effect = new KeyframeEffectReadOnly(target, {
left: ["10px", "20px"],
composite: composite
});
assert_equals(effect.getFrames()[0].composite, composite,
"resulting composite for '" + composite + "'");
});
gBadCompositeValueTests.forEach(function(composite) {
assert_throws(new TypeError, function() {
new KeyframeEffectReadOnly(target, {
left: ["10px", "20px"],
composite: composite
});
});
});
}, "composite values are parsed correctly when passed to the " +
"KeyframeEffectReadOnly constructor in PropertyIndexedKeyframes");
test(function(t) {
gGoodCompositeValueTests.forEach(function(composite) {
var effect = new KeyframeEffectReadOnly(target, [
{ offset: 0, left: "10px", composite: composite },
{ offset: 1, left: "20px" }
]);
assert_equals(effect.getFrames()[0].composite, composite,
"resulting composite for '" + composite + "'");
});
gBadCompositeValueTests.forEach(function(composite) {
assert_throws(new TypeError, function() {
new KeyframeEffectReadOnly(target, [
{ offset: 0, left: "10px", composite: composite },
{ offset: 1, left: "20px" }
]);
});
});
}, "composite values are parsed correctly when passed to the " +
"KeyframeEffectReadOnly constructor in Keyframe");
test(function(t) {
gGoodCompositeValueTests.forEach(function(composite) {
var effect = new KeyframeEffectReadOnly(target, {
left: ["10px", "20px"]
}, { composite: composite });
assert_equals(effect.getFrames()[0].composite, composite,
"resulting composite for '" + composite + "'");
});
gBadCompositeValueTests.forEach(function(composite) {
assert_throws(new TypeError, function() {
new KeyframeEffectReadOnly(target, {
left: ["10px", "20px"]
}, { composite: composite });
});
});
}, "composite values are parsed correctly when passed to the " +
"KeyframeEffectReadOnly constructor in KeyframeTimingOptions");
var gPropertyIndexedKeyframesTests = [
{ desc: "a one property two value PropertyIndexedKeyframes specification",
input: { left: ["10px", "20px"] },
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", left: "10px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", left: "20px" }] },
{ desc: "a one shorthand property two value PropertyIndexedKeyframes specification",
input: { margin: ["10px", "10px 20px 30px 40px"] },
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", marginTop: "10px", marginRight: "10px", marginBottom: "10px", marginLeft: "10px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", marginTop: "10px", marginRight: "20px", marginBottom: "30px", marginLeft: "40px" }] },
{ desc: "a two property (one shorthand and one of its longhand components) two value PropertyIndexedKeyframes specification",
input: { marginTop: ["50px", "60px"],
margin: ["10px", "10px 20px 30px 40px"] },
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", marginTop: "50px", marginRight: "10px", marginBottom: "10px", marginLeft: "10px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", marginTop: "60px", marginRight: "20px", marginBottom: "30px", marginLeft: "40px" }] },
{ desc: "a two property two value PropertyIndexedKeyframes specification",
input: { left: ["10px", "20px"],
top: ["30px", "40px"] },
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", left: "10px", top: "30px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", left: "20px", top: "40px" }] },
{ desc: "a two property PropertyIndexedKeyframes specification with different numbers of values",
input: { left: ["10px", "20px", "30px"],
top: ["40px", "50px"] },
output: [{ offset: 0.0, computedOffset: 0.0, easing: "linear", composite: "replace", left: "10px", top: "40px" },
{ offset: 0.5, computedOffset: 0.5, easing: "linear", composite: "replace", left: "20px" },
{ offset: 1.0, computedOffset: 1.0, easing: "linear", composite: "replace", left: "30px", top: "50px" }] },
{ desc: "a PropertyIndexedKeyframes specification with an invalid value",
input: { left: ["10px", "20px", "30px", "40px", "50px"],
top: ["15px", "25px", "invalid", "45px", "55px"] },
output: [{ offset: 0.00, computedOffset: 0.00, easing: "linear", composite: "replace", left: "10px", top: "15px" },
{ offset: 0.25, computedOffset: 0.25, easing: "linear", composite: "replace", left: "20px", top: "25px" },
{ offset: 0.50, computedOffset: 0.50, easing: "linear", composite: "replace", left: "30px" },
{ offset: 0.75, computedOffset: 0.75, easing: "linear", composite: "replace", left: "40px", top: "45px" },
{ offset: 1.00, computedOffset: 1.00, easing: "linear", composite: "replace", left: "50px", top: "55px" }] },
{ desc: "a one property two value PropertyIndexedKeyframes specification that needs to stringify its values",
input: { opacity: [0, 1] },
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", opacity: "0" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", opacity: "1" }] },
{ desc: "a one property one value PropertyIndexedKeyframes specification",
input: { left: ["10px"] },
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", left: "10px" }] },
{ desc: "a one property one non-array value PropertyIndexedKeyframes specification",
input: { left: "10px" },
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", left: "10px" }] },
{ desc: "a one property two value PropertyIndexedKeyframes specification where the first value is invalid",
input: { left: ["invalid", "10px"] },
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", left: "10px" }] },
{ desc: "a one property two value PropertyIndexedKeyframes specification where the second value is invalid",
input: { left: ["10px", "invalid"] },
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", left: "10px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace" }] },
{ desc: "a two property PropertyIndexedKeyframes specification where one property is missing from the first Keyframe",
input: [{ offset: 0, left: "10px" },
{ offset: 1, left: "20px", top: "30px" }],
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", left: "10px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", left: "20px", top: "30px" }] },
{ desc: "a two property PropertyIndexedKeyframes specification where one property is missing from the last Keyframe",
input: [{ offset: 0, left: "10px", top: "20px" },
{ offset: 1, left: "30px" }],
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", left: "10px" , top: "20px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", left: "30px" }] },
{ desc: "a PropertyIndexedKeyframes specification with repeated values at offset 0 with different easings",
input: [{ offset: 0.0, left: "100px", easing: "ease" },
{ offset: 0.0, left: "200px", easing: "ease" },
{ offset: 0.5, left: "300px", easing: "linear" },
{ offset: 1.0, left: "400px", easing: "ease-out" },
{ offset: 1.0, left: "500px", easing: "step-end" }],
output: [{ offset: 0.0, computedOffset: 0.0, easing: "ease", composite: "replace", left: "100px" },
{ offset: 0.0, computedOffset: 0.0, easing: "ease", composite: "replace", left: "200px" },
{ offset: 0.5, computedOffset: 0.5, easing: "linear", composite: "replace", left: "300px" },
{ offset: 1.0, computedOffset: 1.0, easing: "ease-out", composite: "replace", left: "400px" },
{ offset: 1.0, computedOffset: 1.0, easing: "linear", composite: "replace", left: "500px" }] },
];
gPropertyIndexedKeyframesTests.forEach(function(subtest) {
test(function(t) {
var effect = new KeyframeEffectReadOnly(target, subtest.input);
assert_frame_lists_equal(effect.getFrames(), subtest.output);
}, "a KeyframeEffectReadOnly can be constructed with " + subtest.desc);
test(function(t) {
var effect = new KeyframeEffectReadOnly(target, subtest.input);
var secondEffect = new KeyframeEffectReadOnly(target, effect.getFrames());
assert_frame_lists_equal(secondEffect.getFrames(), effect.getFrames());
}, "a KeyframeEffectReadOnly constructed with " + subtest.desc +
" roundtrips");
});
test(function(t) {
var expectedOrder = ["composite", "easing", "offset", "left", "marginLeft"];
var actualOrder = [];
var kf1 = {};
var kf2 = { marginLeft: "10px", left: "20px", offset: 1 };
[{ p: "marginLeft", v: "10px" },
{ p: "left", v: "20px" },
{ p: "offset", v: "0" },
{ p: "easing", v: "linear" },
{ p: "composite", v: null }].forEach(function(e) {
Object.defineProperty(kf1, e.p, {
enumerable: true,
get: function() { actualOrder.push(e.p); return e.v; }
});
});
new KeyframeEffectReadOnly(target, [kf1, kf2]);
assert_array_equals(actualOrder, expectedOrder, "property access order");
}, "the KeyframeEffectReadOnly constructor reads Keyframe properties in the " +
"expected order");
var gKeyframeSequenceTests = [
{ desc: "a one property two Keyframe sequence",
input: [{ offset: 0, left: "10px" },
{ offset: 1, left: "20px" }],
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", left: "10px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", left: "20px" }] },
{ desc: "a two property two Keyframe sequence",
input: [{ offset: 0, left: "10px", top: "30px" },
{ offset: 1, left: "20px", top: "40px" }],
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", left: "10px", top: "30px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", left: "20px", top: "40px" }] },
{ desc: "a one shorthand property two Keyframe sequence",
input: [{ offset: 0, margin: "10px" },
{ offset: 1, margin: "20px 30px 40px 50px" }],
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", marginTop: "10px", marginRight: "10px", marginBottom: "10px", marginLeft: "10px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", marginTop: "20px", marginRight: "30px", marginBottom: "40px", marginLeft: "50px" }] },
{ desc: "a two property (a shorthand and one of its component longhands) two Keyframe sequence",
input: [{ offset: 0, margin: "10px", marginTop: "20px" },
{ offset: 1, marginTop: "70px", margin: "30px 40px 50px 60px" }],
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", marginTop: "20px", marginRight: "10px", marginBottom: "10px", marginLeft: "10px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", marginTop: "70px", marginRight: "40px", marginBottom: "50px", marginLeft: "60px" }] },
{ desc: "a Keyframe sequence with duplicate values for a given interior offset",
input: [{ offset: 0.0, left: "10px" },
{ offset: 0.5, left: "20px" },
{ offset: 0.5, left: "30px" },
{ offset: 0.5, left: "40px" },
{ offset: 1.0, left: "50px" }],
output: [{ offset: 0.0, computedOffset: 0.0, easing: "linear", composite: "replace", left: "10px" },
{ offset: 0.5, computedOffset: 0.5, easing: "linear", composite: "replace", left: "20px" },
{ offset: 0.5, computedOffset: 0.5, easing: "linear", composite: "replace", left: "40px" },
{ offset: 1.0, computedOffset: 1.0, easing: "linear", composite: "replace", left: "50px" }] },
{ desc: "a Keyframe sequence with duplicate values for offsets 0 and 1",
input: [{ offset: 0, left: "10px" },
{ offset: 0, left: "20px" },
{ offset: 0, left: "30px" },
{ offset: 1, left: "40px" },
{ offset: 1, left: "50px" },
{ offset: 1, left: "60px" }],
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", left: "10px" },
{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", left: "30px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", left: "40px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", left: "60px" }] },
{ desc: "a two property four Keyframe sequence",
input: [{ offset: 0, left: "10px" },
{ offset: 0, top: "20px" },
{ offset: 1, top: "30px" },
{ offset: 1, left: "40px" }],
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", left: "10px", top: "20px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", left: "40px", top: "30px" }] },
{ desc: "a one property Keyframe sequence with some omitted offsets",
input: [{ offset: 0.00, left: "10px" },
{ offset: 0.25, left: "20px" },
{ left: "30px" },
{ left: "40px" },
{ offset: 1.00, left: "50px" }],
output: [{ offset: 0.00, computedOffset: 0.00, easing: "linear", composite: "replace", left: "10px" },
{ offset: 0.25, computedOffset: 0.25, easing: "linear", composite: "replace", left: "20px" },
{ offset: 0.50, computedOffset: 0.50, easing: "linear", composite: "replace", left: "30px" },
{ offset: 0.75, computedOffset: 0.75, easing: "linear", composite: "replace", left: "40px" },
{ offset: 1.00, computedOffset: 1.00, easing: "linear", composite: "replace", left: "50px" }] },
{ desc: "a two property Keyframe sequence with some omitted offsets",
input: [{ offset: 0.00, left: "10px", top: "20px" },
{ offset: 0.25, left: "30px" },
{ left: "40px" },
{ left: "50px", top: "60px" },
{ offset: 1.00, left: "70px", top: "80px" }],
output: [{ offset: 0.00, computedOffset: 0.00, easing: "linear", composite: "replace", left: "10px", top: "20px" },
{ offset: 0.25, computedOffset: 0.25, easing: "linear", composite: "replace", left: "30px" },
{ offset: 0.50, computedOffset: 0.50, easing: "linear", composite: "replace", left: "40px" },
{ offset: 0.75, computedOffset: 0.75, easing: "linear", composite: "replace", left: "50px", top: "60px" },
{ offset: 1.00, computedOffset: 1.00, easing: "linear", composite: "replace", left: "70px", top: "80px" }] },
{ desc: "a one property Keyframe sequence with all omitted offsets",
input: [{ left: "10px" },
{ left: "20px" },
{ left: "30px" },
{ left: "40px" },
{ left: "50px" }],
output: [{ offset: 0.00, computedOffset: 0.00, easing: "linear", composite: "replace", left: "10px" },
{ offset: 0.25, computedOffset: 0.25, easing: "linear", composite: "replace", left: "20px" },
{ offset: 0.50, computedOffset: 0.50, easing: "linear", composite: "replace", left: "30px" },
{ offset: 0.75, computedOffset: 0.75, easing: "linear", composite: "replace", left: "40px" },
{ offset: 1.00, computedOffset: 1.00, easing: "linear", composite: "replace", left: "50px" }] },
{ desc: "a Keyframe sequence with different easing values, but the same easing value for a given offset",
input: [{ offset: 0.0, easing: "ease", left: "10px"},
{ offset: 0.0, easing: "ease", top: "20px"},
{ offset: 0.5, easing: "linear", left: "30px" },
{ offset: 0.5, easing: "linear", top: "40px" },
{ offset: 1.0, easing: "step-end", left: "50px" },
{ offset: 1.0, easing: "step-end", top: "60px" }],
output: [{ offset: 0.0, computedOffset: 0.0, easing: "ease", composite: "replace", left: "10px", top: "20px" },
{ offset: 0.5, computedOffset: 0.5, easing: "linear", composite: "replace", left: "30px", top: "40px" },
{ offset: 1.0, computedOffset: 1.0, easing: "linear", composite: "replace", left: "50px", top: "60px" }] },
{ desc: "a Keyframe sequence with different composite values, but the same composite value for a given offset",
input: [{ offset: 0.0, composite: "replace", left: "10px" },
{ offset: 0.0, composite: "replace", top: "20px" },
{ offset: 0.5, composite: "add", left: "30px" },
{ offset: 0.5, composite: "add", top: "40px" },
{ offset: 1.0, composite: "replace", left: "50px" },
{ offset: 1.0, composite: "replace", top: "60px" }],
output: [{ offset: 0.0, computedOffset: 0.0, easing: "linear", composite: "replace", left: "10px", top: "20px" },
{ offset: 0.5, computedOffset: 0.5, easing: "linear", composite: "add", left: "30px", top: "40px" },
{ offset: 1.0, computedOffset: 1.0, easing: "linear", composite: "replace", left: "50px", top: "60px" }] },
{ desc: "a one property two Keyframe sequence that needs to stringify its values",
input: [{ offset: 0, opacity: 0 },
{ offset: 1, opacity: 1 }],
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", opacity: "0" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", opacity: "1" }] },
{ desc: "a Keyframe sequence where shorthand precedes longhand",
input: [{ offset: 0, margin: "10px", marginRight: "20px" },
{ offset: 1, margin: "30px" }],
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", marginBottom: "10px", marginLeft: "10px", marginRight: "20px", marginTop: "10px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", marginBottom: "30px", marginLeft: "30px", marginRight: "30px", marginTop: "30px" }] },
{ desc: "a Keyframe sequence where longhand precedes shorthand",
input: [{ offset: 0, marginRight: "20px", margin: "10px" },
{ offset: 1, margin: "30px" }],
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace", marginBottom: "10px", marginLeft: "10px", marginRight: "20px", marginTop: "10px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace", marginBottom: "30px", marginLeft: "30px", marginRight: "30px", marginTop: "30px" }] },
{ desc: "a Keyframe sequence where lesser shorthand precedes greater shorthand",
input: [{ offset: 0, borderLeft: "1px solid rgb(1, 2, 3)", border: "2px dotted rgb(4, 5, 6)" },
{ offset: 1, border: "3px dashed rgb(7, 8, 9)" }],
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace",
borderBottomColor: "rgb(4, 5, 6)", borderBottomWidth: "2px",
borderLeftColor: "rgb(1, 2, 3)", borderLeftWidth: "1px",
borderRightColor: "rgb(4, 5, 6)", borderRightWidth: "2px",
borderTopColor: "rgb(4, 5, 6)", borderTopWidth: "2px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace",
borderBottomColor: "rgb(7, 8, 9)", borderBottomWidth: "3px",
borderLeftColor: "rgb(7, 8, 9)", borderLeftWidth: "3px",
borderRightColor: "rgb(7, 8, 9)", borderRightWidth: "3px",
borderTopColor: "rgb(7, 8, 9)", borderTopWidth: "3px" }] },
{ desc: "a Keyframe sequence where greater shorthand precedes lesser shorthand",
input: [{ offset: 0, border: "2px dotted rgb(4, 5, 6)", borderLeft: "1px solid rgb(1, 2, 3)" },
{ offset: 1, border: "3px dashed rgb(7, 8, 9)" }],
output: [{ offset: 0, computedOffset: 0, easing: "linear", composite: "replace",
borderBottomColor: "rgb(4, 5, 6)", borderBottomWidth: "2px",
borderLeftColor: "rgb(1, 2, 3)", borderLeftWidth: "1px",
borderRightColor: "rgb(4, 5, 6)", borderRightWidth: "2px",
borderTopColor: "rgb(4, 5, 6)", borderTopWidth: "2px" },
{ offset: 1, computedOffset: 1, easing: "linear", composite: "replace",
borderBottomColor: "rgb(7, 8, 9)", borderBottomWidth: "3px",
borderLeftColor: "rgb(7, 8, 9)", borderLeftWidth: "3px",
borderRightColor: "rgb(7, 8, 9)", borderRightWidth: "3px",
borderTopColor: "rgb(7, 8, 9)", borderTopWidth: "3px" }] },
];
gKeyframeSequenceTests.forEach(function(subtest) {
test(function(t) {
var effect = new KeyframeEffectReadOnly(target, subtest.input);
assert_frame_lists_equal(effect.getFrames(), subtest.output);
}, "a KeyframeEffectReadOnly can be constructed with " + subtest.desc);
test(function(t) {
var effect = new KeyframeEffectReadOnly(target, subtest.input);
var secondEffect = new KeyframeEffectReadOnly(target, effect.getFrames());
assert_frame_lists_equal(secondEffect.getFrames(), effect.getFrames());
}, "a KeyframeEffectReadOnly constructed with " + subtest.desc +
" roundtrips");
});
done();
</script>
</body>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>Test the return value of connect when connecting two AudioNodes</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function(t) {
var context = new OfflineAudioContext(1, 1, 44100);
var g1 = context.createGain();
var g2 = context.createGain();
var rv = g1.connect(g2);
assert_equals(rv, g2);
var rv = g1.connect(g2);
assert_equals(rv, g2);
}, "connect should return the node connected to.");
</script>

View file

@ -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()

View file

@ -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>

View file

@ -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>

View file

@ -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()

View file

@ -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()

View file

@ -66,6 +66,42 @@ class GetElementAttributeTest(base_test.WebDriverBaseTest):
el = self.driver.find_element_by_css_selector("div") el = self.driver.find_element_by_css_selector("div")
self.assertIsNone(el.get_attribute("class")) 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__": if __name__ == "__main__":
unittest.main() unittest.main()

View file

@ -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>

View file

@ -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>

View file

@ -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()

View 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

View file

@ -0,0 +1,8 @@
<html>
<head>
<meta charset="utf-8" />
<title>Text Form Landing</title>
</head>
<body>
</body>
</html>

View file

@ -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>

View file

@ -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()

View file

@ -14,9 +14,14 @@ async_test(function(t) {
ws.close(); ws.close();
ws.close(); ws.close();
ws.close(); ws.close();
setTimeout(t.step_func(function() { var f = t.step_func(function() {
if (i < 1) {
setTimeout(f, 500);
return;
}
assert_equals(i, 1); assert_equals(i, 1);
t.done() t.done()
}), 50); });
setTimeout(f, 500);
}); });
</script> </script>

View file

@ -33,6 +33,20 @@ function countStorageEvents(callback, expectedNumEvents, times)
setTimeout(onTimeout, 20); setTimeout(onTimeout, 20);
} }
function clearStorage(storageName, callback)
{
if (window[storageName].length === 0) {
storageEventList = [];
setTimeout(callback, 0);
} else {
window[storageName].clear();
runAfterNStorageEvents(function() {
storageEventList = [];
callback();
}, 1);
}
}
function testStorages(testCallback) function testStorages(testCallback)
{ {
testCallback("sessionStorage"); testCallback("sessionStorage");

View file

@ -4,15 +4,11 @@ testStorages(function(storageString) {
var storage = window[storageString]; var storage = window[storageString];
t.add_cleanup(function() { storage.clear() }); t.add_cleanup(function() { storage.clear() });
storageEventList = new Array(); clearStorage(storageString, t.step_func(step1));
storage.clear();
assert_equals(storage.length, 0, "storage.length"); assert_equals(storage.length, 0, "storage.length");
runAfterNStorageEvents(t.step_func(step1), 0);
function step1(msg) function step1(msg)
{ {
storageEventList = new Array();
storage.setItem('FOO', 'BAR'); storage.setItem('FOO', 'BAR');
runAfterNStorageEvents(t.step_func(step2), 1); runAfterNStorageEvents(t.step_func(step2), 1);

View file

@ -4,11 +4,14 @@ testStorages(function(storageString) {
var storage = window[storageString]; var storage = window[storageString];
t.add_cleanup(function() { storage.clear() }); t.add_cleanup(function() { storage.clear() });
storage.clear(); clearStorage(storageString, t.step_func(step0));
assert_equals(storage.length, 0, "storage.length"); assert_equals(storage.length, 0, "storage.length");
function step0(msg)
{
iframe.onload = t.step_func(step1); iframe.onload = t.step_func(step1);
iframe.src = "resources/event_body_handler.html"; iframe.src = "resources/event_body_handler.html";
}
function step1(msg) function step1(msg)
{ {

View file

@ -4,11 +4,14 @@ testStorages(function(storageString) {
var storage = window[storageString]; var storage = window[storageString];
t.add_cleanup(function() { storage.clear() }); t.add_cleanup(function() { storage.clear() });
storage.clear(); clearStorage(storageString, t.step_func(step0));
assert_equals(storage.length, 0, "storage.length"); assert_equals(storage.length, 0, "storage.length");
storage.foo = "test";
function step0(msg)
{
storage.foo = "test";
runAfterNStorageEvents(t.step_func(step1), 1); runAfterNStorageEvents(t.step_func(step1), 1);
}
function step1(msg) function step1(msg)
{ {

View file

@ -9,21 +9,18 @@
<h1>event_Constructor</h1> <h1>event_Constructor</h1>
<div id="log"></div> <div id="log"></div>
<script> <script>
test(function() { async_test(function(t) {
var t = async_test("StorageEvent constructor and nulls");
function onStorageEvent(event) { function onStorageEvent(event) {
t.step(function() {
assert_equals(event.type, 'storage', 'type'); assert_equals(event.type, 'storage', 'type');
assert_equals(event.key, null, 'key'); assert_equals(event.key, null, 'key');
assert_equals(event.oldValue, null, 'oldValue'); assert_equals(event.oldValue, null, 'oldValue');
assert_equals(event.newValue, null, 'newValue'); assert_equals(event.newValue, null, 'newValue');
assert_equals(event.url, 'null', 'url'); assert_equals(event.url, 'null', 'url');
assert_equals(event.storageArea, null, 'storageArea'); assert_equals(event.storageArea, null, 'storageArea');
});
t.done(); t.done();
} }
window.addEventListener('storage', onStorageEvent, false); window.addEventListener('storage', t.step_func(onStorageEvent), false);
var event = new StorageEvent('storage', { var event = new StorageEvent('storage', {
key: null, key: null,
oldValue: null, oldValue: null,
@ -31,7 +28,7 @@
url: null url: null
}); });
window.dispatchEvent(event); window.dispatchEvent(event);
}, "Construct StorageEvent with StorageEventInit."); }, "StorageEvent constructor and nulls - Construct StorageEvent with StorageEventInit.");
</script> </script>
</body> </body>
</html> </html>

View file

@ -4,40 +4,35 @@
<title>WebStorage Test: localStorage event - key</title> <title>WebStorage Test: localStorage event - key</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_unreached(msg);
});
t.done();
}
</script>
</head> </head>
<body> <body>
<h1>event_local_key</h1> <h1>event_local_key</h1>
<div id="log"></div> <div id="log"></div>
<script> <script>
var t = async_test("key property test of local event"); async_test(function(t) {
test(function() {
localStorage.clear(); localStorage.clear();
t.add_cleanup(function() { localStorage.clear() });
self.fail = t.step_func(function(msg) {
assert_unreached(msg);
t.done();
});
var expected = ['name', null] var expected = ['name', null]
function onStorageEvent(event) { function onStorageEvent(event) {
t.step(function() {
assert_equals(event.key, expected.shift()); assert_equals(event.key, expected.shift());
});
if (!expected.length) { if (!expected.length) {
t.done(); t.done();
} }
} }
window.addEventListener('storage', onStorageEvent, false); window.addEventListener('storage', t.step_func(onStorageEvent), false);
var el = document.createElement("iframe"); var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm'); el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'resources/local_set_item_clear_iframe.html'); el.setAttribute('src', 'resources/local_set_item_clear_iframe.html');
document.body.appendChild(el); document.body.appendChild(el);
}, "Local event is fired due to an invocation of the setItem(), clear() methods."); }, "key property test of local event - Local event is fired due to an invocation of the setItem(), clear() methods.");
</script> </script>
</body> </body>
</html> </html>

View file

@ -4,40 +4,35 @@
<title>WebStorage Test: localStorage event - newValue</title> <title>WebStorage Test: localStorage event - newValue</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_unreached(msg);
});
t.done();
}
</script>
</head> </head>
<body> <body>
<h1>event_local_newValue</h1> <h1>event_local_newValue</h1>
<div id="log"></div> <div id="log"></div>
<script> <script>
var t = async_test("newValue property test of local event"); async_test(function(t) {
test(function() {
localStorage.clear(); localStorage.clear();
t.add_cleanup(function() { localStorage.clear() });
self.fail = t.step_func(function(msg) {
assert_unreached(msg);
t.done();
});
var expected = ['user1', 'user2', null] var expected = ['user1', 'user2', null]
function onStorageEvent(event) { function onStorageEvent(event) {
t.step(function() {
assert_equals(event.newValue, expected.shift()); assert_equals(event.newValue, expected.shift());
});
if (!expected.length) { if (!expected.length) {
t.done(); t.done();
} }
} }
window.addEventListener('storage', onStorageEvent, false); window.addEventListener('storage', t.step_func(onStorageEvent), false);
var el = document.createElement("iframe"); var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm'); el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'resources/local_change_item_iframe.html'); el.setAttribute('src', 'resources/local_change_item_iframe.html');
document.body.appendChild(el); document.body.appendChild(el);
}, "Local event is fired due to an invocation of the setItem(), clear() methods."); }, "newValue property test of local event - Local event is fired due to an invocation of the setItem(), clear() methods.");
</script> </script>
</body> </body>
</html> </html>

View file

@ -4,40 +4,35 @@
<title>WebStorage Test: localStorage event - oldValue</title> <title>WebStorage Test: localStorage event - oldValue</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_unreached(msg);
});
t.done();
}
</script>
</head> </head>
<body> <body>
<h1>event_local_oldValue</h1> <h1>event_local_oldValue</h1>
<div id="log"></div> <div id="log"></div>
<script> <script>
var t = async_test("oldValue property test of local event"); async_test(function(t) {
test(function() {
localStorage.clear(); localStorage.clear();
t.add_cleanup(function() { localStorage.clear() });
self.fail = t.step_func(function(msg) {
assert_unreached(msg);
t.done();
});
var expected = [null, 'user1', null] var expected = [null, 'user1', null]
function onStorageEvent(event) { function onStorageEvent(event) {
t.step(function() {
assert_equals(event.oldValue, expected.shift()); assert_equals(event.oldValue, expected.shift());
});
if (!expected.length) { if (!expected.length) {
t.done(); t.done();
} }
} }
window.addEventListener('storage', onStorageEvent, false); window.addEventListener('storage', t.step_func(onStorageEvent), false);
var el = document.createElement("iframe"); var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm'); el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'resources/local_change_item_iframe.html'); el.setAttribute('src', 'resources/local_change_item_iframe.html');
document.body.appendChild(el); document.body.appendChild(el);
}, "Local event is fired due to an invocation of the setItem(), clear() methods."); }, "oldValue property test of local event - Local event is fired due to an invocation of the setItem(), clear() methods.");
</script> </script>
</body> </body>
</html> </html>

View file

@ -9,10 +9,11 @@
<script> <script>
var t = async_test("key property test of local event"); async_test(function(t) {
t.step(function() {
localStorage.clear(); localStorage.clear();
t.add_cleanup(function() { localStorage.clear() });
self.step = function(f) { t.step(f); };
var event_index = 0; var event_index = 0;
window.addEventListener('storage', t.step_func(function(event) { window.addEventListener('storage', t.step_func(function(event) {
@ -39,6 +40,6 @@ t.step(function() {
el.setAttribute('id', 'ifrm'); el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'resources/local_set_item_remove_iframe.html'); el.setAttribute('src', 'resources/local_set_item_remove_iframe.html');
document.body.appendChild(el); document.body.appendChild(el);
}); }, "key property test of local event");
</script> </script>

View file

@ -4,41 +4,36 @@
<title>WebStorage Test: localStorage event - storageArea</title> <title>WebStorage Test: localStorage event - storageArea</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_unreached(msg);
});
t.done();
}
</script>
</head> </head>
<body> <body>
<h1>event_local_storageArea</h1> <h1>event_local_storageArea</h1>
<div id="log"></div> <div id="log"></div>
<script> <script>
var t = async_test("storageArea property test of local event"); async_test(function(t) {
test(function() {
localStorage.clear(); localStorage.clear();
t.add_cleanup(function() { localStorage.clear() });
self.fail = t.step_func(function(msg) {
assert_unreached(msg);
t.done();
});
function onStorageEvent(event) { function onStorageEvent(event) {
t.step(function() {
assert_equals(event.storageArea.length, 1); assert_equals(event.storageArea.length, 1);
var key = event.storageArea.key(0); var key = event.storageArea.key(0);
var value = event.storageArea.getItem(key); var value = event.storageArea.getItem(key);
assert_equals(key, "name"); assert_equals(key, "name");
assert_equals(value, "user1"); assert_equals(value, "user1");
});
t.done(); t.done();
} }
window.addEventListener('storage', onStorageEvent, false); window.addEventListener('storage', t.step_func(onStorageEvent), false);
var el = document.createElement("iframe"); var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm'); el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'resources/local_set_item_iframe.html'); el.setAttribute('src', 'resources/local_set_item_iframe.html');
document.body.appendChild(el); document.body.appendChild(el);
}, "Local event is fired due to an invocation of the setItem() method."); }, "storageArea property test of local event - Local event is fired due to an invocation of the setItem() method.");
</script> </script>
</body> </body>
</html> </html>

View file

@ -9,20 +9,18 @@
<h1>event_local_StorageEventInit</h1> <h1>event_local_StorageEventInit</h1>
<div id="log"></div> <div id="log"></div>
<script> <script>
test(function() { async_test(function(t) {
var t = async_test("storageeventinit test");
function onStorageEvent(event) { function onStorageEvent(event) {
t.step(function() {
assert_equals(event.key, 'key'); assert_equals(event.key, 'key');
assert_equals(event.oldValue, 'oldValue'); assert_equals(event.oldValue, 'oldValue');
assert_equals(event.newValue, 'newValue'); assert_equals(event.newValue, 'newValue');
assert_equals(event.url, window.location.href); assert_equals(event.url, window.location.href);
assert_equals(event.storageArea, window.localStorage); assert_equals(event.storageArea, window.localStorage);
});
t.done(); t.done();
} }
window.addEventListener('storage', onStorageEvent, false); window.addEventListener('storage', t.step_func(onStorageEvent), false);
var event = new StorageEvent('storage', { var event = new StorageEvent('storage', {
key: 'key', key: 'key',
@ -33,7 +31,7 @@
}); });
window.dispatchEvent(event); window.dispatchEvent(event);
}, "Storage event is fired due to set values for StorageEventInit."); }, "storageeventinit test - Storage event is fired due to set values for StorageEventInit.");
</script> </script>
</body> </body>
</html> </html>

View file

@ -4,25 +4,21 @@
<title>WebStorage Test: localStorage event - url</title> <title>WebStorage Test: localStorage event - url</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_unreached(msg);
});
t.done();
}
</script>
</head> </head>
<body> <body>
<h1>event_local_url</h1> <h1>event_local_url</h1>
<div id="log"></div> <div id="log"></div>
<script> <script>
var t = async_test("url property test of local event"); async_test(function(t) {
test(function() {
localStorage.clear(); localStorage.clear();
t.add_cleanup(function() { localStorage.clear() });
self.fail = t.step_func(function(msg) {
assert_unreached(msg);
t.done();
});
function onStorageEvent(event) { function onStorageEvent(event) {
t.step(function() {
var url = window.location.href; var url = window.location.href;
var pos = url.lastIndexOf("/"); var pos = url.lastIndexOf("/");
@ -32,17 +28,16 @@
} }
assert_equals(event.url, url); assert_equals(event.url, url);
});
t.done(); t.done();
} }
window.addEventListener('storage', onStorageEvent, false); window.addEventListener('storage', t.step_func(onStorageEvent), false);
var el = document.createElement("iframe"); var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm'); el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'resources/local_set_item_iframe.html'); el.setAttribute('src', 'resources/local_set_item_iframe.html');
document.body.appendChild(el); document.body.appendChild(el);
}, "Local event is fired due to an invocation of the setItem() method."); }, "url property test of local event - Local event is fired due to an invocation of the setItem() method.");
</script> </script>
</body> </body>
</html> </html>

View file

@ -4,40 +4,35 @@
<title>WebStorage Test: sessionStorage event - key</title> <title>WebStorage Test: sessionStorage event - key</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_unreached(msg);
});
t.done();
}
</script>
</head> </head>
<body> <body>
<h1>event_session_key</h1> <h1>event_session_key</h1>
<div id="log"></div> <div id="log"></div>
<script> <script>
var t = async_test("key property test of session event"); async_test(function(t) {
test(function() {
sessionStorage.clear(); sessionStorage.clear();
t.add_cleanup(function() { sessionStorage.clear() });
self.fail = t.step_func(function(msg) {
assert_unreached(msg);
t.done();
});
var expected = ['name', null] var expected = ['name', null]
function onStorageEvent(event) { function onStorageEvent(event) {
t.step(function() {
assert_equals(event.key, expected.shift()); assert_equals(event.key, expected.shift());
});
if (!expected.length) { if (!expected.length) {
t.done(); t.done();
} }
} }
window.addEventListener('storage', onStorageEvent, false); window.addEventListener('storage', t.step_func(onStorageEvent), false);
var el = document.createElement("iframe"); var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm'); el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'resources/session_set_item_clear_iframe.html'); el.setAttribute('src', 'resources/session_set_item_clear_iframe.html');
document.body.appendChild(el); document.body.appendChild(el);
}, "Session event is fired due to an invocation of the setItem(), clear() methods."); }, "key property test of session event - Session event is fired due to an invocation of the setItem(), clear() methods.");
</script> </script>
</body> </body>
</html> </html>

View file

@ -4,23 +4,20 @@
<title>WebStorage Test: sessionStorage event - newValue</title> <title>WebStorage Test: sessionStorage event - newValue</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_unreached(msg);
});
t.done();
}
</script>
</head> </head>
<body> <body>
<h1>event_session_newValue</h1> <h1>event_session_newValue</h1>
<div id="log"></div> <div id="log"></div>
<script> <script>
var t = async_test("newvalue property test of session event"); async_test(function(t) {
test(function() {
sessionStorage.clear(); sessionStorage.clear();
t.add_cleanup(function() { sessionStorage.clear() });
self.fail = t.step_func(function(msg) {
assert_unreached(msg);
t.done();
});
var expected = ['user1', 'user2', null] var expected = ['user1', 'user2', null]
function onStorageEvent(event) { function onStorageEvent(event) {
t.step(function() { t.step(function() {
@ -31,13 +28,13 @@
} }
} }
window.addEventListener('storage', onStorageEvent, false); window.addEventListener('storage', t.step_func(onStorageEvent), false);
var el = document.createElement("iframe"); var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm'); el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'resources/session_change_item_iframe.html'); el.setAttribute('src', 'resources/session_change_item_iframe.html');
document.body.appendChild(el); document.body.appendChild(el);
}, "Session event is fired due to an invocation of the setItem(), clear() methods."); }, "newvalue property test of session event - Session event is fired due to an invocation of the setItem(), clear() methods.");
</script> </script>
</body> </body>
</html> </html>

View file

@ -4,40 +4,35 @@
<title>WebStorage Test: sessionStorage event - oldValue</title> <title>WebStorage Test: sessionStorage event - oldValue</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_unreached(msg);
});
t.done();
}
</script>
</head> </head>
<body> <body>
<h1>event_session_oldValue</h1> <h1>event_session_oldValue</h1>
<div id="log"></div> <div id="log"></div>
<script> <script>
var t = async_test("oldvalue property test of session event"); async_test(function(t) {
test(function() {
sessionStorage.clear(); sessionStorage.clear();
t.add_cleanup(function() { sessionStorage.clear() });
self.fail = t.step_func(function(msg) {
assert_unreached(msg);
t.done();
});
var expected = [null, 'user1', null] var expected = [null, 'user1', null]
function onStorageEvent(event) { function onStorageEvent(event) {
t.step(function() {
assert_equals(event.oldValue, expected.shift()); assert_equals(event.oldValue, expected.shift());
});
if (!expected.length) { if (!expected.length) {
t.done(); t.done();
} }
} }
window.addEventListener('storage', onStorageEvent, false); window.addEventListener('storage', t.step_func(onStorageEvent), false);
var el = document.createElement("iframe"); var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm'); el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'resources/session_change_item_iframe.html'); el.setAttribute('src', 'resources/session_change_item_iframe.html');
document.body.appendChild(el); document.body.appendChild(el);
}, "Session event is fired due to an invocation of the setItem(), clear() methods."); }, "oldvalue property test of session event - Session event is fired due to an invocation of the setItem(), clear() methods.");
</script> </script>
</body> </body>
</html> </html>

View file

@ -9,10 +9,11 @@
<script> <script>
var t = async_test("key property test of session event"); async_test(function(t) {
t.step(function() {
sessionStorage.clear(); sessionStorage.clear();
t.add_cleanup(function() { sessionStorage.clear() });
self.step = function(f) { t.step(f); };
var event_index = 0; var event_index = 0;
window.addEventListener('storage', t.step_func(function(event) { window.addEventListener('storage', t.step_func(function(event) {
@ -39,5 +40,5 @@ t.step(function() {
el.setAttribute('id', 'ifrm'); el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'resources/session_set_item_remove_iframe.html'); el.setAttribute('src', 'resources/session_set_item_remove_iframe.html');
document.body.appendChild(el); document.body.appendChild(el);
}); }, "key property test of session event");
</script> </script>

View file

@ -4,40 +4,36 @@
<title>WebStorage Test: sessionStorage event - storageArea</title> <title>WebStorage Test: sessionStorage event - storageArea</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_unreached(msg);
});
t.done();
}
</script>
</head> </head>
<body> <body>
<h1>event_session_storageArea</h1> <h1>event_session_storageArea</h1>
<div id="log"></div> <div id="log"></div>
<script> <script>
var t = async_test("storageArea property test of session event"); async_test(function(t) {
sessionStorage.clear();
t.add_cleanup(function() { sessionStorage.clear() });
self.fail = t.step_func(function(msg) {
assert_unreached(msg);
t.done();
});
test(function() {
function onStorageEvent(event) { function onStorageEvent(event) {
t.step(function() {
assert_equals(event.storageArea.length, 1); assert_equals(event.storageArea.length, 1);
var key = event.storageArea.key(0); var key = event.storageArea.key(0);
var value = event.storageArea.getItem(key); var value = event.storageArea.getItem(key);
assert_equals(key, "name"); assert_equals(key, "name");
assert_equals(value, "user1"); assert_equals(value, "user1");
});
t.done(); t.done();
} }
window.addEventListener('storage', onStorageEvent, false); window.addEventListener('storage', t.step_func(onStorageEvent), false);
var el = document.createElement("iframe"); var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm'); el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'resources/session_set_item_iframe.html'); el.setAttribute('src', 'resources/session_set_item_iframe.html');
document.body.appendChild(el); document.body.appendChild(el);
}, "Session event is fired due to an invocation of the setItem() method."); }, "storageArea property test of session event - session event is fired due to an invocation of the setItem() method.");
</script> </script>
</body> </body>

View file

@ -9,20 +9,17 @@
<h1>event_session_StorageEventInit</h1> <h1>event_session_StorageEventInit</h1>
<div id="log"></div> <div id="log"></div>
<script> <script>
test(function() { async_test(function(t) {
var t = async_test("storageeventinit test");
function onStorageEvent(event) { function onStorageEvent(event) {
t.step(function() {
assert_equals(event.key, 'key'); assert_equals(event.key, 'key');
assert_equals(event.oldValue, 'oldValue'); assert_equals(event.oldValue, 'oldValue');
assert_equals(event.newValue, 'newValue'); assert_equals(event.newValue, 'newValue');
assert_equals(event.url, window.location.href); assert_equals(event.url, window.location.href);
assert_equals(event.storageArea, window.sessionStorage); assert_equals(event.storageArea, window.sessionStorage);
});
t.done(); t.done();
} }
window.addEventListener('storage', onStorageEvent, false); window.addEventListener('storage', t.step_func(onStorageEvent), false);
var event = new StorageEvent('storage', { var event = new StorageEvent('storage', {
key: 'key', key: 'key',
@ -33,7 +30,7 @@
}); });
window.dispatchEvent(event); window.dispatchEvent(event);
}, "Storage event is fired due to set values for StorageEventInit."); }, "storageeventinit test - Storage event is fired due to set values for StorageEventInit.");
</script> </script>
</body> </body>
</html> </html>

View file

@ -4,25 +4,21 @@
<title>WebStorage Test: sessionStorage event - url</title> <title>WebStorage Test: sessionStorage event - url</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_unreached(msg);
});
t.done();
}
</script>
</head> </head>
<body> <body>
<h1>event_session_url</h1> <h1>event_session_url</h1>
<div id="log"></div> <div id="log"></div>
<script> <script>
var t = async_test("url property test of session event"); async_test(function(t) {
test(function() {
sessionStorage.clear(); sessionStorage.clear();
t.add_cleanup(function() { sessionStorage.clear() });
self.fail = t.step_func(function(msg) {
assert_unreached(msg);
t.done();
});
function onStorageEvent(event) { function onStorageEvent(event) {
t.step(function() {
var url = window.location.href; var url = window.location.href;
var pos = url.lastIndexOf("/"); var pos = url.lastIndexOf("/");
@ -32,17 +28,16 @@
} }
assert_equals(event.url, url); assert_equals(event.url, url);
});
t.done(); t.done();
} }
window.addEventListener('storage', onStorageEvent, false); window.addEventListener('storage', t.step_func(onStorageEvent), false);
var el = document.createElement("iframe"); var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm'); el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'resources/session_set_item_iframe.html'); el.setAttribute('src', 'resources/session_set_item_iframe.html');
document.body.appendChild(el); document.body.appendChild(el);
}, "Session event is fired due to an invocation of the setItem() method."); }, "url property test of session event - Session event is fired due to an invocation of the setItem() method.");
</script> </script>
</body> </body>
</html> </html>

View file

@ -4,16 +4,17 @@ testStorages(function(storageString) {
var storage = window[storageString]; var storage = window[storageString];
t.add_cleanup(function() { storage.clear() }); t.add_cleanup(function() { storage.clear() });
storageEventList = new Array(); clearStorage(storageString, t.step_func(step0));
storage.clear();
assert_equals(storage.length, 0, "storage.length"); assert_equals(storage.length, 0, "storage.length");
function step0(msg)
{
iframe.onload = t.step_func(step1); iframe.onload = t.step_func(step1);
iframe.src = "resources/event_setattribute_handler.html"; iframe.src = "resources/event_setattribute_handler.html";
}
function step1(msg) function step1(msg)
{ {
storageEventList = new Array();
storage.setItem('FOO', 'BAR'); storage.setItem('FOO', 'BAR');
runAfterNStorageEvents(t.step_func(step2), 1); runAfterNStorageEvents(t.step_func(step2), 1);

View file

@ -2,7 +2,7 @@
<html> <html>
<body> <body>
<script> <script>
parent.t.step(function() { parent.step(function() {
localStorage.setItem("name", "user1"); localStorage.setItem("name", "user1");
localStorage.removeItem('name'); localStorage.removeItem('name');
}); });

View file

@ -2,7 +2,7 @@
<html> <html>
<body> <body>
<script> <script>
parent.t.step(function() { parent.step(function() {
sessionStorage.setItem("name", "user1"); sessionStorage.setItem("name", "user1");
sessionStorage.removeItem('name'); sessionStorage.removeItem('name');
}); });

View file

@ -4,9 +4,14 @@
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<div id=log></div> <div id=log></div>
<script> <script>
test(function() { async_test(function(t) {
assert_throws("SECURITY_ERR", function() { try {
new Worker("ftp://example.org/support/WorkerBasic.js"); var w = new Worker("ftp://example.org/support/WorkerBasic.js");
w.onerror = t.step_func_done(function(e) {
assert_true(e instanceof ErrorEvent);
}); });
} catch (e) {
t.step_func_done(function(e) { assert_true(true); });
}
}); });
</script> </script>

View file

@ -12,35 +12,54 @@
// not propogate to the window before the tests finish // not propogate to the window before the tests finish
setup({allow_uncaught_exception: true}); setup({allow_uncaught_exception: true});
function testSharedWorkerHelper(t, script) {
try {
var worker = new SharedWorker(script, '');
worker.onerror = t.step_func_done(function(e) {
assert_true(e instanceof ErrorEvent);
});
} catch (e) {
t.step_func_done(function(e) { assert_true(true); });
}
}
test(function() { test(function() {
assert_throws("SecurityError", function() { new SharedWorker('unsupported:', ''); }); assert_throws("SecurityError", function() { new SharedWorker('unsupported:', ''); });
}, "unsupported_scheme"); }, "unsupported_scheme");
async_test(function() { async_test(function() {
var worker = new SharedWorker('data:,onconnect = function(e) { e.ports[0].postMessage(1); }', ''); var worker = new SharedWorker('data:,onconnect = function(e) { e.ports[0].postMessage(1); }', '');
worker.port.onmessage = this.step_func_done(function(e) { worker.port.onmessage = this.step_func_done(function(e) {
assert_equals(e.data, 1); assert_equals(e.data, 1);
}); });
}, "data_url"); }, "data_url");
test(function() {
assert_throws("SecurityError", function() { new SharedWorker('javascript:""', ''); }); async_test(function(t) {
testSharedWorkerHelper(this, 'javascript:""');
}, "javascript_url"); }, "javascript_url");
test(function() {
assert_throws("SecurityError", function() { new SharedWorker('about:blank', ''); }); async_test(function(t) {
testSharedWorkerHelper(this, 'about:blank');
}, "about_blank"); }, "about_blank");
test(function() {
assert_throws("SecurityError", function() { new SharedWorker('http://www.opera.com/', ''); }); async_test(function(t) {
testSharedWorkerHelper(this, 'http://www.opera.com/');
}, "opera_com"); }, "opera_com");
test(function() {
assert_throws("SecurityError", function() { new SharedWorker(location.protocol+'//'+location.hostname+':81/', ''); }); async_test(function(t) {
testSharedWorkerHelper(this, location.protocol+'//'+location.hostname+':81/');
}, "port_81"); }, "port_81");
test(function() {
assert_throws("SecurityError", function() { new SharedWorker('https://'+location.hostname+':80/', ''); }); async_test(function(t) {
testSharedWorkerHelper(this, 'https://'+location.hostname+':80/');
}, "https_port_80"); }, "https_port_80");
test(function() {
assert_throws("SecurityError", function() { new SharedWorker('https://'+location.hostname+':8000/', ''); }); async_test(function(t) {
testSharedWorkerHelper(this, 'https://'+location.hostname+':8000/');
}, "https_port_8000"); }, "https_port_8000");
test(function() {
assert_throws("SecurityError", function() { new SharedWorker('http://'+location.hostname+':8012/', ''); }); async_test(function(t) {
testSharedWorkerHelper(this, 'http://'+location.hostname+':8012/');
}, "http_port_8012"); }, "http_port_8012");
</script> </script>
<!-- <!--

View file

@ -10,6 +10,17 @@
// not propogate to the window before the tests finish // not propogate to the window before the tests finish
setup({allow_uncaught_exception: true}); setup({allow_uncaught_exception: true});
function testSharedWorkerHelper(t, script) {
try {
var worker = new SharedWorker(script, '');
worker.onerror = t.step_func_done(function(e) {
assert_true(e instanceof ErrorEvent);
});
} catch (e) {
t.step_func_done(function(e) { assert_true(true); });
}
}
test(function() { test(function() {
assert_throws("SecurityError", function() { new Worker('unsupported:'); }); assert_throws("SecurityError", function() { new Worker('unsupported:'); });
}, "unsupported_scheme"); }, "unsupported_scheme");
@ -21,31 +32,32 @@ async_test(function() {
}); });
}, "data_url"); }, "data_url");
test(function() { async_test(function(t) {
assert_throws("SecurityError", function() { new Worker('about:blank'); }); testSharedWorkerHelper(t, 'about:blank');
}, "about_blank"); }, "about_blank");
test(function() { async_test(function(t) {
assert_throws("SecurityError", function() { new Worker('http://www.example.invalid/'); }); testSharedWorkerHelper(t, 'http://www.example.invalid/');
}, "example_invalid"); }, "example_invalid");
test(function() { async_test(function(t) {
assert_throws("SecurityError", function() { new Worker(location.protocol+'//'+location.hostname+':81/'); }); testSharedWorkerHelper(t, location.protocol+'//'+location.hostname+':81/');
}, "port_81"); }, "port_81");
test(function() { async_test(function(t) {
assert_throws("SecurityError", function() { new Worker('https://'+location.hostname+':80/'); }); testSharedWorkerHelper(t, 'https://'+location.hostname+':80/');
}, "https_port_80"); }, "https_port_80");
test(function() { async_test(function(t) {
assert_throws("SecurityError", function() { new Worker('https://'+location.hostname+':8000/'); }); testSharedWorkerHelper(t, 'https://'+location.hostname+':8000/');
}, "https_port_8000"); }, "https_port_8000");
test(function() { async_test(function(t) {
assert_throws("SecurityError", function() { new Worker('http://'+location.hostname+':8012/'); }); testSharedWorkerHelper(t, 'http://'+location.hostname+':8012/');
}, "http_post_8012"); }, "http_post_8012");
test(function() { async_test(function(t) {
assert_throws("SecurityError", function() { new Worker('javascript:""'); }); testSharedWorkerHelper(t,'javascript:""');
}, "javascript_url"); }, "javascript_url");
</script> </script>