diff options
author | Kristian Monsen <kristianm@google.com> | 2010-06-28 16:42:48 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-07-02 10:29:56 +0100 |
commit | 06ea8e899e48f1f2f396b70e63fae369f2f23232 (patch) | |
tree | 20c1428cd05c76f32394ab354ea35ed99acd86d8 /LayoutTests | |
parent | 72aad67af14193199e29cdd5c4ddc095a8b9a8a8 (diff) | |
download | external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.zip external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.gz external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.bz2 |
Merge WebKit at r61871: Initial merge by git.
Change-Id: I6cff43abca9cc4782e088a469ad4f03f166a65d5
Diffstat (limited to 'LayoutTests')
-rw-r--r-- | LayoutTests/fast/js/resources/bom-in-file-retains-correct-offset.js | 2 | ||||
-rw-r--r-- | LayoutTests/fast/js/resources/script-line-number.js | 26 | ||||
-rw-r--r-- | LayoutTests/storage/change-version.html | 76 | ||||
-rw-r--r-- | LayoutTests/storage/domstorage/complex-values-expected.txt | 36 | ||||
-rw-r--r-- | LayoutTests/storage/sql-error-codes-expected.txt | 11 | ||||
-rw-r--r-- | LayoutTests/storage/sql-error-codes.html | 12 | ||||
-rw-r--r-- | LayoutTests/storage/sql-error-codes.js | 121 |
7 files changed, 233 insertions, 51 deletions
diff --git a/LayoutTests/fast/js/resources/bom-in-file-retains-correct-offset.js b/LayoutTests/fast/js/resources/bom-in-file-retains-correct-offset.js index b62a250..c4870d2 100644 --- a/LayoutTests/fast/js/resources/bom-in-file-retains-correct-offset.js +++ b/LayoutTests/fast/js/resources/bom-in-file-retains-correct-offset.js @@ -1,2 +1,2 @@ description("This ensures that BOM's scattered through a source file do not break parsing"); -function f(){successfullyReparsed=true;shouldBeTrue('successfullyReparsed');successfullyParsed=true}f(); +function g(){function f(){successfullyReparsed=true;shouldBeTrue('successfullyReparsed');successfullyParsed=true}f();} g() diff --git a/LayoutTests/fast/js/resources/script-line-number.js b/LayoutTests/fast/js/resources/script-line-number.js new file mode 100644 index 0000000..09d9b1a --- /dev/null +++ b/LayoutTests/fast/js/resources/script-line-number.js @@ -0,0 +1,26 @@ +description( +"This test checks that line numbers are correctly reported for both inline scripts and inline event handlers." +); + +function getLineFromError(e) +{ + // JSC + if (e.line) + return e.line; + + // V8 + if (e.stack) { + // ErrorName: ErrorDescription at FileName:LineNumber:ColumnNumber + parts = e.stack.split(":"); + return parts[parts.length - 2]; + } + + return -1; +} + +function assertErrorOnLine(error, expectedLine) +{ + shouldBe(stringify(getLineFromError(error)), stringify(expectedLine)); +} + +var successfullyParsed = true; diff --git a/LayoutTests/storage/change-version.html b/LayoutTests/storage/change-version.html index d81c6b5..9b6876c 100644 --- a/LayoutTests/storage/change-version.html +++ b/LayoutTests/storage/change-version.html @@ -1,26 +1,26 @@ -<html> +<html> <head> <title>Test database.changeVersion</title> -<script> -var db; +<script> +var db1; var EXPECTED_VERSION_AFTER_HIXIE_TEST = '2'; var EXPECTED_VERSION_AFTER_RELOAD = '3'; - + function emptyFunction() { } - + function changeVersionCallback(tx) { tx.executeSql("DROP table if exists info;", [], emptyFunction, emptyFunction); tx.executeSql("CREATE table if not exists info (version INTEGER);", [], emptyFunction, emptyFunction); tx.executeSql("INSERT into info values(?);", [EXPECTED_VERSION_AFTER_RELOAD], emptyFunction, emptyFunction); } - + function changeVersionSuccess() { - log("Successfully changed version to ' + db.version + '. Reloading."); + log("Successfully changed version to " + db1.version + ". Reloading."); window.location.href = window.location + '?2'; } - + function changeVersionError(error) { log("Error: " + error.message); @@ -42,8 +42,8 @@ function log(message) function runTest() { if (window.location.search == "?2") { - db = window.openDatabase("changeversion-test", "", "Test for the database.changeVersion() function", 1024); - log("Finished tests with version " + db.version + "; expected version: " + EXPECTED_VERSION_AFTER_RELOAD); + db1 = window.openDatabase("changeversion-test", "", "Test for the database.changeVersion() function", 1024); + log("Finished tests with version " + db1.version + "; expected version: " + EXPECTED_VERSION_AFTER_RELOAD); finishTest(); } else testPart1(); @@ -55,31 +55,43 @@ function testPart1() { layoutTestController.dumpAsText(); layoutTestController.waitUntilDone(); } - - db = window.openDatabase("changeversion-test", "", "Test for the database.changeVersion() function", 1024); - if (db.version != EXPECTED_VERSION_AFTER_RELOAD) { - // First run Hixie's test to ensure basic changeVersion functionality works (see bug 28418). - db.changeVersion("", EXPECTED_VERSION_AFTER_HIXIE_TEST, emptyFunction, function (e) { - log('FAIL in changeVersion:' + e); - finishTest(); - }, function () { - try { - var db2 = openDatabase("change-version-test", EXPECTED_VERSION_AFTER_HIXIE_TEST, "", 0); - } catch (e) { - log('FAIL in openDatabase: ' + e); - finishTest(); - } - // The two database versions should match. - if (db.version == db2.version) - log("PASS: db.version(" + db.version + ") matches db2.version(" + db2.version +") as expected."); - else - log("FAIL: db.version(" + db.version + ") does not match db2.version(" + db2.version +")"); + db1 = window.openDatabase("changeversion-test", "1", "Test for the database.changeVersion() function", 1024); + var db2 = window.openDatabase("changeversion-test", "1", "Test for the database.changeVersion() function", 1024); - // Now try a test to ensure the version persists after reloading (see bug 27836) - db.changeVersion(EXPECTED_VERSION_AFTER_HIXIE_TEST, EXPECTED_VERSION_AFTER_RELOAD, changeVersionCallback, changeVersionError, changeVersionSuccess); + // First run Hixie's test to ensure basic changeVersion functionality works (see bug 28418). + db1.changeVersion("1", EXPECTED_VERSION_AFTER_HIXIE_TEST, emptyFunction, function (e) { + log("FAIL in changeVersion:" + e); + finishTest(); + }, function () { + // Make sure the version change has propagated to db2 too. + // All transactions on db2 should fail. + if (db2.version != db1.version) { + log("FAIL: changing db1's version (" + db1.version + ") did not change db2's version (" + db2.version + ") as expected."); + finishTest(); + } + db2.transaction(function(tx) { + tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo INT)"); + }, function(error) { }, function() { + log("FAIL: The DB version changed, all transactions on db2 should fail."); + finishTest(); }); - } + + // Make sure any new handle to the same DB sees the new version + try { + var db3 = openDatabase("change-version-test", EXPECTED_VERSION_AFTER_HIXIE_TEST, "", 0); + } catch (e) { + log("FAIL in openDatabase: " + e); + finishTest(); + } + if (db1.version != db3.version) { + log("FAIL: db.version(" + db1.version + ") does not match db3.version(" + db3.version +")"); + finishTest(); + } + + // Now try a test to ensure the version persists after reloading (see bug 27836) + db1.changeVersion(EXPECTED_VERSION_AFTER_HIXIE_TEST, EXPECTED_VERSION_AFTER_RELOAD, changeVersionCallback, changeVersionError, changeVersionSuccess); + }); } </script> </head> diff --git a/LayoutTests/storage/domstorage/complex-values-expected.txt b/LayoutTests/storage/domstorage/complex-values-expected.txt index 69d7644..9a75e42 100644 --- a/LayoutTests/storage/domstorage/complex-values-expected.txt +++ b/LayoutTests/storage/domstorage/complex-values-expected.txt @@ -82,25 +82,25 @@ PASS storage.getItem('foo9') is "2" storage.foo10 = k PASS typeof storage['foo10'] is "string" -PASS storage['foo10'] is "ÿ찡hello" +PASS storage['foo10'] is "ÿ찡�hello" PASS typeof storage.foo10 is "string" -PASS storage.foo10 is "ÿ찡hello" +PASS storage.foo10 is "ÿ찡�hello" PASS typeof storage.getItem('foo10') is "string" -PASS storage.getItem('foo10') is "ÿ찡hello" +PASS storage.getItem('foo10') is "ÿ찡�hello" storage['foo11'] = k PASS typeof storage['foo11'] is "string" -PASS storage['foo11'] is "ÿ찡hello" +PASS storage['foo11'] is "ÿ찡�hello" PASS typeof storage.foo11 is "string" -PASS storage.foo11 is "ÿ찡hello" +PASS storage.foo11 is "ÿ찡�hello" PASS typeof storage.getItem('foo11') is "string" -PASS storage.getItem('foo11') is "ÿ찡hello" +PASS storage.getItem('foo11') is "ÿ찡�hello" storage.setItem('foo12', k) PASS typeof storage['foo12'] is "string" -PASS storage['foo12'] is "ÿ찡hello" +PASS storage['foo12'] is "ÿ찡�hello" PASS typeof storage.foo12 is "string" -PASS storage.foo12 is "ÿ찡hello" +PASS storage.foo12 is "ÿ찡�hello" PASS typeof storage.getItem('foo12') is "string" -PASS storage.getItem('foo12') is "ÿ찡hello" +PASS storage.getItem('foo12') is "ÿ찡�hello" Testing localStorage @@ -182,25 +182,25 @@ PASS storage.getItem('foo9') is "2" storage.foo10 = k PASS typeof storage['foo10'] is "string" -PASS storage['foo10'] is "ÿ찡hello" +PASS storage['foo10'] is "ÿ찡�hello" PASS typeof storage.foo10 is "string" -PASS storage.foo10 is "ÿ찡hello" +PASS storage.foo10 is "ÿ찡�hello" PASS typeof storage.getItem('foo10') is "string" -PASS storage.getItem('foo10') is "ÿ찡hello" +PASS storage.getItem('foo10') is "ÿ찡�hello" storage['foo11'] = k PASS typeof storage['foo11'] is "string" -PASS storage['foo11'] is "ÿ찡hello" +PASS storage['foo11'] is "ÿ찡�hello" PASS typeof storage.foo11 is "string" -PASS storage.foo11 is "ÿ찡hello" +PASS storage.foo11 is "ÿ찡�hello" PASS typeof storage.getItem('foo11') is "string" -PASS storage.getItem('foo11') is "ÿ찡hello" +PASS storage.getItem('foo11') is "ÿ찡�hello" storage.setItem('foo12', k) PASS typeof storage['foo12'] is "string" -PASS storage['foo12'] is "ÿ찡hello" +PASS storage['foo12'] is "ÿ찡�hello" PASS typeof storage.foo12 is "string" -PASS storage.foo12 is "ÿ찡hello" +PASS storage.foo12 is "ÿ찡�hello" PASS typeof storage.getItem('foo12') is "string" -PASS storage.getItem('foo12') is "ÿ찡hello" +PASS storage.getItem('foo12') is "ÿ찡�hello" PASS successfullyParsed is true TEST COMPLETE diff --git a/LayoutTests/storage/sql-error-codes-expected.txt b/LayoutTests/storage/sql-error-codes-expected.txt new file mode 100644 index 0000000..1a9caa7 --- /dev/null +++ b/LayoutTests/storage/sql-error-codes-expected.txt @@ -0,0 +1,11 @@ +CONSOLE MESSAGE: line 0: Exception thrown in transaction callback. +CONSOLE MESSAGE: line 0: Cannot call toString() on this object. +This test tests the error codes reported in exceptional situations. +PASS: expected and got error code UNKNOWN_ERR +PASS: expected and got error code UNKNOWN_ERR +PASS: expected and got error code SYNTAX_ERR +PASS: expected and got error code SYNTAX_ERR +PASS: expected and got error code UNKNOWN_ERR +PASS: expected and got error code QUOTA_ERR +PASS: expected and got error code VERSION_ERR + diff --git a/LayoutTests/storage/sql-error-codes.html b/LayoutTests/storage/sql-error-codes.html new file mode 100644 index 0000000..dc70c6c --- /dev/null +++ b/LayoutTests/storage/sql-error-codes.html @@ -0,0 +1,12 @@ +<html> +<head> +<script src="resources/database-common.js"></script> +<script src="sql-error-codes.js"></script> +</head> +<body onload="setupAndRunTest();"> +This test tests the error codes reported in exceptional situations.<br> +<pre id="console"> +FAILURE: test didn't run. +</pre> +</body> +</html> diff --git a/LayoutTests/storage/sql-error-codes.js b/LayoutTests/storage/sql-error-codes.js new file mode 100644 index 0000000..9d6f6d3 --- /dev/null +++ b/LayoutTests/storage/sql-error-codes.js @@ -0,0 +1,121 @@ +function finishTest() +{ + if (window.layoutTestController) + layoutTestController.notifyDone(); +} + +var TOTAL_TESTS = 7; +var testsRun = 0; +function transactionErrorCallback(error, expectedErrorCodeName) +{ + if (error.code == error[expectedErrorCodeName]) { + log("PASS: expected and got error code " + expectedErrorCodeName); + if (++testsRun == TOTAL_TESTS) + finishTest(); + } else { + log("FAIL: expected error code " + expectedErrorCodeName + " (" + error[expectedErrorCodeName] + "); got " + error.code); + finishTest(); + } +} + +function transactionSuccessCallback() +{ + log("FAIL: a transaction has completed successfully."); + finishTest(); +} + +function testTransaction(db, transactionCallback, expectedErrorCodeName) +{ + db.transaction(transactionCallback, + function(error) { + transactionErrorCallback(error, expectedErrorCodeName); + }, transactionSuccessCallback); +} + +function testTransactionThrowsException(db) +{ + testTransaction(db, function(tx) { throw "Exception thrown in transaction callback."; }, "UNKNOWN_ERR"); +} + +function testTransactionFailureBecauseOfStatementFailure(db) +{ + testTransaction(db, + function(tx) { + tx.executeSql("BAD STATEMENT", [], null, function(tx, error) { return true; }); + }, "UNKNOWN_ERR"); +} + +function testInvalidStatement(db) +{ + testTransaction(db, function(tx) { tx.executeSql("BAD STATEMENT"); }, "SYNTAX_ERR"); +} + +function testIncorrectNumberOfBindParameters(db) +{ + testTransaction(db, + function(tx) { + tx.executeSql("CREATE TABLE IF NOT EXISTS BadBindNumberTest (Foo INT, Bar INT)"); + tx.executeSql("INSERT INTO BadBindNumberTest VALUES (?, ?)", [1]); + }, "SYNTAX_ERR"); +} + +function testBindParameterOfWrongType(db) +{ + var badString = { }; + badString.toString = function() { throw "Cannot call toString() on this object." }; + + // JSC will throw an exception when calling badString.toString(). V8 will catch it. + // So we run this transaction using a custom success callback. + db.transaction(function(tx) { + tx.executeSql("CREATE TABLE IF NOT EXISTS BadBindTypeTest (Foo TEXT)"); + tx.executeSql("INSERT INTO BadBindTypeTest VALUES (?)", [badString]); + }, function(error) { + transactionErrorCallback(error, "UNKNOWN_ERR"); + }, function() { + log("The transaction in testBindParameterOfWrongType() was successful."); + testsRun++; + }); +} + +function testQuotaExceeded(db) +{ + testTransaction(db, + function(tx) { + tx.executeSql("CREATE TABLE IF NOT EXISTS QuotaTest (Foo BLOB)"); + tx.executeSql("INSERT INTO QuotaTest VALUES (ZEROBLOB(10 * 1024 * 1024))"); + }, "QUOTA_ERR"); +} + +function testVersionMismatch(db) +{ + // Use another DB handle to change the version. However, in order to make sure that the DB version is not + // changed before the transactions in the other tests have run, we need to do it in a transaction on 'db'. + db.transaction(function(tx) { + var db2 = openDatabaseWithSuffix("SQLErrorCodesTest", "1.0", "Tests the error codes.", 1); + db2.changeVersion("1.0", "2.0", function(tx) { }, + function(error) { + log("FAIL: could not change the DB version."); + finishTest(); + }, function() { }); + }); + + testTransaction(db, + function(tx) { + tx.executeSql("THIS STATEMENT SHOULD NEVER GET EXECUTED"); + }, "VERSION_ERR"); +} + +function runTest() +{ + if (window.layoutTestController) + layoutTestController.clearAllDatabases(); + + var db = openDatabaseWithSuffix("SQLErrorCodesTest", "1.0", "Tests the error codes.", 1); + testTransactionThrowsException(db); + testTransactionFailureBecauseOfStatementFailure(db); + testInvalidStatement(db); + testIncorrectNumberOfBindParameters(db); + testBindParameterOfWrongType(db); + testQuotaExceeded(db); + testVersionMismatch(db); +} |