diff options
author | brg@chromium.com <brg@chromium.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-17 20:41:58 +0000 |
---|---|---|
committer | brg@chromium.com <brg@chromium.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-17 20:41:58 +0000 |
commit | 4462559524df6726acc2400113508f3dc22b3648 (patch) | |
tree | 29986e90138219c2091482606685a0f6ddab6628 /chrome/test | |
parent | 6d37714b0e46f65b0418bc3d85f2d296bbbbdfa9 (diff) | |
download | chromium_src-4462559524df6726acc2400113508f3dc22b3648.zip chromium_src-4462559524df6726acc2400113508f3dc22b3648.tar.gz chromium_src-4462559524df6726acc2400113508f3dc22b3648.tar.bz2 |
Committing for dcheng@
Original review: http://codereview.chromium.org/882003
Review URL: http://codereview.chromium.org/1042004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41874 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
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"); |