forked from lazyboy/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/lazyboy/chromium
- Loading branch information
Showing
15 changed files
with
479 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
New style simple (chromium) platform app. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.