| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "chrome/common/chrome_paths.h" | 8 #include "chrome/common/chrome_paths.h" |
| 9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
| 10 #include "chrome/renderer/extensions/extension_process_bindings.h" | 10 #include "chrome/renderer/extensions/extension_process_bindings.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // same way. | 64 // same way. |
| 65 TEST_F(ExtensionAPIClientTest, CallbackDispatching) { | 65 TEST_F(ExtensionAPIClientTest, CallbackDispatching) { |
| 66 ExecuteJavaScript( | 66 ExecuteJavaScript( |
| 67 "function assert(truth, message) {" | 67 "function assert(truth, message) {" |
| 68 " if (!truth) {" | 68 " if (!truth) {" |
| 69 " throw new Error(message);" | 69 " throw new Error(message);" |
| 70 " }" | 70 " }" |
| 71 "}" | 71 "}" |
| 72 "function callback(result) {" | 72 "function callback(result) {" |
| 73 " assert(typeof result == 'object', 'result not object');" | 73 " assert(typeof result == 'object', 'result not object');" |
| 74 " assert(goog.json.serialize(result) == '{\"foo\":\"bar\"}', " | 74 " assert(JSON.stringify(result) == '{\"foo\":\"bar\"}', " |
| 75 " 'incorrect result');" | 75 " 'incorrect result');" |
| 76 " console.log('pass')" | 76 " console.log('pass')" |
| 77 "}" | 77 "}" |
| 78 "chrome.tabs.create({}, callback);" | 78 "chrome.tabs.create({}, callback);" |
| 79 ); | 79 ); |
| 80 | 80 |
| 81 EXPECT_EQ("", GetConsoleMessage()); | 81 EXPECT_EQ("", GetConsoleMessage()); |
| 82 | 82 |
| 83 // Ok, we should have gotten a message to create a tab, grab the callback ID. | 83 // Ok, we should have gotten a message to create a tab, grab the callback ID. |
| 84 const IPC::Message* request_msg = | 84 const IPC::Message* request_msg = |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 "SetBookmarkTitle", | 471 "SetBookmarkTitle", |
| 472 "{\"id\":42,\"title\":\"x\"}"); | 472 "{\"id\":42,\"title\":\"x\"}"); |
| 473 } | 473 } |
| 474 | 474 |
| 475 TEST_F(ExtensionAPIClientTest, EnablePageAction) { | 475 TEST_F(ExtensionAPIClientTest, EnablePageAction) { |
| 476 ExpectJsPass("chrome.pageActions.enableForTab(" | 476 ExpectJsPass("chrome.pageActions.enableForTab(" |
| 477 "\"dummy\", {tabId: 0, url: \"http://foo/\"});", | 477 "\"dummy\", {tabId: 0, url: \"http://foo/\"});", |
| 478 "EnablePageAction", | 478 "EnablePageAction", |
| 479 "[\"dummy\",{\"tabId\":0,\"url\":\"http://foo/\"}]"); | 479 "[\"dummy\",{\"tabId\":0,\"url\":\"http://foo/\"}]"); |
| 480 } | 480 } |
| OLD | NEW |