Index: chrome/test/data/extensions/api_test/clipboard/extension/test.js |
diff --git a/chrome/test/data/extensions/api_test/clipboard/extension/test.js b/chrome/test/data/extensions/api_test/clipboard/extension/test.js |
index 8432db7e2ab10bcc7c07459a16fd54de9b085463..aef5c502712bd7dd1e6de29162f37368914a5b33 100644 |
--- a/chrome/test/data/extensions/api_test/clipboard/extension/test.js |
+++ b/chrome/test/data/extensions/api_test/clipboard/extension/test.js |
@@ -5,18 +5,55 @@ |
// Clipboard permission test for Chrome. |
// browser_tests.exe --gtest_filter=ClipboardApiTest.Extension |
-chrome.test.runTests([ |
- function domCopy() { |
- if (document.execCommand('copy')) |
- chrome.test.succeed(); |
- else |
- chrome.test.fail('execCommand("copy") failed'); |
- }, |
- function domPaste() { |
- if (document.execCommand('paste')) |
- chrome.test.succeed(); |
- else |
- chrome.test.fail('execCommand("paste") failed'); |
+// TODO(kalman): Consolidate this test script with the other clipboard tests. |
+ |
+var pass = chrome.test.callbackPass; |
+ |
+function testDomCopy() { |
+ if (document.execCommand('copy')) |
+ chrome.test.succeed(); |
+ else |
+ chrome.test.fail('execCommand("copy") failed'); |
+} |
+ |
+function testDomPaste() { |
+ if (document.execCommand('paste')) |
+ chrome.test.succeed(); |
+ else |
+ chrome.test.fail('execCommand("paste") failed'); |
+} |
+ |
+function testContentScriptCopyPaste(tabUrl) { |
+ function runContentScript(tabId) { |
+ var done = chrome.test.listenForever(chrome.runtime.onMessage, |
+ function(message, sender) { |
+ if (sender.tab.id == tabId) { |
+ chrome.tabs.remove(sender.tab.id); |
+ chrome.test.assertEq('', message); |
+ done(); |
+ chrome.test.succeed(); |
+ } |
+ }); |
+ chrome.tabs.executeScript(tabId, {file: 'content_script.js'}); |
} |
-]); |
+ chrome.tabs.create({url: tabUrl}, pass(function(newTab) { |
+ var done = chrome.test.listenForever(chrome.tabs.onUpdated, |
+ function(_, info, updatedTab) { |
+ if (updatedTab.id == newTab.id && info.status == 'complete') { |
+ runContentScript(newTab.id); |
+ done(); |
+ } |
+ }); |
+ })); |
+} |
+ |
+chrome.test.getConfig(function(config) { |
+ var tabUrl = 'http://localhost:' + config.testServer.port + |
+ '/extensions/test_file.html'; |
+ chrome.test.runTests([ |
+ testDomCopy, |
+ testDomPaste, |
+ testContentScriptCopyPaste.bind(null, tabUrl) |
+ ]); |
+}) |