From 06ea8e899e48f1f2f396b70e63fae369f2f23232 Mon Sep 17 00:00:00 2001 From: Kristian Monsen Date: Mon, 28 Jun 2010 16:42:48 +0100 Subject: Merge WebKit at r61871: Initial merge by git. Change-Id: I6cff43abca9cc4782e088a469ad4f03f166a65d5 --- .../bom-in-file-retains-correct-offset.js | 2 +- .../fast/js/resources/script-line-number.js | 26 +++++ LayoutTests/storage/change-version.html | 76 +++++++------ .../storage/domstorage/complex-values-expected.txt | 36 +++--- LayoutTests/storage/sql-error-codes-expected.txt | 11 ++ LayoutTests/storage/sql-error-codes.html | 12 ++ LayoutTests/storage/sql-error-codes.js | 121 +++++++++++++++++++++ 7 files changed, 233 insertions(+), 51 deletions(-) create mode 100644 LayoutTests/fast/js/resources/script-line-number.js create mode 100644 LayoutTests/storage/sql-error-codes-expected.txt create mode 100644 LayoutTests/storage/sql-error-codes.html create mode 100644 LayoutTests/storage/sql-error-codes.js (limited to 'LayoutTests') 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 @@ - + Test database.changeVersion - 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 @@ + + + + + + +This test tests the error codes reported in exceptional situations.
+
+FAILURE: test didn't run.
+
+ + 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); +} -- cgit v1.1