summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/extensions/api_test/clipboard/manifest.json13
-rw-r--r--chrome/test/data/extensions/api_test/clipboard/test.html1
-rw-r--r--chrome/test/data/extensions/api_test/clipboard/test.js64
-rw-r--r--chrome/test/data/extensions/api_test/clipboard/test_helper.js10
4 files changed, 88 insertions, 0 deletions
diff --git a/chrome/test/data/extensions/api_test/clipboard/manifest.json b/chrome/test/data/extensions/api_test/clipboard/manifest.json
new file mode 100644
index 0000000..3f79bb5
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/clipboard/manifest.json
@@ -0,0 +1,13 @@
+{
+ "name": "chrome.clipboard",
+ "version": "0.1",
+ "description": "end-to-end browser test for chrome.experimental.clipboard API",
+ "background_page": "test.html",
+ "permissions": ["experimental", "tabs"],
+ "content_scripts": [
+ {
+ "matches": ["http://*/*"],
+ "js": ["test_helper.js"]
+ }
+ ]
+}
diff --git a/chrome/test/data/extensions/api_test/clipboard/test.html b/chrome/test/data/extensions/api_test/clipboard/test.html
new file mode 100644
index 0000000..46f4d74
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/clipboard/test.html
@@ -0,0 +1 @@
+<script src="test.js"></script>
diff --git a/chrome/test/data/extensions/api_test/clipboard/test.js b/chrome/test/data/extensions/api_test/clipboard/test.js
new file mode 100644
index 0000000..52f013d
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/clipboard/test.js
@@ -0,0 +1,64 @@
+// Clipboard API test for Chrome.
+// browser_tests.exe --gtest_filter=ExtensionApiTest.Clipboard
+
+const TEST_URL = "http://localhost:1337/files/extensions/test_file.html";
+
+function setupWindow(callback) {
+ chrome.tabs.getSelected(null, function(tab) {
+ chrome.tabs.update(tab.id, {"url": TEST_URL}, callback);
+ });
+}
+
+chrome.test.runTests([
+ function executeCopy() {
+ var onRequestCompleted = chrome.test.listenForever(
+ chrome.extension.onRequest,
+ function(request, sender, sendResponse) {
+ if (request == "start test") {
+ chrome.experimental.clipboard.executeCopy(
+ sender.tab.id,
+ chrome.test.callbackPass());
+ } else if (request == "copy event") {
+ onRequestCompleted();
+ } else {
+ chrome.test.fail("Unexpected request: " + JSON.stringify(request));
+ }
+ }
+ );
+ setupWindow();
+ },
+ function executeCut() {
+ var onRequestCompleted = chrome.test.listenForever(
+ chrome.extension.onRequest,
+ function(request, sender, sendResponse) {
+ if (request == "start test") {
+ chrome.experimental.clipboard.executeCut(
+ sender.tab.id,
+ chrome.test.callbackPass());
+ } else if (request == "cut event") {
+ onRequestCompleted();
+ } else {
+ chrome.test.fail("Unexpected request: " + JSON.stringify(request));
+ }
+ }
+ );
+ setupWindow();
+ },
+ function executePaste() {
+ var onRequestCompleted = chrome.test.listenForever(
+ chrome.extension.onRequest,
+ function(request, sender, sendResponse) {
+ if (request == "start test") {
+ chrome.experimental.clipboard.executePaste(
+ sender.tab.id,
+ chrome.test.callbackPass());
+ } else if (request == "paste event") {
+ onRequestCompleted();
+ } else {
+ chrome.test.fail("Unexpected request: " + JSON.stringify(request));
+ }
+ }
+ );
+ setupWindow();
+ }
+]);
diff --git a/chrome/test/data/extensions/api_test/clipboard/test_helper.js b/chrome/test/data/extensions/api_test/clipboard/test_helper.js
new file mode 100644
index 0000000..c38f5f8
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/clipboard/test_helper.js
@@ -0,0 +1,10 @@
+document.addEventListener("copy", function() {
+ chrome.extension.sendRequest("copy event");
+}, false);
+document.addEventListener("cut", function() {
+ chrome.extension.sendRequest("cut event");
+}, false);
+document.addEventListener("paste", function() {
+ chrome.extension.sendRequest("paste event");
+}, false);
+chrome.extension.sendRequest("start test");