summaryrefslogtreecommitdiffstats
path: root/chrome/test/data/extensions/samples/bookmarks
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/test/data/extensions/samples/bookmarks')
-rw-r--r--chrome/test/data/extensions/samples/bookmarks/bookmark_api.html88
-rw-r--r--chrome/test/data/extensions/samples/bookmarks/bookmark_view.html152
-rw-r--r--chrome/test/data/extensions/samples/bookmarks/manifest.json7
3 files changed, 0 insertions, 247 deletions
diff --git a/chrome/test/data/extensions/samples/bookmarks/bookmark_api.html b/chrome/test/data/extensions/samples/bookmarks/bookmark_api.html
deleted file mode 100644
index 7421ad6..0000000
--- a/chrome/test/data/extensions/samples/bookmarks/bookmark_api.html
+++ /dev/null
@@ -1,88 +0,0 @@
-<html>
-<script>
-var dump = function(obj, indent) {
- if (indent === undefined)
- indent = "";
- if (typeof obj == "object") {
- var ret = "{<br/>";
- var child_indent = indent + " ";
- for (var item in obj) {
- var child = null;
- try {
- child = obj[item];
- } catch (e) {
- child = '<error>';
- }
- ret += child_indent + item + ": " + dump(child, indent + " ");
- }
- return ret + indent + "}" + "<br/>";
- } else {
- return obj.toString() + "<br/>";
- }
-}
-
-var testMoveBookmarks = function(event) {
- testMoveBookmarks2(event);
-}
-
-var testMoveBookmarks2 = function(event) {
- console.log(testMoveBookmarks2.caller.name);
- if (event.shiftKey) {
- // TODO - it would be nice to have a mechanism to do this built-in to a
- // context menu.
- window.location.reload();
- return;
- }
- console.log("testMoveBookmarks2");
- chrome.bookmarks.getChildren('0', function(root_children) {
- var bookmark_bar = root_children[0]; // bookmarks bar is always first
- chrome.bookmarks.getChildren(bookmark_bar.id, function(bar_children) {
- var folder_search = [];
- bar_children.forEach(function(child) {
- if (child.title == "folder" && child.url == undefined) {
- folder_search.push(child);
- }
- });
- if (folder_search.length == 1) {
- console.log('moving children out of "folder"');
- var folder = folder_search[0];
- chrome.bookmarks.getChildren(folder_search[0].id,
- function(folder_children) {
- folder_children.forEach(function(child) {
- chrome.bookmarks.move(child.id,
- {'parentId': bookmark_bar.id});
- });
- });
- chrome.bookmarks.remove(folder.id);
- } else if (folder_search.length == 0) {
- console.log('creating "folder" and moving children into it');
- chrome.bookmarks.create({'parentId': bookmark_bar.id,
- 'title': 'folder'},
- function(folder) {
- chrome.bookmarks.search("oog", function(oog_search) {
- oog_search.forEach(function(oog_match) {
- chrome.bookmarks.move(oog_match.id,
- {'parentId': folder.id})
- });
- });
- });
- } else {
- console.log("my puny code wasn't written to handle this");
- }
- });
- });
-};
-
-var dumpBookmarks = function(event) {
- chrome.tabs.create({url:"bookmark_view.html"});
-};
-</script>
-<body>
-<div class="toolstrip-button" onclick="dumpBookmarks(window.event);">
-<span>Dump Bookmarks</span>
-</div>
-<div class="toolstrip-button" onclick="testMoveBookmarks(window.event);">
-<span>Test Move</span>
-</div>
-</body>
-</html>
diff --git a/chrome/test/data/extensions/samples/bookmarks/bookmark_view.html b/chrome/test/data/extensions/samples/bookmarks/bookmark_view.html
deleted file mode 100644
index 163f2e4..0000000
--- a/chrome/test/data/extensions/samples/bookmarks/bookmark_view.html
+++ /dev/null
@@ -1,152 +0,0 @@
-<!DOCTYPE HTML>
-<title>Bookmark View</title>
-<style>
-
-.bookmark {
- margin-left: 5px;
- padding: 2px;
-}
-
-.bookmark_title {
- display: inline;
- border: 1px solid white;
- padding: 0px 3px;
-}
-
-.bookmark_title:hover {
- background-color: silver;
- border: 1px solid black;
-}
-
-.event-log {
- font-family: monospace;
-}
-
-ul {
- padding-left: 10px;
-}
-
-</style>
-<script>
-// XXX Hack: When you call window.open('chrome-extension://...'), the window is
-// first navigated to about:blank, and then to the final URL. This confuses the
-// code that sets up our v8 extensions, and we don't end up with them running.
-//
-// If we noticed this happened, reload ourselves, which should fix it.
-if (!chrome.bookmarks)
- location.reload();
-
-var logEvent = function(name, id, data) {
- var log = document.getElementById("event-log");
- log.innerHTML = name + ": " + id + ", " + JSON.stringify(data) + "<br>" +
- log.innerHTML;
- console.log("got event: " + name);
-}
-
-chrome.bookmarks.onCreated.addListener(function(id, data) {
- logEvent("onBookmarkCreated", id, data);
-});
-
-chrome.bookmarks.onRemoved.addListener(function(id, data) {
- logEvent("onBookmarkRemoved", id, data);
-});
-
-chrome.bookmarks.onChanged.addListener(function(id, data) {
- logEvent("onBookmarkChanged", id, data);
-});
-
-chrome.bookmarks.onMoved.addListener(function(id, data) {
- logEvent("onBookmarkMoved", id, data);
-});
-
-chrome.bookmarks.onChildrenReordered.addListener(function(id, data) {
- logEvent("onBookmarkChildrenReordered", id, data);
-});
-
-var prefix = "bookmark_";
-
-var toggleBookmark = function(event) {
- event.stopPropagation();
- var node = event.currentTarget;
- var id_str = node.id;
- if (id_str < prefix.length)
- return;
- var id = id_str.substring(prefix.length);
- console.log("toggle: " + id);
- //console.dir(event);
- if (node.childNodes.length > 1) {
- var i = 0;
- while (node.childNodes.length > i) {
- var child = node.childNodes.item(i);
- if (child.tagName == "UL")
- node.removeChild(child);
- else
- i++;
- }
- } else {
- chrome.bookmarks.getChildren(id, function(children) {
- console.dir(children);
- addBookmarks(children, node);
- });
- }
-};
-
-var addBookmark = function(bookmark, parent) {
- var child = document.createElement('li');
- child.className = 'bookmark';
- child.id = prefix + bookmark.id;
- child.addEventListener('click', toggleBookmark, false);
- var text = bookmark.title;
- if (bookmark.dateAdded)
- text += " (" + new Date(bookmark.dateAdded) + ")";
- if (bookmark.url && bookmark.url.length) {
- var link = document.createElement('a');
- link.href = bookmark.url;
- link.innerHTML = text;
- link.className = 'bookmark_title';
- child.appendChild(link);
- } else {
- var title = document.createElement('div');
- title.innerHTML = text;
- title.className = 'bookmark_title';
- child.appendChild(title);
- }
- parent.appendChild(child);
-};
-
-var addBookmarks = function(bookmarks, parent) {
- console.log("addBookmarks " + parent.id);
- var list = document.createElement("ul");
- parent.appendChild(list);
- bookmarks.forEach(function(bookmark) { addBookmark(bookmark, list); });
-};
-
-var testGetTree = function(results) {
- console.log("testGetTree:");
- console.dir(results);
- function get_children(node) {
- console.log(node.title);
- node.children.forEach(get_children);
- };
- results.forEach(get_children);
-};
-
-var loadBookmarks = function() {
- var container = document.getElementById('container');
- var rootElement = document.createElement("div");
- var rootId = '0';
- rootElement.id = prefix + rootId;
- // root element is empty / invisible, just an id to be looked up
- container.appendChild(rootElement);
- chrome.bookmarks.getChildren(rootId, function(children) {
- addBookmarks(children, rootElement);
- });
- chrome.bookmarks.getTree(testGetTree);
-};
-
-</script>
-<body onload="loadBookmarks()">
-<div id="container">
-</div>
-<div id="event-log"></div>
-</body>
diff --git a/chrome/test/data/extensions/samples/bookmarks/manifest.json b/chrome/test/data/extensions/samples/bookmarks/manifest.json
deleted file mode 100644
index c6319e8..0000000
--- a/chrome/test/data/extensions/samples/bookmarks/manifest.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "BookmarksAPI",
- "description": "Bookmarks API test",
- "version": "0.1",
- "toolstrips": ["bookmark_api.html"],
- "permissions": ["bookmarks"]
-}