Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/lazyboy/chromium
Browse files Browse the repository at this point in the history
  • Loading branch information
Istiaque Ahmed committed Apr 15, 2013
2 parents 59bcf2c + 73a2137 commit b8ff168
Show file tree
Hide file tree
Showing 15 changed files with 479 additions and 6 deletions.
1 change: 1 addition & 0 deletions bugs/damage_buffer_compositing/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
New style simple (chromium) platform app.
18 changes: 18 additions & 0 deletions bugs/damage_buffer_compositing/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!--
* Copyright 2013 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.
-->
<html>
<head>
<script type="text/javascript" src="main.js"></script>
</head>
<body>
<div>Embedder</div>
<div>
<button id="crazy-resize">Start resize</button>
<button id="change-src">Change to composited src</button>
</div>
<webview src="data:text/html,hello-possibly-non-composited-world" style="border: 1px solid gray; height: 600px;"></webview>
</body>
</html>
38 changes: 38 additions & 0 deletions bugs/damage_buffer_compositing/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
var LOG = function(msg) { window.console.log(msg); };

var webview;

var doingResize = false;
var w = 200; var dW = 2; var minW = 100; var maxW = 600;
var doCrazyResize = function() {
if (!doingResize) return;
if (w + dW < minW || w + dW > maxW) dW = -dW;
w += dW;
webview.style.width = w + 'px';
window.setTimeout(doCrazyResize, 10);
};

var doCrazyResizeClick = function(e) {
doingResize = !doingResize;
document.getElementById('crazy-resize').innerHTML =
(doingResize ? 'Stop' : 'Start') + ' resize';
doCrazyResize();
};

var isCompositedPage = false;
var flipSrcCompositingPage = function(e) {
if (isCompositedPage) {
webview.src = 'http://jsbin.com/ixomuz/1';
LOG('changed src to contain regular page');
} else {
webview.src = 'data:text/html,non-animation-hello';
LOG('changed src to contain css anim');
}
isCompositedPage = !isCompositedPage;
};

window.onload = function() {
webview = document.querySelector('webview');
document.getElementById('crazy-resize').onclick = doCrazyResizeClick;
document.getElementById('change-src').onclick = flipSrcCompositingPage;
};
14 changes: 14 additions & 0 deletions bugs/damage_buffer_compositing/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"manifest_version": 2,
"name": "Bug: resize + compositing + damage buffer",
"version": "1",
"minimum_chrome_version": "23",
"permissions": [
"webview"
],
"app": {
"background": {
"scripts": ["test.js"]
}
}
}
10 changes: 10 additions & 0 deletions bugs/damage_buffer_compositing/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Listens for the app launching then creates the window
*
* @see http://developer.chrome.com/trunk/apps/app.runtime.html
* @see http://developer.chrome.com/trunk/apps/app.window.html
*/
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('main.html',
{width: 500, height: 300});
});
1 change: 1 addition & 0 deletions tests/chrome-apps/storage/embedder_idb/guest/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This page needs to be served from a webserver and guest/webivew url/src in ../main.html should point there.
19 changes: 19 additions & 0 deletions tests/chrome-apps/storage/embedder_idb/guest/page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<html>
<head>
<title>IndexedDB test</title>
</head>
<body>
<div>
<input type="text" id="inumchars" value="1000000"/>
<button id="writeb">Write data</button>
<button id="countb">Read count data</button>
<button id="readb">Read one row</button>
<button id="createb">Create database</button>
<button id="clearb">Clear table items</button>
<button id="showb">Show DB usage stat</button>
<button id="clearlogs">Clear logs</button>
</div>
<div id="value"></div>
<script src="page.js"></script>
</body>
</html>
196 changes: 196 additions & 0 deletions tests/chrome-apps/storage/embedder_idb/guest/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
var LOG = function(msg) {
window.console.log(msg);
$('value').innerText += 'log: ' + msg + '\n';
};
var $ = function(id) { return document.getElementById(id); };
var clearLogs = function() { $('value').innerText = '' };


var DBNAME = 'dbname';
var TABLE = 'mytable';
var COLUMN = 'valcol';

var dbErrorGFunction = function(e) { LOG('dbErrorGFunction: ' + e); };

var setUpDone = false;
var maybeSetUpIndexedDB = function() {
if (setUpDone) return;
window.indexedDB = window.indexedDB ||
window.webkitIndexedDB ||
window.mozIndexedDB;
if ('webkitIndexedDB' in window) {
window.IDBTransaction = window.webkitIDBTransaction;
window.IDBKeyRange = window.webkitIDBKeyRange;
}
};
maybeSetUpIndexedDB();

var g_db;
var attemptedToOpen = false;

var getData = function(numChars) {
var y = []; y.length = numChars + 1;
return y.join('a');
};

var openOrCreateDb = function(onSuccess) {
LOG('Start open/create db');
var version = 1;
var req = indexedDB.open(TABLE, version);

req.onupgradeneeded = function(e) {
var db = e.target.result;
e.target.transaction.onerror = dbErrorGFunction;
if (db.objectStoreNames.contains(TABLE)) {
db.deleteObjectStore(TABLE);
}
var store = db.createObjectStore(TABLE);
};
req.onsuccess = function(e) {
LOG('openOrCreateDb.req.onsuccess: e.target.result: ' + e.target.result);
g_db = e.target.result;
if (onSuccess) onSuccess(true /* opt_doNotOpen */);
};
req.onerror = dbErrorGFunction;
};

var maybeOpenDb = function(continueFunc) {
if (!attemptedToOpen) {
attemptedToOpen = 1;
var successCallback = continueFunc;
openOrCreateDb(successCallback);
}
};

var writeValue = function(opt_doNotOpen) {
LOG('writeValue');
if (!opt_doNotOpen) { return guardedOpen(writeValue); }
if (!g_db) { LOG('Error, no db'); return; }

var numchars = 1 * $('inumchars').value;
LOG('numchars: ' + numchars);
if (typeof numchars != 'number') {
LOG('Error: numchars not a number');
return;
}

var val = getData(numchars);

var trans = g_db.transaction([TABLE], 'readwrite');
var store = trans.objectStore(TABLE);

//var req = store.put(val, '' + (+new Date));
var req = store.put(val, 'single');
//var req = store.put('dinosaur', 'single');
req.onsuccess = function(e) {
LOG('writeValue.req.onsuccess');
};
req.onerror = function(e) {
LOG('writeValue.req.onerror: ' + req.error);
LOG('name: ' + req.error.name);
};
};

var guardedOpen = function(callbackFunc) {
if (g_db) { // Already opened successfully.
callbackFunc(true /* opt_doNotOpen */);
} else {
maybeOpenDb(callbackFunc);
}
};

var readCount = function(opt_doNotOpen) {
LOG('readCount');
if (!opt_doNotOpen) { return guardedOpen(readCount); }
if (!g_db) { LOG('Error, no db'); return; }

var trans = g_db.transaction([TABLE], 'readwrite');
var store = trans.objectStore(TABLE);

var req = store.count();
req.onsuccess = function(e) {
var count = e.target.result;
LOG('readCount.req.onsuccess, count: ' + count);
};
req.onerror = function(e) {
LOG('readCount.req.onerror');
}
};

var readValue = function(opt_doNotOpen) {
LOG('readValue');
if (!opt_doNotOpen) { return guardedOpen(readValue); }
if (!g_db) { LOG('Error, no db'); return; }

var trans = g_db.transaction([TABLE], 'readwrite');
var store = trans.objectStore(TABLE);

var req = store.get('single');
req.onsuccess = function(e) {
var value = e.target.result;
LOG('readValue.req.onsuccess, value: ' + value);
};
req.onerror = function(e) {
LOG('readValue.req.onerror');
}

/*
var singleRange = IDBKeyRange.only('single');
//var singleRange = IDBKeyRange.lowerBound(0);
var cursorReq = store.openCursor(singleRange);
cursorReq.onsuccess = function(e) {
var cursor = e.target.result;
if (cursor) {
//LOG('readValue.cursor: ' + cursor);
LOG('readValue.cursor.value: ' + cursor.value);
cursor.continue();
}
};
cursorReq.onerror = function(e) { LOG('readValue.req.onerror'); };
*/
};

var clearValues = function(opt_doNotOpen) {
LOG('clearValues');
if (!opt_doNotOpen) { return guardedOpen(clearValues); }
if (!g_db) { LOG('Error, no db'); return; }

var trans = g_db.transaction([TABLE], 'readwrite');
var store = trans.objectStore(TABLE);

var req = store.clear();
req.onsuccess = function(e) {
LOG('clearValues.req.onsuccess');
};
req.onerror = function(e) {
LOG('clearValues.req.onerror');
};
};

var showDbUsageStat = function() {
LOG('showDbUsageStat');
navigator.webkitTemporaryStorage.queryUsageAndQuota(
function(currentUsageInBytes, currentQuotaInBytes) {
LOG('webkitTemporaryStorage: currentUsageInBytes: ' +
currentUsageInBytes +
', currentQuotaInBytes: ' + currentQuotaInBytes);
});
navigator.webkitPersistentStorage.queryUsageAndQuota(
function(currentUsageInBytes, currentQuotaInBytes) {
LOG('webkitPersistentStorage: currentUsageInBytes: ' +
currentUsageInBytes +
', currentQuotaInBytes: ' + currentQuotaInBytes);
});
};

window.onload = function() {
$('createb').onclick = function(e) { openOrCreateDb(); };
$('countb').onclick = function(e) { readCount(); };
$('readb').onclick = function(e) { readValue(); };
$('writeb').onclick = function(e) { writeValue(); };
$('clearb').onclick = function(e) { clearValues(); };

$('showb').onclick = showDbUsageStat;
$('clearlogs').onclick = clearLogs;
};

9 changes: 7 additions & 2 deletions tests/chrome-apps/storage/embedder_idb/main.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<!--
* Copyright (c) 2012 The Chromium Authors. All rights reserved. Use of this
* Copyright 2013 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.
-->
<html>
<head>
<script type="text/javascript" src="main.js"></script>
</head>
<body>
<!--
Expand All @@ -14,7 +15,11 @@
<script src="main.js"></script>
-->
<div>Embedder (partitioned guest)</div>
<webview partition="persist:idb" src="http://osmium.wat.corp.google.com/a/idb/page.html" style="border: 1px solid gray; height: 240px; width: 90%"></webview>
<button id="button-clear">Clear guest storage</button>
<!-- FIX ME -->
<!-- FIX ME -->
<!-- FIX ME -->
<webview partition="persist:idb" src="guest/page.html" style="border: 1px solid gray; height: 240px; width: 90%"></webview>
<!--
<webview src="http://www.google.com" style="border: 1px solid gray; height: 240px; width: 90%"></webview>
-->
Expand Down
1 change: 1 addition & 0 deletions tests/chrome-apps/storage/embedder_websql/guest/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This page needs to be served from a webserver and guest/webivew url/src in ../main.html should point there.
17 changes: 17 additions & 0 deletions tests/chrome-apps/storage/embedder_websql/guest/page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<html>
<head>
</head>
<body>
<div>
<input type="text" id="inumchars" value="1000000"/>
<button id="writeb">Write data</button>
<button id="readb">Read data</button>
<button id="createb">Create database</button>
<button id="clearb">Clear table items</button>
<button id="showb">Show DB usage stat</button>
<button id="clearlogs">Clear logs</button>
</div>
<div id="value"></div>
<script src="page.js"></script>
</body>
</html>
Loading

0 comments on commit b8ff168

Please sign in to comment.