Skip to content

Commit

Permalink
Merge pull request #6 from w3c/master
Browse files Browse the repository at this point in the history
Catch up to W3C master
  • Loading branch information
engelke authored Jul 6, 2016
2 parents f9542e0 + 4828ce2 commit 9560530
Show file tree
Hide file tree
Showing 2,126 changed files with 32,001 additions and 17,752 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ node_modules
scratch
testharness_runner.html
webdriver/.idea
.vscode/
22 changes: 11 additions & 11 deletions FileAPI/blob/Blob-constructor.html
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,17 @@
desc: "Passing an platform object that supports indexed properties as the blobParts array should work (select)."
});

var t_ports = async_test("Passing a platform array object as the blobParts array should work (MessagePort[]).");
test_blob(function() {
var elm = document.createElement("div");
elm.setAttribute("foo", "bar");
return new Blob(elm.attributes);
}, {
expected: "[object Attr]",
type: "",
desc: "Passing an platform object that supports indexed properties as the blobParts array should work (attributes)."
});

var t_ports = async_test("Passing a FrozenArray as the blobParts array should work (FrozenArray<MessagePort>).");
t_ports.step(function() {
var channel = new MessageChannel();
channel.port2.onmessage = this.step_func(function(e) {
Expand All @@ -342,16 +352,6 @@
channel.port1.postMessage('', [channel2.port1]);
});

test_blob(function() {
var elm = document.createElement("div");
elm.setAttribute("foo", "bar");
return new Blob(elm.attributes);
}, {
expected: "[object Attr]",
type: "",
desc: "Passing a platform array object as the blobParts array should work (Attr[])."
});

test_blob(function() {
var blob = new Blob(['foo']);
return new Blob([blob, blob]);
Expand Down
34 changes: 31 additions & 3 deletions IndexedDB/idbkeyrange-includes.htm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<script src=/resources/testharnessreport.js></script>
<script>

test( function() {
test(function() {
var closedRange = IDBKeyRange.bound(5, 20);
assert_true(!!closedRange.includes, "IDBKeyRange has a .includes");
assert_true(closedRange.includes(7), "in range");
Expand All @@ -17,17 +17,45 @@
"invalid key");
}, "IDBKeyRange.includes() with a closed range");

test( function() {
test(function() {
var openRange = IDBKeyRange.bound(5, 20, true, true);
assert_false(openRange.includes(5) || openRange.includes(20),
"boundary points");
}, "IDBKeyRange.includes() with an open range");

test( function() {
test(function() {
var range = IDBKeyRange.only(42);
assert_true(range.includes(42), "in range");
assert_false(range.includes(1), "below range");
assert_false(range.includes(9000), "above range");
}, "IDBKeyRange.includes() with an only range");

test(function() {
var range = IDBKeyRange.lowerBound(5);
assert_false(range.includes(4), 'value before closed lower bound');
assert_true(range.includes(5), 'value at closed lower bound');
assert_true(range.includes(6), 'value after closed lower bound');
}, "IDBKeyRange.includes() with an closed lower-bounded range");

test(function() {
var range = IDBKeyRange.lowerBound(5, true);
assert_false(range.includes(4), 'value before open lower bound');
assert_false(range.includes(5), 'value at open lower bound');
assert_true(range.includes(6), 'value after open lower bound');
}, "IDBKeyRange.includes() with an open lower-bounded range");

test(function() {
var range = IDBKeyRange.upperBound(5);
assert_true(range.includes(4), 'value before closed upper bound');
assert_true(range.includes(5), 'value at closed upper bound');
assert_false(range.includes(6), 'value after closed upper bound');
}, "IDBKeyRange.includes() with an closed upper-bounded range");

test(function() {
var range = IDBKeyRange.upperBound(5, true);
assert_true(range.includes(4), 'value before open upper bound');
assert_false(range.includes(5), 'value at open upper bound');
assert_false(range.includes(6), 'value after open upper bound');
}, "IDBKeyRange.includes() with an open upper-bounded range");

</script>
46 changes: 15 additions & 31 deletions IndexedDB/idbobjectstore_createIndex14-exception_order.htm
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,10 @@
<link rel="help" href="http://w3c.github.io/IndexedDB/#dom-idbobjectstore-createindex">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>

function indexeddb_test(description, upgrade_func, open_func = null) {
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);
});
if (open_func) {
open.onsuccess = t.step_func(function() {
var db = open.result;
open_func(t, db);
});
}
}, description);
}

indexeddb_test(
"InvalidStateError(Incorrect mode) vs. TransactionInactiveError",
function(t, db, txn) {
var store = db.createObjectStore("s");
},
Expand All @@ -41,12 +20,12 @@
}, "Mode check should precede state check of the transaction");
t.done();
};
}
},
"InvalidStateError(Incorrect mode) vs. TransactionInactiveError"
);

var gDeletedObjectStore;
indexeddb_test(
"InvalidStateError(Deleted ObjectStore) vs. TransactionInactiveError",
function(t, db, txn) {
gDeletedObjectStore = db.createObjectStore("s");
db.deleteObjectStore("s");
Expand All @@ -56,11 +35,12 @@
}, "Deletion check should precede transaction-state check");
t.done();
};
}
},
null,
"InvalidStateError(Deleted ObjectStore) vs. TransactionInactiveError"
);

indexeddb_test(
"TransactionInactiveError vs. ConstraintError",
function(t, db, txn) {
var store = db.createObjectStore("s");
store.createIndex("index", "foo");
Expand All @@ -70,11 +50,12 @@
}, "Transaction-state check should precede index name check");
t.done();
};
}
},
null,
"TransactionInactiveError vs. ConstraintError"
);

indexeddb_test(
"ConstraintError vs. SyntaxError",
function(t, db) {
var store = db.createObjectStore("s");
store.createIndex("index", "foo");
Expand All @@ -86,11 +67,12 @@
["invalid key path 1", "invalid key path 2"]);
}, "Index name check should precede syntax check of the key path");
t.done();
}
},
null,
"ConstraintError vs. SyntaxError"
);

indexeddb_test(
"SyntaxError vs. InvalidAccessError",
function(t, db) {
var store = db.createObjectStore("s");
assert_throws("SyntaxError", function() {
Expand All @@ -99,7 +81,9 @@
{ multiEntry: true });
}, "Syntax check should precede multiEntry check of the key path");
t.done();
}
},
null,
"SyntaxError vs. InvalidAccessError"
);

</script>
20 changes: 1 addition & 19 deletions IndexedDB/idbtransaction_objectStoreNames.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,9 @@
<title>IndexedDB: IDBTransaction.objectStoreNames attribute</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.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) {
Expand Down
20 changes: 20 additions & 0 deletions IndexedDB/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,23 @@ function createdb_for_multiple_tests(dbname, version) {
function assert_key_equals(actual, expected, description) {
assert_equals(indexedDB.cmp(actual, expected), 0, description);
}

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;
if (open_func)
open_func(t, db);
});
}, description);
}
89 changes: 89 additions & 0 deletions IndexedDB/transaction-lifetime-empty.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!DOCTYPE html>
<title>IndexedDB: Commit ordering of empty transactions</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>

// Call with a test object and array of expected values. Returns a
// function to call with each actual value. Once the expected number
// of values is seen, asserts that the value orders match and completes
// the test.
function expect(t, expected) {
var results = [];
return result => {
results.push(result);
if (results.length === expected.length) {
assert_array_equals(results, expected);
t.done();
}
};
}

indexeddb_test(
(t, db) => {
db.createObjectStore('store');
},
(t, db) => {
var saw = expect(t, ['rq1.onsuccess',
'rq2.onsuccess',
'tx1.oncomplete',
'tx2.oncomplete']);

var tx1 = db.transaction('store', 'readwrite');
tx1.onabort = t.unreached_func('transaction should commit');
tx1.oncomplete = t.step_func(() => saw('tx1.oncomplete'));

var store = tx1.objectStore('store');
var rq1 = store.put('a', 1);
rq1.onerror = t.unreached_func('put should succeed');
rq1.onsuccess = t.step_func(() => {
saw('rq1.onsuccess');

var tx2 = db.transaction('store', 'readonly');
tx2.onabort = t.unreached_func('transaction should commit');
tx2.oncomplete = t.step_func(() => saw('tx2.oncomplete'));

var rq2 = store.put('b', 2);
rq2.onsuccess = t.step_func(() => saw('rq2.onsuccess'));
rq2.onerror = t.unreached_func('request should succeed');
});

},
'Transactions without requests complete in the expected order');

indexeddb_test(
(t, db) => {
db.createObjectStore('store');
},
(t, db) => {
var saw = expect(t, ['rq1.onsuccess',
'rq2.onsuccess',
'tx1.oncomplete',
'tx2.oncomplete',
'tx3.oncomplete']);
var tx1 = db.transaction('store', 'readwrite');
tx1.onabort = t.unreached_func('transaction should commit');
tx1.oncomplete = t.step_func(() => saw('tx1.oncomplete'));

var store = tx1.objectStore('store');
var rq1 = store.put('a', 1);
rq1.onerror = t.unreached_func('put should succeed');
rq1.onsuccess = t.step_func(() => {
saw('rq1.onsuccess');

var tx2 = db.transaction('store', 'readonly');
tx2.onabort = t.unreached_func('transaction should commit');
tx2.oncomplete = t.step_func(() => saw('tx2.oncomplete'));

var tx3 = db.transaction('store', 'readonly');
tx3.onabort = t.unreached_func('transaction should commit');
tx3.oncomplete = t.step_func(() => saw('tx3.oncomplete'));

var rq2 = store.put('b', 2);
rq2.onsuccess = t.step_func(() => saw('rq2.onsuccess'));
rq2.onerror = t.unreached_func('request should succeed');
});
},
'Multiple transactions without requests complete in the expected order');
</script>
3 changes: 3 additions & 0 deletions WebCryptoAPI/generateKey/failures.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ function run_test(algorithmNames) {
];

var testVectors = [];
if (algorithmNames && !Array.isArray(algorithmNames)) {
algorithmNames = [algorithmNames];
};
allTestVectors.forEach(function(vector) {
if (!algorithmNames || algorithmNames.includes(vector.name)) {
testVectors.push(vector);
Expand Down
6 changes: 6 additions & 0 deletions WebCryptoAPI/generateKey/failures_AES-CBC.worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// <meta> timeout=long
importScripts("/resources/testharness.js");
importScripts("../util/helpers.js");
importScripts("failures.js");
run_test(["AES-CBC"]);
done();
6 changes: 6 additions & 0 deletions WebCryptoAPI/generateKey/failures_AES-CTR.worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// <meta> timeout=long
importScripts("/resources/testharness.js");
importScripts("../util/helpers.js");
importScripts("failures.js");
run_test(["AES-CTR"]);
done();
6 changes: 6 additions & 0 deletions WebCryptoAPI/generateKey/failures_AES-GCM.worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// <meta> timeout=long
importScripts("/resources/testharness.js");
importScripts("../util/helpers.js");
importScripts("failures.js");
run_test(["AES-GCM"]);
done();
6 changes: 6 additions & 0 deletions WebCryptoAPI/generateKey/failures_AES-KW.worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// <meta> timeout=long
importScripts("/resources/testharness.js");
importScripts("../util/helpers.js");
importScripts("failures.js");
run_test(["AES-KW"]);
done();
6 changes: 6 additions & 0 deletions WebCryptoAPI/generateKey/failures_ECDH.worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// <meta> timeout=long
importScripts("/resources/testharness.js");
importScripts("../util/helpers.js");
importScripts("failures.js");
run_test(["ECDH"]);
done();
Loading

0 comments on commit 9560530

Please sign in to comment.