Commit 4ef6907b authored by jam@chromium.org's avatar jam@chromium.org

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
parent baec9526
<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>
// 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));
}
<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>
// 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);
}
<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>
// 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.');
}
}
<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>
// 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);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment