summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-26 02:29:37 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-26 02:29:37 +0000
commit4ef6907bda202b63564d4773f36f69079bcaa509 (patch)
tree81cc50f4062653bf8093ac12674c0fcd3238abda
parentbaec95263e9c03ed519cc3240f5816dffb841270 (diff)
downloadchromium_src-4ef6907bda202b63564d4773f36f69079bcaa509.zip
chromium_src-4ef6907bda202b63564d4773f36f69079bcaa509.tar.gz
chromium_src-4ef6907bda202b63564d4773f36f69079bcaa509.tar.bz2
Copy test data for a few browser_tests in prepartion for moving them to content_browsertests
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148488 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/test/data/device_orientation/device_orientation_test.html36
-rw-r--r--content/test/data/fileapi/common.js53
-rw-r--r--content/test/data/fileapi/create_test.html10
-rw-r--r--content/test/data/fileapi/create_test.js19
-rw-r--r--content/test/data/fileapi/quota_test.html10
-rw-r--r--content/test/data/fileapi/quota_test.js66
-rw-r--r--content/test/data/fileapi/request_test.html10
-rw-r--r--content/test/data/fileapi/request_test.js19
8 files changed, 223 insertions, 0 deletions
diff --git a/content/test/data/device_orientation/device_orientation_test.html b/content/test/data/device_orientation/device_orientation_test.html
new file mode 100644
index 0000000..95c68f5
--- /dev/null
+++ b/content/test/data/device_orientation/device_orientation_test.html
@@ -0,0 +1,36 @@
+<html>
+ <head>
+ <title>DeviceOrientation test</title>
+ <script type="text/javascript">
+ var eventCount = 0;
+
+ function checkOrientationEvent(event) {
+ // Return true iff the orientation is close enough to (1, 2, 3).
+ return Math.abs(event.alpha - 1) < 0.01 &&
+ Math.abs(event.beta - 2) < 0.01 &&
+ Math.abs(event.gamma - 3) < 0.01;
+ }
+
+ function onOrientation(event) {
+ if (checkOrientationEvent(event)) {
+ window.removeEventListener('deviceorientation', onOrientation);
+ pass();
+ } else {
+ fail();
+ }
+ }
+
+ function pass() {
+ document.getElementById('status').innerHTML = 'PASS';
+ document.location = '#pass';
+ }
+
+ function fail() {
+ document.location = '#fail';
+ }
+ </script>
+ </head>
+ <body onLoad="window.addEventListener('deviceorientation', onOrientation)">
+ <div id="status">FAIL</div>
+ </body>
+</html>
diff --git a/content/test/data/fileapi/common.js b/content/test/data/fileapi/common.js
new file mode 100644
index 0000000..3fc52df
--- /dev/null
+++ b/content/test/data/fileapi/common.js
@@ -0,0 +1,53 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function debug(message)
+{
+ document.getElementById('status').innerHTML += '<br/>' + message;
+}
+
+function done(message)
+{
+ if (document.location.hash == '#fail')
+ return;
+ if (message)
+ debug('PASS: ' + message);
+ else
+ debug('PASS');
+ document.location.hash = '#pass';
+}
+
+function fail(message)
+{
+ debug('FAILED: ' + message);
+ document.location.hash = '#fail';
+}
+
+function getLog()
+{
+ return '' + document.getElementById('status').innerHTML;
+}
+
+function fileErrorToString(e)
+{
+ switch (e.code) {
+ case FileError.QUOTA_EXCEEDED_ERR:
+ return 'QUOTA_EXCEEDED_ERR';
+ case FileError.NOT_FOUND_ERR:
+ return 'NOT_FOUND_ERR';
+ case FileError.SECURITY_ERR:
+ return 'SECURITY_ERR';
+ case FileError.INVALID_MODIFICATION_ERR:
+ return 'INVALID_MODIFICATION_ERR';
+ case FileError.INVALID_STATE_ERR:
+ return 'INVALID_STATE_ERR';
+ default:
+ return 'Unknown Error';
+ }
+}
+
+function unexpectedErrorCallback(e)
+{
+ fail('unexpectedErrorCallback:' + fileErrorToString(e));
+}
diff --git a/content/test/data/fileapi/create_test.html b/content/test/data/fileapi/create_test.html
new file mode 100644
index 0000000..5d6f1be
--- /dev/null
+++ b/content/test/data/fileapi/create_test.html
@@ -0,0 +1,10 @@
+<html>
+ <head>
+ <title>FileAPI create test</title>
+ <script type="text/javascript" src="common.js"></script>
+ <script type="text/javascript" src="create_test.js"></script>
+ </head>
+ <body onLoad="test()">
+ <div id="status">Starting...</div>
+ </body>
+</html>
diff --git a/content/test/data/fileapi/create_test.js b/content/test/data/fileapi/create_test.js
new file mode 100644
index 0000000..5026bb0
--- /dev/null
+++ b/content/test/data/fileapi/create_test.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function requestFileSystemSuccess(fs)
+{
+ fs.root.getFile('foo', {create: true, exclusive: false}, done,
+ function(e) { fail('Open:' + fileErrorToString(e)); } );
+}
+
+function test()
+{
+ debug('Requesting FileSystem');
+ window.webkitRequestFileSystem(
+ window.TEMPORARY,
+ 1024 * 1024,
+ requestFileSystemSuccess,
+ unexpectedErrorCallback);
+}
diff --git a/content/test/data/fileapi/quota_test.html b/content/test/data/fileapi/quota_test.html
new file mode 100644
index 0000000..8612f0ca
--- /dev/null
+++ b/content/test/data/fileapi/quota_test.html
@@ -0,0 +1,10 @@
+<html>
+ <head>
+ <title>FileAPI quota test</title>
+ <script type="text/javascript" src="common.js"></script>
+ <script type="text/javascript" src="quota_test.js"></script>
+ </head>
+ <body onLoad="test()">
+ <div id="status">Starting...</div>
+ </body>
+</html>
diff --git a/content/test/data/fileapi/quota_test.js b/content/test/data/fileapi/quota_test.js
new file mode 100644
index 0000000..382d623
--- /dev/null
+++ b/content/test/data/fileapi/quota_test.js
@@ -0,0 +1,66 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function truncateFailByQuota(fs) {
+ fs.root.getFile('fd', {create: false, exclusive: false}, function(fileEntry) {
+ fileEntry.createWriter(function(fileWriter) {
+ var failedInTruncate = false;
+ fileWriter.onerror = function(e) {
+ failedInTruncate = true;
+ };
+ fileWriter.onwriteend = function(e) {
+ if (failedInTruncate) {
+ fail(e.currentTarget.error);
+ } else {
+ done();
+ }
+ };
+ fileWriter.truncate(2500 * 1024);
+ }, unexpectedErrorCallback)
+ }, function(e) { fail('Open for 2nd truncate:' + fileErrorToString(e)); } );
+}
+
+function requestFileSystemSuccess(fs) {
+ fs.root.getFile('fd', {create: true, exclusive: false}, function(fileEntry) {
+ fileEntry.createWriter(function(fileWriter) {
+ var failedInTruncate = false;
+ fileWriter.onerror = function(e) {
+ debug(e.currentTarget.error);
+ failedInTruncate = true;
+ };
+ fileWriter.onwriteend = function() {
+ if (failedInTruncate) {
+ truncateFailByQuota(fs);
+ } else {
+ fail('Unexpectedly succeeded to truncate. It should fail by quota.');
+ }
+ };
+ fileWriter.truncate(10000 * 1024);
+ }, unexpectedErrorCallback)
+ }, function(e) { fail('Open for 1st truncate:' + fileErrorToString(e)); } );
+}
+
+function quotaSuccess(usage, quota) {
+ if (usage != 0)
+ fail('Usage is not zero: ' + usage);
+ if (quota != 5000 * 1024)
+ fail('Quota is not 5000KiB: ' + quota);
+
+ window.webkitRequestFileSystem(
+ window.TEMPORARY,
+ 1024 * 1024,
+ requestFileSystemSuccess,
+ unexpectedErrorCallback);
+}
+
+function test() {
+ if (window.webkitStorageInfo) {
+ debug('Querying usage and quota.');
+ webkitStorageInfo.queryUsageAndQuota(webkitStorageInfo.TEMPORARY,
+ quotaSuccess,
+ unexpectedErrorCallback);
+ } else {
+ debug('This test requires window.webkitStorageInfo.');
+ }
+}
diff --git a/content/test/data/fileapi/request_test.html b/content/test/data/fileapi/request_test.html
new file mode 100644
index 0000000..b59f704
--- /dev/null
+++ b/content/test/data/fileapi/request_test.html
@@ -0,0 +1,10 @@
+<html>
+ <head>
+ <title>FileAPI request test</title>
+ <script type="text/javascript" src="common.js"></script>
+ <script type="text/javascript" src="request_test.js"></script>
+ </head>
+ <body onLoad="test()">
+ <div id="status">Starting...</div>
+ </body>
+</html>
diff --git a/content/test/data/fileapi/request_test.js b/content/test/data/fileapi/request_test.js
new file mode 100644
index 0000000..c9c26a2
--- /dev/null
+++ b/content/test/data/fileapi/request_test.js
@@ -0,0 +1,19 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function requestFileSystemSuccess(fs)
+{
+ debug('Requested successfully.');
+ done();
+}
+
+function test()
+{
+ debug('Requesting FileSystem');
+ window.webkitRequestFileSystem(
+ window.TEMPORARY,
+ 1024 * 1024,
+ requestFileSystemSuccess,
+ unexpectedErrorCallback);
+}