diff options
110 files changed, 275 insertions, 417 deletions
diff --git a/chrome/browser/extensions/api/downloads/downloads_api.h b/chrome/browser/extensions/api/downloads/downloads_api.h index 3f42571..dafd4d4 100644 --- a/chrome/browser/extensions/api/downloads/downloads_api.h +++ b/chrome/browser/extensions/api/downloads/downloads_api.h @@ -33,7 +33,7 @@ class ResourceDispatcherHost; namespace download_extension_errors { -// Errors that can be returned through chrome.extension.lastError.message. +// Errors that can be returned through chrome.runtime.lastError.message. extern const char kGenericError[]; extern const char kIconNotFoundError[]; extern const char kInvalidDangerTypeError[]; diff --git a/chrome/browser/extensions/api/messaging/message_service.cc b/chrome/browser/extensions/api/messaging/message_service.cc index afc9407..af6bb51 100644 --- a/chrome/browser/extensions/api/messaging/message_service.cc +++ b/chrome/browser/extensions/api/messaging/message_service.cc @@ -211,7 +211,7 @@ void MessageService::OpenChannelToNativeApp( source_extension_id)); NativeMessageProcessHost::MessageType type = - channel_name == "chrome.extension.sendNativeMessage" ? + channel_name == "chrome.runtime.sendNativeMessage" ? NativeMessageProcessHost::TYPE_SEND_MESSAGE_REQUEST : NativeMessageProcessHost::TYPE_CONNECT; diff --git a/chrome/browser/extensions/api/messaging/message_service.h b/chrome/browser/extensions/api/messaging/message_service.h index 6e400dc..f4c691a 100644 --- a/chrome/browser/extensions/api/messaging/message_service.h +++ b/chrome/browser/extensions/api/messaging/message_service.h @@ -34,7 +34,7 @@ class LazyBackgroundTaskQueue; // Messaging works this way: // - An extension-owned script context (like a background page or a content // script) adds an event listener to the "onConnect" event. -// - Another context calls "extension.connect()" to open a channel to the +// - Another context calls "runtime.connect()" to open a channel to the // extension process, or an extension context calls "tabs.connect(tabId)" to // open a channel to the content scripts for the given tab. The EMS notifies // the target process/tab, which then calls the onConnect event in every diff --git a/chrome/browser/extensions/extension_bindings_apitest.cc b/chrome/browser/extensions/extension_bindings_apitest.cc index 4a017e6..4870054 100644 --- a/chrome/browser/extensions/extension_bindings_apitest.cc +++ b/chrome/browser/extensions/extension_bindings_apitest.cc @@ -20,7 +20,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ExceptionInHandlerShouldNotCrash) { } // Tests that an error raised during an async function still fires -// the callback, but sets chrome.extension.lastError. +// the callback, but sets chrome.runtime.lastError. IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, LastError) { ASSERT_TRUE(LoadExtension( test_data_dir_.AppendASCII("browsertest").AppendASCII("last_error"))); diff --git a/chrome/browser/resources/file_manager/js/file_copy_manager.js b/chrome/browser/resources/file_manager/js/file_copy_manager.js index 74435a2..a5fb156 100644 --- a/chrome/browser/resources/file_manager/js/file_copy_manager.js +++ b/chrome/browser/resources/file_manager/js/file_copy_manager.js @@ -916,9 +916,9 @@ FileCopyManager.prototype.serviceNextTaskEntry_ = function( function onFileTransferCompleted() { self.cancelCallback_ = null; - if (chrome.extension.lastError) { + if (chrome.runtime.lastError) { onFailTransfer({ - code: chrome.extension.lastError.message, + code: chrome.runtime.lastError.message, toGDrive: task.targetOnGData, sourceFileUrl: sourceFileUrl }); diff --git a/chrome/common/extensions/api/bluetooth.idl b/chrome/common/extensions/api/bluetooth.idl index cbc4414..3c200a5 100644 --- a/chrome/common/extensions/api/bluetooth.idl +++ b/chrome/common/extensions/api/bluetooth.idl @@ -156,7 +156,7 @@ namespace bluetooth { DeviceCallback deviceCallback; }; - // These functions all report failures via chrome.extension.lastError. + // These functions all report failures via chrome.runtime.lastError. interface Functions { // Get information about the Bluetooth adapter. // |callback| : Called with an AdapterState object describing the adapter diff --git a/chrome/common/extensions/api/context_menus.json b/chrome/common/extensions/api/context_menus.json index c4113ea..5f37e87 100644 --- a/chrome/common/extensions/api/context_menus.json +++ b/chrome/common/extensions/api/context_menus.json @@ -78,7 +78,7 @@ { "name": "create", "type": "function", - "description": "Creates a new context menu item. Note that if an error occurs during creation, you may not find out until the creation callback fires (the details will be in chrome.extension.lastError).", + "description": "Creates a new context menu item. Note that if an error occurs during creation, you may not find out until the creation callback fires (the details will be in chrome.runtime.lastError).", "returns": { "choices": [ { "type": "integer" }, @@ -170,7 +170,7 @@ "type": "function", "name": "callback", "optional": true, - "description": "Called when the item has been created in the browser. If there were any problems creating the item, details will be available in chrome.extension.lastError.", + "description": "Called when the item has been created in the browser. If there were any problems creating the item, details will be available in chrome.runtime.lastError.", "parameters": [] } ] diff --git a/chrome/common/extensions/api/cookies.json b/chrome/common/extensions/api/cookies.json index fd3a633..fc3e53f 100644 --- a/chrome/common/extensions/api/cookies.json +++ b/chrome/common/extensions/api/cookies.json @@ -118,7 +118,7 @@ "min_version": "11.0.674.0", "parameters": [ { - "name": "cookie", "$ref": "Cookie", "optional": true, "description": "Contains details about the cookie that's been set. If setting failed for any reason, this will be \"null\", and \"chrome.extension.lastError\" will be set." + "name": "cookie", "$ref": "Cookie", "optional": true, "description": "Contains details about the cookie that's been set. If setting failed for any reason, this will be \"null\", and \"chrome.runtime.lastError\" will be set." } ] } @@ -148,7 +148,7 @@ { "name": "details", "type": "object", - "description": "Contains details about the cookie that's been removed. If removal failed for any reason, this will be \"null\", and \"chrome.extension.lastError\" will be set.", + "description": "Contains details about the cookie that's been removed. If removal failed for any reason, this will be \"null\", and \"chrome.runtime.lastError\" will be set.", "optional": true, "properties": { "url": {"type": "string", "description": "The URL associated with the cookie that's been removed."}, diff --git a/chrome/common/extensions/api/extension.json b/chrome/common/extensions/api/extension.json index aa21140..ed97595 100644 --- a/chrome/common/extensions/api/extension.json +++ b/chrome/common/extensions/api/extension.json @@ -16,24 +16,6 @@ "tab": {"$ref": "tabs.Tab", "optional": true, "description":"This property will <b>only</b> be present when the connection was opened from a tab or content script."}, "id": {"type": "string", "description": "The extension ID of the extension that opened the connection."} } - }, - { - "id": "Port", - "nodoc": true, - "type": "object", - "description": "(Deprecated - use runtime.Port instead) An object which allows two way communication with other pages.", - "properties": { - "name": {"type": "string"}, - "onDisconnect": { "$ref": "events.Event" }, - "onMessage": { "$ref": "events.Event" }, - "postMessage": {"type": "function"}, - "sender": { - "$ref": "MessageSender", - "optional": true, - "description": "This property will <b>only</b> be present on ports passed to onConnect/onConnectExternal listeners." - } - }, - "additionalProperties": { "type": "any"} } ], "properties": { @@ -55,55 +37,6 @@ }, "functions": [ { - "name": "connect", - "nodoc": true, - "nocompile": true, - "type": "function", - "unprivileged": true, - "description": "(Deprecated - use runtime.connect) Attempts to connect to other listeners within the extension (such as the extension's background page). This is primarily useful for content scripts connecting to their extension processes. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via $ref:tabs.connect.", - "parameters": [ - {"type": "string", "name": "extensionId", "optional": true, "description": "The extension ID of the extension you want to connect to. If omitted, default is your own extension."}, - { - "type": "object", - "name": "connectInfo", - "properties": { - "name": { "type": "string", "optional": true, "description": "Will be passed into onConnect for extension processes that are listening for the connection event." } - }, - "optional": true - } - ], - "returns": { - "$ref": "Port", - "description": "Port through which messages can be sent and received with the extension. The port's $ref:extension.Port event is fired if extension does not exist. " - } - }, - { - "name": "connectNative", - "nodoc": true, - "nocompile": true, - "type": "function", - "description": "(Deprecated - use runtime.connectNative instead) Attempts to connect a native application in the host machine. The native application must have already registered itself in the proper directory.", - "parameters": [ - { - "type": "string", - "name": "appName", - "description": "The name of the registered app to connect to." - }, - { - "name": "connectionMessage", - "description": "The object that will be passed to the registered native app on connection.", - "type": "object", - "additionalProperties": { - "type": "any" - } - } - ], - "returns": { - "$ref": "Port", - "description": "Port through which messages can be sent and received with the application" - } - }, - { "name": "sendRequest", "nodoc": true, "type": "function", @@ -128,69 +61,6 @@ ] }, { - "name": "sendMessage", - "nodoc": true, - "nocompile": true, - "type": "function", - "allowAmbiguousOptionalArguments": true, - "unprivileged": true, - "description": "Sends a single message to other listeners within the extension. Similar to chrome.extension.connect, but only sends a single message with an optional response. The $ref:extension.onMessage event is fired in each extension page of the extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use $ref:tabs.sendMessage.", - "parameters": [ - {"type": "string", "name": "extensionId", "optional": true, "description": "The extension ID of the extension you want to connect to. If omitted, default is your own extension."}, - { "type": "any", "name": "message" }, - { - "type": "function", - "name": "responseCallback", - "optional": true, - "parameters": [ - { - "name": "response", - "type": "any", - "description": "The JSON response object sent by the handler of the message. If an error occurs while connecting to the extension, the callback will be called with no arguments and $ref:runtime.lastError will be set to the error message." - } - ] - } - ] - }, - { - "name": "sendNativeMessage", - "nodoc": true, - "nocompile": true, - "type": "function", - "description": "(Deprecated - use runtime.sendNativeMessage) Send a single message to a registered native application.", - "parameters": [ - { - "name": "registeredNativeApp", - "description": "The name of the registered native application.", - "type": "string" - }, - { - "name": "message", - "description": "The message that will be passed to the registered native application.", - "type": "object", - "additionalProperties": { - "type": "any" - } - }, - { - "type": "function", - "name": "callback", - "optional": true, - "description": "Called with the response from the native application.", - "parameters": [ - { - "name": "nativeResponse", - "type": "object", - "description": "Whatever the native application responds with.", - "additionalProperties": { - "type": "any" - } - } - ] - } - ] - }, - { "name": "getURL", "type": "function", "unprivileged": true, @@ -310,29 +180,6 @@ ], "events": [ { - "name": "onConnect", - "nodoc": true, - "nocompile": true, - "type": "function", - "unprivileged": true, - "anonymous": true, - "description": "Fired when a connection is made from either an extension process or a content script.", - "parameters": [ - {"$ref": "Port", "name": "port"} - ] - }, - { - "name": "onConnectExternal", - "nodoc": true, - "nocompile": true, - "type": "function", - "anonymous": true, - "description": "Fired when a connection is made from another extension.", - "parameters": [ - {"$ref": "Port", "name": "port"} - ] - }, - { "name": "onRequest", "nodoc": true, "type": "function", @@ -356,43 +203,6 @@ {"name": "sender", "$ref": "MessageSender" }, {"name": "sendResponse", "type": "function", "description": "Function to call when you have a response. The argument should be any JSON-ifiable object, or undefined if there is no response." } ] - }, - { - "name": "onMessage", - "nodoc": true, - "nocompile": true, - "type": "function", - "anonymous": true, - "unprivileged": true, - "description": "(Deprecated - use runtime.onMessage instead) Fired when a message is sent from either an extension process or a content script.", - "parameters": [ - {"name": "message", "type": "any", "description": "The message sent by the calling script."}, - {"name": "sender", "$ref": "MessageSender" }, - {"name": "sendResponse", "type": "function", "description": "Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one <code>onMessage</code> listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until <code>sendResponse</code> is called)." } - ], - "returns": { - "type": "boolean", - "optional": "true", - "description": "Return true from the event listener if you wish to call <code>sendResponse</code> after the event listener returns." - } - }, - { - "name": "onMessageExternal", - "nodoc": true, - "nocompile": true, - "type": "function", - "anonymous": true, - "description": "(Deprecated - use runtime.onMessageExternal instead) Fired when a message is sent from another extension. Cannot be used in a content script.", - "parameters": [ - {"name": "message", "type": "any", "description": "The message sent by the calling script."}, - {"name": "sender", "$ref": "MessageSender" }, - {"name": "sendResponse", "type": "function", "description": "Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one <code>onMessage</code> listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until <code>sendResponse</code> is called)." } - ], - "returns": { - "type": "boolean", - "optional": "true", - "description": "Return true from the event listener if you wish to call <code>sendResponse</code> after the event listener returns." - } } ] } diff --git a/chrome/common/extensions/api/extension_api_unittest.cc b/chrome/common/extensions/api/extension_api_unittest.cc index 18146e4..106656c 100644 --- a/chrome/common/extensions/api/extension_api_unittest.cc +++ b/chrome/common/extensions/api/extension_api_unittest.cc @@ -97,11 +97,11 @@ TEST(ExtensionAPI, IsPrivileged) { scoped_ptr<ExtensionAPI> extension_api( ExtensionAPI::CreateWithDefaultConfiguration()); - EXPECT_FALSE(extension_api->IsPrivileged("extension.connect")); - EXPECT_FALSE(extension_api->IsPrivileged("extension.onConnect")); + EXPECT_FALSE(extension_api->IsPrivileged("runtime.connect")); + EXPECT_FALSE(extension_api->IsPrivileged("runtime.onConnect")); // Properties are not supported yet. - EXPECT_TRUE(extension_api->IsPrivileged("extension.lastError")); + EXPECT_TRUE(extension_api->IsPrivileged("runtime.lastError")); // Default unknown names to privileged for paranoia's sake. EXPECT_TRUE(extension_api->IsPrivileged("")); diff --git a/chrome/common/extensions/api/file_browser_private.json b/chrome/common/extensions/api/file_browser_private.json index e5b15ef..087224e 100644 --- a/chrome/common/extensions/api/file_browser_private.json +++ b/chrome/common/extensions/api/file_browser_private.json @@ -837,7 +837,7 @@ "name": "callback", "type": "function", "optional": true, - "description": "Completion callback. chrome.extension.lastError will be set if there was an error.", + "description": "Completion callback. chrome.runtime.lastError will be set if there was an error.", "parameters": [] } ] @@ -884,7 +884,7 @@ "name": "callback", "type": "function", "optional": true, - "description": "Completion callback. chrome.extension.lastError will be set if there was an error.", + "description": "Completion callback. chrome.runtime.lastError will be set if there was an error.", "parameters": [] } ] diff --git a/chrome/common/extensions/api/input_ime.json b/chrome/common/extensions/api/input_ime.json index ae99ab5..939408b 100644 --- a/chrome/common/extensions/api/input_ime.json +++ b/chrome/common/extensions/api/input_ime.json @@ -91,7 +91,7 @@ "type": "function", "name": "callback", "optional": true, - "description": "Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.extension.lastError is set.", + "description": "Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.runtime.lastError is set.", "parameters": [ { "name": "success", @@ -120,7 +120,7 @@ "type": "function", "name": "callback", "optional": true, - "description": "Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.extension.lastError is set.", + "description": "Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.runtime.lastError is set.", "parameters": [ { "name": "success", @@ -153,7 +153,7 @@ "type": "function", "name": "callback", "optional": true, - "description": "Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.extension.lastError is set.", + "description": "Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.runtime.lastError is set.", "parameters": [ { "name": "success", diff --git a/chrome/common/extensions/api/tts.json b/chrome/common/extensions/api/tts.json index 601edbf..3b2abf2 100644 --- a/chrome/common/extensions/api/tts.json +++ b/chrome/common/extensions/api/tts.json @@ -169,7 +169,7 @@ "type": "function", "name": "callback", "optional": true, - "description": "Called right away, before speech finishes. Check chrome.extension.lastError to make sure there were no errors. Use options.onEvent to get more detailed feedback.", + "description": "Called right away, before speech finishes. Check chrome.runtime.lastError to make sure there were no errors. Use options.onEvent to get more detailed feedback.", "parameters": [] } ] diff --git a/chrome/common/extensions/api/webstore_private.json b/chrome/common/extensions/api/webstore_private.json index c128edc..49e10e4 100644 --- a/chrome/common/extensions/api/webstore_private.json +++ b/chrome/common/extensions/api/webstore_private.json @@ -56,7 +56,7 @@ { "name": "callback", "type": "function", - "description": "Called when the install process completes. Upon failures, chrome.extension.lastError will be set to 'user_canceled' or 'unknown_error'.", + "description": "Called when the install process completes. Upon failures, chrome.runtime.lastError will be set to 'user_canceled' or 'unknown_error'.", "optional": "true", "parameters": [] } diff --git a/chrome/common/extensions/docs/examples/api/debugger/live-headers/background.js b/chrome/common/extensions/docs/examples/api/debugger/live-headers/background.js index ad6595d..bba6065 100644 --- a/chrome/common/extensions/docs/examples/api/debugger/live-headers/background.js +++ b/chrome/common/extensions/docs/examples/api/debugger/live-headers/background.js @@ -15,8 +15,8 @@ function actionClicked(tab) { } function onAttach(tabId) { - if (chrome.extension.lastError) { - alert(chrome.extension.lastError.message); + if (chrome.runtime.lastError) { + alert(chrome.runtime.lastError.message); return; } diff --git a/chrome/common/extensions/docs/examples/api/debugger/pause-resume/background.js b/chrome/common/extensions/docs/examples/api/debugger/pause-resume/background.js index fb14127..3d6b032 100644 --- a/chrome/common/extensions/docs/examples/api/debugger/pause-resume/background.js +++ b/chrome/common/extensions/docs/examples/api/debugger/pause-resume/background.js @@ -28,8 +28,8 @@ function actionClicked(tab) { } function onAttach(debuggeeId) { - if (chrome.extension.lastError) { - alert(chrome.extension.lastError.message); + if (chrome.runtime.lastError) { + alert(chrome.runtime.lastError.message); return; } diff --git a/chrome/common/extensions/docs/examples/api/devtools/audits/broken-links/devtools.js b/chrome/common/extensions/docs/examples/api/devtools/audits/broken-links/devtools.js index bc406c9..5696dcd 100644 --- a/chrome/common/extensions/docs/examples/api/devtools/audits/broken-links/devtools.js +++ b/chrome/common/extensions/docs/examples/api/devtools/audits/broken-links/devtools.js @@ -27,4 +27,4 @@ category.onAuditStarted.addListener(function callback(auditResults) { } auditResults.done(); }); -});
\ No newline at end of file +}); diff --git a/chrome/common/extensions/docs/examples/api/eventPage/basic/background.js b/chrome/common/extensions/docs/examples/api/eventPage/basic/background.js index f94543f..ec6d68f 100644 --- a/chrome/common/extensions/docs/examples/api/eventPage/basic/background.js +++ b/chrome/common/extensions/docs/examples/api/eventPage/basic/background.js @@ -56,7 +56,7 @@ chrome.experimental.keybinding.onCommand.addListener(function(command) { chrome.tabs.create({url: "http://www.google.com/"}); }); -chrome.extension.onMessage.addListener(function(msg, _, sendResponse) { +chrome.runtime.onMessage.addListener(function(msg, _, sendResponse) { if (msg.setAlarm) { chrome.alarms.create({delayInMinutes: 0.1}); } else if (msg.delayedResponse) { diff --git a/chrome/common/extensions/docs/examples/api/eventPage/basic/content.js b/chrome/common/extensions/docs/examples/api/eventPage/basic/content.js index cf9c603..3bb880c 100644 --- a/chrome/common/extensions/docs/examples/api/eventPage/basic/content.js +++ b/chrome/common/extensions/docs/examples/api/eventPage/basic/content.js @@ -22,23 +22,23 @@ addButton("Clear logs", function() { }); addButton("Send message with delayed response", function() { - chrome.extension.sendMessage({delayedResponse: true}, function(response) { + chrome.runtime.sendMessage({delayedResponse: true}, function(response) { log("Background page responded: " + response); }); }); addButton("Show counters", function() { - chrome.extension.sendMessage({getCounters: true}, function(response) { + chrome.runtime.sendMessage({getCounters: true}, function(response) { log("In-memory counter is: " + response.counter); log("Persisted counter is: " + response.persistentCounter); }); }); addButton("Set an alarm", function() { - chrome.extension.sendMessage({setAlarm: true}); + chrome.runtime.sendMessage({setAlarm: true}); }); -chrome.extension.onMessage.addListener(function(msg, _, sendResponse) { +chrome.runtime.onMessage.addListener(function(msg, _, sendResponse) { log("Got message from background page: " + msg); }); diff --git a/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/contentscript.js b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/contentscript.js index 6fa03ec..db1f3b3 100644 --- a/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/contentscript.js +++ b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/contentscript.js @@ -1,8 +1,7 @@ -/* - * Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this - * source code is governed by a BSD-style license that can be found in the - * LICENSE file. - */ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + var regex = /sandwich/gi; matches = document.body.innerText.match(regex); if (matches) { @@ -10,4 +9,4 @@ if (matches) { count: matches.length // Pass the number of matches back. }; chrome.extension.sendRequest(payload, function(response) {}); -}
\ No newline at end of file +} diff --git a/chrome/common/extensions/docs/examples/api/messaging/timer/page.js b/chrome/common/extensions/docs/examples/api/messaging/timer/page.js index 92f8df3..bdbf9bf 100644 --- a/chrome/common/extensions/docs/examples/api/messaging/timer/page.js +++ b/chrome/common/extensions/docs/examples/api/messaging/timer/page.js @@ -1,4 +1,8 @@ -chrome.extension.onConnect.addListener(function(port) { +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +chrome.runtime.onConnect.addListener(function(port) { port.onMessage.addListener(function(msg) { port.postMessage({counter: msg.counter+1}); }); diff --git a/chrome/common/extensions/docs/examples/api/speechInput/basic/background.js b/chrome/common/extensions/docs/examples/api/speechInput/basic/background.js index 3093b6c..bd9b99a 100644 --- a/chrome/common/extensions/docs/examples/api/speechInput/basic/background.js +++ b/chrome/common/extensions/docs/examples/api/speechInput/basic/background.js @@ -14,9 +14,9 @@ chrome.browserAction.onClicked.addListener(function(tab) { chrome.experimental.speechInput.isRecording(function(recording) { if (!recording) { chrome.experimental.speechInput.start({}, function() { - if (chrome.extension.lastError) { + if (chrome.runtime.lastError) { alert("Couldn't start speech input: " + - chrome.extension.lastError.message); + chrome.runtime.lastError.message); setStartIcon(); } else { setStopIcon(); diff --git a/chrome/common/extensions/docs/examples/api/storage/stylizr/popup.js b/chrome/common/extensions/docs/examples/api/storage/stylizr/popup.js index c19b5c1..fe6b58d 100644 --- a/chrome/common/extensions/docs/examples/api/storage/stylizr/popup.js +++ b/chrome/common/extensions/docs/examples/api/storage/stylizr/popup.js @@ -15,7 +15,7 @@ storage.get('css', function(items) { // If there is CSS specified, inject it into the page. if (items.css) { chrome.tabs.insertCSS(null, {code: items.css}, function() { - if (chrome.extension.lastError) { + if (chrome.runtime.lastError) { message.innerText = 'Not allowed to inject CSS into special page.'; } else { message.innerText = 'Injected style!'; diff --git a/chrome/common/extensions/docs/examples/extensions/benchmark/background.js b/chrome/common/extensions/docs/examples/extensions/benchmark/background.js index 1d11a94..06915ea 100644 --- a/chrome/common/extensions/docs/examples/extensions/benchmark/background.js +++ b/chrome/common/extensions/docs/examples/extensions/benchmark/background.js @@ -412,7 +412,7 @@ function Benchmark() { }; } -chrome.extension.onConnect.addListener(function(port) { +chrome.runtime.onConnect.addListener(function(port) { port.onMessage.addListener(function(data) { if (data.message == "load") { var benchmark = findBenchmark(data.url); diff --git a/chrome/common/extensions/docs/examples/extensions/benchmark/script.js b/chrome/common/extensions/docs/examples/extensions/benchmark/script.js index b35213e..9d7dadd 100644 --- a/chrome/common/extensions/docs/examples/extensions/benchmark/script.js +++ b/chrome/common/extensions/docs/examples/extensions/benchmark/script.js @@ -1,5 +1,9 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + // The port for communicating back to the extension. -var benchmarkExtensionPort = chrome.extension.connect(); +var benchmarkExtensionPort = chrome.runtime.connect(); // The url is what this page is known to the benchmark as. // The benchmark uses this id to differentiate the benchmark's diff --git a/chrome/common/extensions/docs/examples/extensions/catifier/event_page.js b/chrome/common/extensions/docs/examples/extensions/catifier/event_page.js index 18b6460..2618fdc 100644 --- a/chrome/common/extensions/docs/examples/extensions/catifier/event_page.js +++ b/chrome/common/extensions/docs/examples/extensions/catifier/event_page.js @@ -47,8 +47,8 @@ function registerRules() { }; var callback = function() { - if (chrome.extension.lastError) { - console.error('Error adding rules: ' + chrome.extension.lastError); + if (chrome.runtime.lastError) { + console.error('Error adding rules: ' + chrome.runtime.lastError); } else { console.info('Rules successfully installed'); chrome.declarativeWebRequest.onRequest.getRules(null, @@ -70,8 +70,8 @@ function setup() { chrome.declarativeWebRequest.onRequest.removeRules( null, function() { - if (chrome.extension.lastError) { - console.error('Error clearing rules: ' + chrome.extension.lastError); + if (chrome.runtime.lastError) { + console.error('Error clearing rules: ' + chrome.runtime.lastError); } else { registerRules(); } diff --git a/chrome/common/extensions/docs/examples/extensions/email_this_page/background.js b/chrome/common/extensions/docs/examples/extensions/email_this_page/background.js index a0fd3c3..a16ef80 100644 --- a/chrome/common/extensions/docs/examples/extensions/email_this_page/background.js +++ b/chrome/common/extensions/docs/examples/extensions/email_this_page/background.js @@ -42,7 +42,7 @@ function executeMailto(tab_id, subject, body, selection) { } } -chrome.extension.onConnect.addListener(function(port) { +chrome.runtime.onConnect.addListener(function(port) { var tab = port.sender.tab; // This will get called by the content script we execute in diff --git a/chrome/common/extensions/docs/examples/extensions/email_this_page/content_script.js b/chrome/common/extensions/docs/examples/extensions/email_this_page/content_script.js index fc0ef93..08744ef 100644 --- a/chrome/common/extensions/docs/examples/extensions/email_this_page/content_script.js +++ b/chrome/common/extensions/docs/examples/extensions/email_this_page/content_script.js @@ -1,12 +1,10 @@ -/* - * Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this - * source code is governed by a BSD-style license that can be found in the - * LICENSE file. - */ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. var additionalInfo = { "title": document.title, "selection": window.getSelection().toString() }; -chrome.extension.connect().postMessage(additionalInfo); +chrome.runtime.connect().postMessage(additionalInfo); diff --git a/chrome/common/extensions/docs/examples/extensions/native_messaging/popup.js b/chrome/common/extensions/docs/examples/extensions/native_messaging/popup.js index 07757e1..30f8778 100644 --- a/chrome/common/extensions/docs/examples/extensions/native_messaging/popup.js +++ b/chrome/common/extensions/docs/examples/extensions/native_messaging/popup.js @@ -14,7 +14,7 @@ function gotNativeMessage(message) { function sendNativeMessage() { if (!port) { - port = chrome.extension.connectNative('echo.py', {"message": "Hi there!"}); + port = chrome.runtime.connectNative('echo.py', {"message": "Hi there!"}); port.onMessage.addListener(gotNativeMessage); document.getElementById('input-text').style.display = 'block'; document.getElementById('send-native-message').innerHTML = 'Send Message'; diff --git a/chrome/common/extensions/docs/examples/extensions/plugin_settings/js/chrome_stubs.js b/chrome/common/extensions/docs/examples/extensions/plugin_settings/js/chrome_stubs.js index 38b7514..51058d6 100644 --- a/chrome/common/extensions/docs/examples/extensions/plugin_settings/js/chrome_stubs.js +++ b/chrome/common/extensions/docs/examples/extensions/plugin_settings/js/chrome_stubs.js @@ -18,11 +18,11 @@ chrome.contentSettings.plugins = { var pattern = details.primaryPattern; var setting = details.setting; if (pattern == '__invalid_pattern') { - chrome.extension.lastError = {'message': 'Invalid pattern'}; + chrome.runtime.lastError = {'message': 'Invalid pattern'}; } else if (setting == '__invalid_setting') { throw Error('Invalid setting'); } else { - chrome.extension.lastError = undefined; + chrome.runtime.lastError = undefined; _rules[pattern] = setting; } callback(); diff --git a/chrome/common/extensions/docs/examples/extensions/plugin_settings/js/main.js b/chrome/common/extensions/docs/examples/extensions/plugin_settings/js/main.js index 89aeca6..d86c9f5 100644 --- a/chrome/common/extensions/docs/examples/extensions/plugin_settings/js/main.js +++ b/chrome/common/extensions/docs/examples/extensions/plugin_settings/js/main.js @@ -9,9 +9,9 @@ document.addEventListener('DOMContentLoaded', function() { chrome.contentSettings.plugins.getResourceIdentifiers(function(r) { - if (chrome.extension.lastError) { + if (chrome.runtime.lastError) { $('error').textContent = - 'Error: ' + chrome.extension.lastError.message; + 'Error: ' + chrome.runtime.lastError.message; return; } var pluginList = $('plugin-list'); diff --git a/chrome/common/extensions/docs/examples/extensions/plugin_settings/js/plugin_settings.js b/chrome/common/extensions/docs/examples/extensions/plugin_settings/js/plugin_settings.js index 253240d..fadf7cf 100644 --- a/chrome/common/extensions/docs/examples/extensions/plugin_settings/js/plugin_settings.js +++ b/chrome/common/extensions/docs/examples/extensions/plugin_settings/js/plugin_settings.js @@ -51,7 +51,7 @@ cr.define('pluginSettings', function() { * @private */ didClearRules_: function(callback) { - if (chrome.extension.lastError) { + if (chrome.runtime.lastError) { console.error('Error clearing rules'); callback(); return; @@ -95,10 +95,10 @@ cr.define('pluginSettings', function() { * @private */ didSetContentSetting_: function(plugin, pattern, key, counter, callback) { - if (chrome.extension.lastError) { + if (chrome.runtime.lastError) { console.error( 'Error restoring [' + key + ': ' + value + ']: ' + - chrome.extension.lastError.message); + chrome.runtime.lastError.message); window.localStorage.removeItem(key); } counter.value--; @@ -124,8 +124,8 @@ cr.define('pluginSettings', function() { 'resourceIdentifier': { 'id': plugin }, 'setting': setting, }, function() { - if (chrome.extension.lastError) { - callback(chrome.extension.lastError.message); + if (chrome.runtime.lastError) { + callback(chrome.runtime.lastError.message); } else { window.localStorage.setItem(JSON.stringify([plugin, pattern]), setting); diff --git a/chrome/common/extensions/docs/examples/extensions/proxy_configuration/proxy_form_controller.js b/chrome/common/extensions/docs/examples/extensions/proxy_configuration/proxy_form_controller.js index 80f909b..26c70dc 100644 --- a/chrome/common/extensions/docs/examples/extensions/proxy_configuration/proxy_form_controller.js +++ b/chrome/common/extensions/docs/examples/extensions/proxy_configuration/proxy_form_controller.js @@ -524,7 +524,7 @@ ProxyFormController.prototype = { * @private */ callbackForRegularSettings_: function() { - if (chrome.extension.lastError) { + if (chrome.runtime.lastError) { this.generateAlert_(chrome.i18n.getMessage('errorSettingRegularProxy')); return; } @@ -545,7 +545,7 @@ ProxyFormController.prototype = { * @private */ callbackForIncognitoSettings_: function() { - if (chrome.extension.lastError) { + if (chrome.runtime.lastError) { this.generateAlert_(chrome.i18n.getMessage('errorSettingIncognitoProxy')); return; } diff --git a/chrome/common/extensions/docs/examples/extensions/talking_alarm_clock/background.js b/chrome/common/extensions/docs/examples/extensions/talking_alarm_clock/background.js index ae94ff8..38c5917 100644 --- a/chrome/common/extensions/docs/examples/extensions/talking_alarm_clock/background.js +++ b/chrome/common/extensions/docs/examples/extensions/talking_alarm_clock/background.js @@ -114,7 +114,7 @@ function onLocalStorageChange() { function initBackground() { window.addEventListener('storage', onLocalStorageChange, false); - chrome.extension.onConnect.addListener(function(popupPort) { + chrome.runtime.onConnect.addListener(function(popupPort) { port = popupPort; port.onDisconnect.addListener(function() { port = null; diff --git a/chrome/common/extensions/docs/examples/extensions/talking_alarm_clock/popup.js b/chrome/common/extensions/docs/examples/extensions/talking_alarm_clock/popup.js index 1f0bf06..30b8085 100644 --- a/chrome/common/extensions/docs/examples/extensions/talking_alarm_clock/popup.js +++ b/chrome/common/extensions/docs/examples/extensions/talking_alarm_clock/popup.js @@ -190,7 +190,7 @@ function addOutlineStyleListeners() { function load() { try { - port = chrome.extension.connect(); + port = chrome.runtime.connect(); port.onMessage.addListener(function(msg) { if (msg.cmd == 'anim') { displayAlarmAnimation(); diff --git a/chrome/common/extensions/docs/examples/extensions/ttsdemo/ttsdemo.js b/chrome/common/extensions/docs/examples/extensions/ttsdemo/ttsdemo.js index d4e0a6f..85ee27d 100644 --- a/chrome/common/extensions/docs/examples/extensions/ttsdemo/ttsdemo.js +++ b/chrome/common/extensions/docs/examples/extensions/ttsdemo/ttsdemo.js @@ -86,8 +86,8 @@ function speak(str, options, highlightText) { }; chrome.tts.speak( str, options, function() { - if (chrome.extension.lastError) { - console.log('TTS Error: ' + chrome.extension.lastError.message); + if (chrome.runtime.lastError) { + console.log('TTS Error: ' + chrome.runtime.lastError.message); } }); ttsStatus.innerHTML = 'Busy'; diff --git a/chrome/common/extensions/docs/templates/articles/content_scripts.html b/chrome/common/extensions/docs/templates/articles/content_scripts.html index ec10423..5cbb2be 100644 --- a/chrome/common/extensions/docs/templates/articles/content_scripts.html +++ b/chrome/common/extensions/docs/templates/articles/content_scripts.html @@ -342,7 +342,7 @@ button.addEventListener("click", function() { <p>An example can be accomplished using window.postMessage (or window.webkitPostMessage for Transferable objects):</p> <pre>contentscript.js ================ -var port = chrome.extension.connect(); +var port = chrome.runtime.connect(); window.addEventListener("message", function(event) { // We only accept messages from ourselves diff --git a/chrome/common/extensions/docs/templates/articles/manifestVersion.html b/chrome/common/extensions/docs/templates/articles/manifestVersion.html index 35fbe3a..b3c7563 100644 --- a/chrome/common/extensions/docs/templates/articles/manifestVersion.html +++ b/chrome/common/extensions/docs/templates/articles/manifestVersion.html @@ -220,7 +220,7 @@ <li> <p> <code>Port.tab</code> is gone. Use - $ref:extension.Port + $ref:runtime.Port instead. </p> </li> diff --git a/chrome/common/extensions/docs/templates/articles/whats_new.html b/chrome/common/extensions/docs/templates/articles/whats_new.html index 4d92fbe..1588f74 100644 --- a/chrome/common/extensions/docs/templates/articles/whats_new.html +++ b/chrome/common/extensions/docs/templates/articles/whats_new.html @@ -115,7 +115,7 @@ made in recent releases. <li>The <code>sendRequest()</code> method has been deprecated in favor of the <code>sendMessage()</code> method for both the - $ref:extension.sendMessage and + $ref:runtime.sendMessage and $ref:tabs.sendMessage.</li> <li>The <a href="external_extensions.html">external_extensions.json file</a> has been deprecated in favor of individual diff --git a/chrome/common/extensions/docs/templates/intros/experimental_speechInput.html b/chrome/common/extensions/docs/templates/intros/experimental_speechInput.html index 9c9f994..1db1334 100644 --- a/chrome/common/extensions/docs/templates/intros/experimental_speechInput.html +++ b/chrome/common/extensions/docs/templates/intros/experimental_speechInput.html @@ -22,13 +22,13 @@ For example:</p> <h2 id="howToStart">How to start speech recognition</h2> <p>To start recognizing speech an extension must call the <code>start()</code> method. If provided, your callback will be called once recording has -successfully started. In case of error <code>chrome.extension.lastError</code> +successfully started. In case of error <code>chrome.runtime.lastError</code> will be set.</p> <p>This API provides exclusive access to the default recording device to the first extension requesting it. Consequently, any calls to <code>start()</code> when the device is being used by another extension or web page will fail and set -<code>chrome.extension.lastError</code>. The message <code>requestDenied</code> +<code>chrome.runtime.lastError</code>. The message <code>requestDenied</code> will be set if another extension in the same profile is making use of the API. Otherwise <code>noRecordingDeviceFound</code>, <code>recordingDeviceInUse</code> or <code>unableToStart</code> will be set depending on the situation.</p> @@ -71,7 +71,7 @@ It is safe to call <code>start()</code> again from the error callback.</p> <h2 id="howToStop">How to stop recording</h2> <p>To stop speech recognition call the <code>stop()</code> method. If provided, the callback function will be called once recording has successfully stopped. -In case of error <code>chrome.extension.lastError</code> will be set. +In case of error <code>chrome.runtime.lastError</code> will be set. </p> @@ -90,8 +90,8 @@ continued period of silence). most likely recognition result.</p> <pre> function checkStart() { - if (chrome.extension.lastError) { - alert("Couldn't start speech input: " + chrome.extension.lastError.message); + if (chrome.runtime.lastError) { + alert("Couldn't start speech input: " + chrome.runtime.lastError.message); } } @@ -106,4 +106,4 @@ function recognitionSucceeded(result) { chrome.experimental.speechInput.onError.addListener(recognitionFailed); chrome.experimental.speechInput.onResult.addListener(recognitionSucceeded); chrome.experimental.speechInput.start({ "language": "en" }, checkStart); -</pre>
\ No newline at end of file +</pre> diff --git a/chrome/common/extensions/docs/templates/intros/privacy.html b/chrome/common/extensions/docs/templates/intros/privacy.html index c7657ea..2a80ae5 100644 --- a/chrome/common/extensions/docs/templates/intros/privacy.html +++ b/chrome/common/extensions/docs/templates/intros/privacy.html @@ -73,10 +73,10 @@ <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { if (details.levelOfControl === 'controllable_by_this_extension') { chrome.privacy.services.autofillEnabled.set({ value: true }, function() { - if (chrome.extension.lastError === undefined) + if (chrome.runtime.lastError === undefined) console.log("Hooray, it worked!"); else - console.log("Sadness!", chrome.extension.lastError); + console.log("Sadness!", chrome.runtime.lastError); } } });</pre> @@ -179,10 +179,10 @@ <pre>chrome.privacy.services.autofillEnabled.get({}, function(details) { if (details.levelOfControl === 'controllable_by_this_extension') { chrome.privacy.services.autofillEnabled.set({ value: true }, function() { - if (chrome.extension.lastError === undefined) + if (chrome.runtime.lastError === undefined) console.log("Hooray, it worked!"); else - console.log("Sadness!", chrome.extension.lastError); + console.log("Sadness!", chrome.runtime.lastError); } } });</pre> @@ -206,4 +206,4 @@ <p> For example code, see the <a href="samples.html#privacy">Privacy API samples</a>. -</p>
\ No newline at end of file +</p> diff --git a/chrome/common/extensions/docs/templates/intros/tts.html b/chrome/common/extensions/docs/templates/intros/tts.html index 1dfaca8..a7387d6 100644 --- a/chrome/common/extensions/docs/templates/intros/tts.html +++ b/chrome/common/extensions/docs/templates/intros/tts.html @@ -87,8 +87,8 @@ to see if there were any errors.</p> utterance, options, function() { - if (chrome.extension.lastError) { - console.log('Error: ' + chrome.extension.lastError.message); + if (chrome.runtime.lastError) { + console.log('Error: ' + chrome.runtime.lastError.message); } });</pre> @@ -202,4 +202,4 @@ argument:</p> console.log(' extension id: ' + voices[i].extensionId); console.log(' event types: ' + voices[i].eventTypes); } - });</pre>
\ No newline at end of file + });</pre> diff --git a/chrome/renderer/extensions/miscellaneous_bindings.cc b/chrome/renderer/extensions/miscellaneous_bindings.cc index 18a6c2ca..deb9c45 100644 --- a/chrome/renderer/extensions/miscellaneous_bindings.cc +++ b/chrome/renderer/extensions/miscellaneous_bindings.cc @@ -26,7 +26,7 @@ // Message passing API example (in a content script): // var extension = // new chrome.Extension('00123456789abcdef0123456789abcdef0123456'); -// var port = extension.connect(); +// var port = runtime.connect(); // port.postMessage('Can you hear me now?'); // port.onmessage.addListener(function(msg, port) { // alert('response=' + msg); diff --git a/chrome/renderer/resources/extensions/extension_custom_bindings.js b/chrome/renderer/resources/extensions/extension_custom_bindings.js index a4145f3..4311ee9 100644 --- a/chrome/renderer/resources/extensions/extension_custom_bindings.js +++ b/chrome/renderer/resources/extensions/extension_custom_bindings.js @@ -70,16 +70,23 @@ chromeHidden.registerCustomHook('extension', }); // Alias several messaging deprecated APIs to their runtime counterparts. - chrome.extension.connect = chrome.runtime.connect; - chrome.extension.sendMessage = chrome.runtime.sendMessage; - chrome.extension.onConnect = chrome.runtime.onConnect; - chrome.extension.onMessage = chrome.runtime.onMessage; - if (contextType == 'BLESSED_EXTENSION') { - chrome.extension.connectNative = chrome.runtime.connectNative; - chrome.extension.sendNativeMessage = chrome.runtime.sendNativeMessage; - chrome.extension.onConnectExternal = chrome.runtime.onConnectExternal; - chrome.extension.onMessageExternal = chrome.runtime.onMessageExternal; - } + var mayNeedAlias = [ + // Types + 'Port', + // Functions + 'connect', 'sendMessage', 'connectNative', 'sendNativeMessage', + // Events + 'onConnect', 'onConnectExternal', 'onMessage', 'onMessageExternal' + ]; + mayNeedAlias.forEach(function(alias) { + try { + // Deliberately accessing runtime[alias] rather than testing its + // existence, since accessing may throw an exception if this context + // doesn't have access. + if (chrome.runtime[alias]) + chrome.extension[alias] = chrome.runtime[alias]; + } catch(e) {} + }); apiFunctions.setUpdateArgumentsPreValidate('sendRequest', sendMessageUpdateArguments.bind(null, 'sendRequest')); diff --git a/chrome/renderer/resources/extensions/miscellaneous_bindings.js b/chrome/renderer/resources/extensions/miscellaneous_bindings.js index 9904e8c..5663271 100644 --- a/chrome/renderer/resources/extensions/miscellaneous_bindings.js +++ b/chrome/renderer/resources/extensions/miscellaneous_bindings.js @@ -255,7 +255,7 @@ } }; - // Shared implementation used by tabs.sendMessage and extension.sendMessage. + // Shared implementation used by tabs.sendMessage and runtime.sendMessage. chromeHidden.Port.sendMessageImpl = function(port, request, responseCallback) { if (port.name != chromeHidden.kNativeMessageChannel) diff --git a/chrome/renderer/resources/extensions/runtime_custom_bindings.js b/chrome/renderer/resources/extensions/runtime_custom_bindings.js index e1c2ffb..c5e63ac 100644 --- a/chrome/renderer/resources/extensions/runtime_custom_bindings.js +++ b/chrome/renderer/resources/extensions/runtime_custom_bindings.js @@ -47,7 +47,7 @@ chromeHidden.registerCustomHook('runtime', function(bindings, id, contextType) { apiFunctions.setHandleRequest('sendNativeMessage', function(targetId, message, responseCallback) { - var port = chrome.extension.connectNative( + var port = chrome.runtime.connectNative( targetId, message, chromeHidden.kNativeMessageChannel); chromeHidden.Port.sendMessageImpl(port, '', responseCallback); }); diff --git a/chrome/test/data/devtools/extensions/devtools_messaging/background.js b/chrome/test/data/devtools/extensions/devtools_messaging/background.js index a4a449a..3ed120f 100644 --- a/chrome/test/data/devtools/extensions/devtools_messaging/background.js +++ b/chrome/test/data/devtools/extensions/devtools_messaging/background.js @@ -1,3 +1,7 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + function onRequest(request, sender, callback) { var response = JSON.stringify(request); callback("onRequest callback: " + response); @@ -13,4 +17,4 @@ function onConnect(port) { port.onMessage.addListener(onMessage.bind(null, port)); } -chrome.extension.onConnect.addListener(onConnect); +chrome.runtime.onConnect.addListener(onConnect); diff --git a/chrome/test/data/devtools/extensions/devtools_messaging/devtools.js b/chrome/test/data/devtools/extensions/devtools_messaging/devtools.js index bd094a9..56c2f14 100644 --- a/chrome/test/data/devtools/extensions/devtools_messaging/devtools.js +++ b/chrome/test/data/devtools/extensions/devtools_messaging/devtools.js @@ -1,3 +1,7 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + function output(msg) { chrome.devtools.inspectedWindow.eval("console.log(unescape('" + escape(msg) + "'));") @@ -38,7 +42,7 @@ function step3() { assertEquals("port.onMessage: foo", message); completeTest(); } - var port = chrome.extension.connect(); + var port = chrome.runtime.connect(); port.onMessage.addListener(onMessage); port.postMessage("foo"); } diff --git a/chrome/test/data/extensions/api_test/README.txt b/chrome/test/data/extensions/api_test/README.txt index 957526a..63006f4 100644 --- a/chrome/test/data/extensions/api_test/README.txt +++ b/chrome/test/data/extensions/api_test/README.txt @@ -61,7 +61,7 @@ chrome.test.runTests([ Note that chrome.test.callbackFail takes an argument which is the error message that it expects to get when the callback fails -(chrome.extension.lastError.message). +(chrome.runtime.lastError.message). Here's what the output of this test might look like: [==========] Running 1 test from 1 test case. diff --git a/chrome/test/data/extensions/api_test/content_scripts/bypass_page_csp/a.js b/chrome/test/data/extensions/api_test/content_scripts/bypass_page_csp/a.js index 7d72643..00c706f 100644 --- a/chrome/test/data/extensions/api_test/content_scripts/bypass_page_csp/a.js +++ b/chrome/test/data/extensions/api_test/content_scripts/bypass_page_csp/a.js @@ -5,10 +5,10 @@ // Inject an image. var img = document.createElement('img'); img.onload = function () { - chrome.extension.connect().postMessage(true); + chrome.runtime.connect().postMessage(true); }; img.onerror = function () { - chrome.extension.connect().postMessage(false); + chrome.runtime.connect().postMessage(false); }; img.src = 'icon3.png'; document.body.appendChild(img); diff --git a/chrome/test/data/extensions/api_test/content_scripts/bypass_page_csp/background.js b/chrome/test/data/extensions/api_test/content_scripts/bypass_page_csp/background.js index fbbeba1..c7837e6 100644 --- a/chrome/test/data/extensions/api_test/content_scripts/bypass_page_csp/background.js +++ b/chrome/test/data/extensions/api_test/content_scripts/bypass_page_csp/background.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -chrome.extension.onConnect.addListener(function(port) { +chrome.runtime.onConnect.addListener(function(port) { chrome.test.log("got connect"); port.onMessage.addListener(function(msg) { chrome.test.log("got message: " + msg); diff --git a/chrome/test/data/extensions/api_test/content_scripts/isolated_world1/background.js b/chrome/test/data/extensions/api_test/content_scripts/isolated_world1/background.js index bebbe80..c8293c8 100644 --- a/chrome/test/data/extensions/api_test/content_scripts/isolated_world1/background.js +++ b/chrome/test/data/extensions/api_test/content_scripts/isolated_world1/background.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -chrome.extension.onConnect.addListener(function(port) { +chrome.runtime.onConnect.addListener(function(port) { chrome.test.log("got connect"); port.onMessage.addListener(function(msg) { chrome.test.log("got message: " + msg); diff --git a/chrome/test/data/extensions/api_test/content_scripts/isolated_world1/c.js b/chrome/test/data/extensions/api_test/content_scripts/isolated_world1/c.js index d3bbc41..f393c4f 100644 --- a/chrome/test/data/extensions/api_test/content_scripts/isolated_world1/c.js +++ b/chrome/test/data/extensions/api_test/content_scripts/isolated_world1/c.js @@ -1,2 +1,6 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + // Send the variable defined by a.js and modified by b.js back to the extension. -chrome.extension.connect().postMessage(num); +chrome.runtime.connect().postMessage(num); diff --git a/chrome/test/data/extensions/api_test/content_scripts/isolated_world2/a.js b/chrome/test/data/extensions/api_test/content_scripts/isolated_world2/a.js index 394feee..05ec1ee 100644 --- a/chrome/test/data/extensions/api_test/content_scripts/isolated_world2/a.js +++ b/chrome/test/data/extensions/api_test/content_scripts/isolated_world2/a.js @@ -1,3 +1,7 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + // We should not be able to read the "num" variable which was defined in a.js // from the "isolated world 1" extension. -chrome.extension.connect().postMessage(typeof num == "undefined"); +chrome.runtime.connect().postMessage(typeof num == "undefined"); diff --git a/chrome/test/data/extensions/api_test/content_scripts/isolated_world2/background.js b/chrome/test/data/extensions/api_test/content_scripts/isolated_world2/background.js index 8ecc511..aad0e77 100644 --- a/chrome/test/data/extensions/api_test/content_scripts/isolated_world2/background.js +++ b/chrome/test/data/extensions/api_test/content_scripts/isolated_world2/background.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -chrome.extension.onConnect.addListener(function(port) { +chrome.runtime.onConnect.addListener(function(port) { chrome.test.log("got connect"); port.onMessage.addListener(function(msg) { chrome.test.log("got message: " + msg); diff --git a/chrome/test/data/extensions/api_test/context_menus/basics/test.js b/chrome/test/data/extensions/api_test/context_menus/basics/test.js index b1e5c1c..91eaa45 100644 --- a/chrome/test/data/extensions/api_test/context_menus/basics/test.js +++ b/chrome/test/data/extensions/api_test/context_menus/basics/test.js @@ -11,7 +11,7 @@ var tests = [ function no_properties() { chrome.contextMenus.create({}, function(id) { - chrome.test.assertTrue(chrome.extension.lastError != null); + chrome.test.assertTrue(chrome.runtime.lastError != null); chrome.test.succeed(); }); }, diff --git a/chrome/test/data/extensions/api_test/debugger/background.js b/chrome/test/data/extensions/api_test/debugger/background.js index 21ff1b5..0ca46c9 100644 --- a/chrome/test/data/extensions/api_test/debugger/background.js +++ b/chrome/test/data/extensions/api_test/debugger/background.js @@ -48,8 +48,8 @@ chrome.test.runTests([ function sendCommand() { function onResponse() { - if (chrome.extension.lastError && - chrome.extension.lastError.message.indexOf("invalidMethod") != -1) + if (chrome.runtime.lastError && + chrome.runtime.lastError.message.indexOf("invalidMethod") != -1) chrome.test.succeed(); else chrome.test.fail(); diff --git a/chrome/test/data/extensions/api_test/executescript/frame_after_load/test.js b/chrome/test/data/extensions/api_test/executescript/frame_after_load/test.js index 5189ebd..b120b41 100644 --- a/chrome/test/data/extensions/api_test/executescript/frame_after_load/test.js +++ b/chrome/test/data/extensions/api_test/executescript/frame_after_load/test.js @@ -13,13 +13,16 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { function() { // Tests that we can still execute scripts after a frame has loaded after // the main document has completed. - var injectFrameCode = 'var frame = document.createElement("iframe");' + - 'frame.src = "' + baseUrl + 'inner.html";' + - 'frame.onload = function() {chrome.extension.connect().postMessage("loaded")};' + - 'document.body.appendChild(frame)'; - var postFrameCode = 'chrome.extension.connect().postMessage("done");'; + var injectFrameCode = + 'var frame = document.createElement("iframe");\n' + + 'frame.src = "' + baseUrl + 'inner.html";\n' + + 'frame.onload = function() {\n' + + ' chrome.runtime.connect().postMessage("loaded");\n' + + '};\n' + + 'document.body.appendChild(frame);'; + var postFrameCode = 'chrome.runtime.connect().postMessage("done");'; - chrome.extension.onConnect.addListener(function(port) { + chrome.runtime.onConnect.addListener(function(port) { port.onMessage.addListener(function(data) { if (data == 'loaded') { chrome.tabs.executeScript(tabId, {code: postFrameCode}); diff --git a/chrome/test/data/extensions/api_test/executescript/in_frame/script.js b/chrome/test/data/extensions/api_test/executescript/in_frame/script.js index a4efa64..59555b3 100644 --- a/chrome/test/data/extensions/api_test/executescript/in_frame/script.js +++ b/chrome/test/data/extensions/api_test/executescript/in_frame/script.js @@ -1,3 +1,7 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + function getStyle(elem, name) { if (document.defaultView && document.defaultView.getComputedStyle) { name = name.toLowerCase(); @@ -15,5 +19,5 @@ function getStyle(elem, name) { var bElement = document.getElementById('test2'); var display = getStyle(bElement, 'display').toLowerCase(); -var extensionPort = chrome.extension.connect(); +var extensionPort = chrome.runtime.connect(); extensionPort.postMessage({message: display}); diff --git a/chrome/test/data/extensions/api_test/executescript/in_frame/test.js b/chrome/test/data/extensions/api_test/executescript/in_frame/test.js index 0312e99c..d8111c2 100644 --- a/chrome/test/data/extensions/api_test/executescript/in_frame/test.js +++ b/chrome/test/data/extensions/api_test/executescript/in_frame/test.js @@ -17,7 +17,7 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { chrome.test.runTests([ function executeJavaScriptCodeInAllFramesShouldSucceed() { var script_file = {}; - script_file.code = "var extensionPort = chrome.extension.connect();"; + script_file.code = "var extensionPort = chrome.runtime.connect();"; script_file.code = script_file.code + "extensionPort.postMessage({message: document.title});"; script_file.allFrames = true; @@ -29,11 +29,11 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { totalTitles += data.message; }); }; - chrome.extension.onConnect.addListener(eventListener); + chrome.runtime.onConnect.addListener(eventListener); chrome.tabs.executeScript(tabId, script_file, pass(function() { assertEq(counter, 5); assertEq(totalTitles, 'frametest0test1test2test3'); - chrome.extension.onConnect.removeListener(eventListener); + chrome.runtime.onConnect.removeListener(eventListener); })); }, @@ -49,7 +49,7 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { newStyle += data.message; }); }; - chrome.extension.onConnect.addListener(eventListener); + chrome.runtime.onConnect.addListener(eventListener); chrome.tabs.insertCSS(tabId, css_file, function() { var script_file = {}; script_file.file = 'script.js'; @@ -58,7 +58,7 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { pass(function() { assertEq(newStyle, 'nonenonenonenone'); assertEq(counter, 4); - chrome.extension.onConnect.removeListener(eventListener); + chrome.runtime.onConnect.removeListener(eventListener); })); }); } diff --git a/chrome/test/data/extensions/api_test/executescript/navigation_race/test.js b/chrome/test/data/extensions/api_test/executescript/navigation_race/test.js index fe539469..40c28af 100644 --- a/chrome/test/data/extensions/api_test/executescript/navigation_race/test.js +++ b/chrome/test/data/extensions/api_test/executescript/navigation_race/test.js @@ -16,9 +16,9 @@ chrome.test.getConfig(function(config) { // Generally, the tab navigation hasn't happened by the time we execute // the script, so it's still showing a.com, where we don't have // permission to run it. - if (chrome.extension.lastError) { + if (chrome.runtime.lastError) { chrome.test.assertTrue( - chrome.extension.lastError.message.indexOf( + chrome.runtime.lastError.message.indexOf( 'Cannot access contents of url "http://a.com:') == 0); chrome.test.notifyPass(); } else { diff --git a/chrome/test/data/extensions/api_test/filebrowser_component/main.js b/chrome/test/data/extensions/api_test/filebrowser_component/main.js index 8d7cfc1..140a6cb 100644 --- a/chrome/test/data/extensions/api_test/filebrowser_component/main.js +++ b/chrome/test/data/extensions/api_test/filebrowser_component/main.js @@ -78,7 +78,7 @@ var TestRunner = function(expectations) { TestRunner.prototype.runTest = function() { // Get local FS, create dir with a file in it. console.log('Requesting local file system...'); - chrome.extension.onMessageExternal.addListener(this.listener_); + chrome.runtime.onMessageExternal.addListener(this.listener_); chrome.fileBrowserPrivate.requestLocalFileSystem( this.onFileSystemFetched_.bind(this)); }; @@ -191,7 +191,7 @@ TestRunner.prototype.onHandlerRequest_ = this.expectations_.verifyHandlerRequest( request, this.verifyRequestCallback_.bind(this, sendResponse)); - chrome.extension.onMessageExternal.removeListener(this.listener_); + chrome.runtime.onMessageExternal.removeListener(this.listener_); }; TestRunner.prototype.verifyRequestCallback_ = function(sendResponse, error) { diff --git a/chrome/test/data/extensions/api_test/filebrowser_component/remote.js b/chrome/test/data/extensions/api_test/filebrowser_component/remote.js index 9207163..f203315 100644 --- a/chrome/test/data/extensions/api_test/filebrowser_component/remote.js +++ b/chrome/test/data/extensions/api_test/filebrowser_component/remote.js @@ -116,7 +116,7 @@ TestRunner.prototype.runExecuteReadTask = function() { // Add listener to be invoked when filesystem handler extension sends us // response. this.listener_ = this.onHandlerRequest_.bind(this); - chrome.extension.onMessageExternal.addListener(this.listener_); + chrome.runtime.onMessageExternal.addListener(this.listener_); var self = this; var fileURL = this.fileEntry_.toURL(); @@ -185,7 +185,7 @@ TestRunner.prototype.runCancelTest = function(fileName, type) { TestRunner.prototype.onHandlerRequest_ = function(request, sender, sendResponse) { // We don't have to listen for a response anymore. - chrome.extension.onMessageExternal.removeListener(this.listener_); + chrome.runtime.onMessageExternal.removeListener(this.listener_); this.verifyHandlerRequest(request, chrome.test.succeed, diff --git a/chrome/test/data/extensions/api_test/filesystem_handler/tab.js b/chrome/test/data/extensions/api_test/filesystem_handler/tab.js index 4cde055..538c566 100644 --- a/chrome/test/data/extensions/api_test/filesystem_handler/tab.js +++ b/chrome/test/data/extensions/api_test/filesystem_handler/tab.js @@ -46,7 +46,7 @@ function errorCallback(error) { }; } - chrome.extension.sendMessage(fileBrowserExtensionId, + chrome.runtime.sendMessage(fileBrowserExtensionId, {fileContent: null, error: {message: "File handler error: " + msg}}, function(response) {}); @@ -57,14 +57,14 @@ function onGotEntryByUrl(entry) { var reader = new FileReader(); reader.onloadend = function(e) { if (reader.result != expectedContent) { - chrome.extension.sendMessage( + chrome.runtime.sendMessage( fileBrowserExtensionId, {fileContent: null, error: {message: "File content does not match."}}, function(response) {}); } else { // Send data back to the file browser extension - chrome.extension.sendMessage( + chrome.runtime.sendMessage( fileBrowserExtensionId, {fileContent: reader.result, error: null}, function(response) {}); @@ -117,7 +117,7 @@ function tryReadingReceivedFile(entry, evt) { function runFileSystemHandlerTest(entries) { if (!entries || entries.length != 1 || !entries[0]) { - chrome.extension.sendMessage( + chrome.runtime.sendMessage( fileBrowserExtensionId, {fileContent: null, error: "Invalid file entries."}, function(response) {}); diff --git a/chrome/test/data/extensions/api_test/filesystem_handler_lazy_background/background.js b/chrome/test/data/extensions/api_test/filesystem_handler_lazy_background/background.js index f6d8dae..0c3b78e 100644 --- a/chrome/test/data/extensions/api_test/filesystem_handler_lazy_background/background.js +++ b/chrome/test/data/extensions/api_test/filesystem_handler_lazy_background/background.js @@ -43,7 +43,7 @@ function errorCallback(error) { // The ID of the extension we want to talk to. var fileBrowserExtensionId = "ddammdhioacbehjngdmkjcjbnfginlla"; - chrome.extension.sendMessage(fileBrowserExtensionId, + chrome.runtime.sendMessage(fileBrowserExtensionId, {fileContent: null, error: {message: "File handler error: " + msg}}, function(response) {}); diff --git a/chrome/test/data/extensions/api_test/filesystem_handler_lazy_background/tab.js b/chrome/test/data/extensions/api_test/filesystem_handler_lazy_background/tab.js index 95f9677..56972e7 100644 --- a/chrome/test/data/extensions/api_test/filesystem_handler_lazy_background/tab.js +++ b/chrome/test/data/extensions/api_test/filesystem_handler_lazy_background/tab.js @@ -32,7 +32,7 @@ function errorCallback(error) { }; } - chrome.extension.sendMessage(fileBrowserExtensionId, + chrome.runtime.sendMessage(fileBrowserExtensionId, {fileContent: null, error: {message: "File handler error: " + msg}}, function(response) {}); @@ -42,7 +42,7 @@ function onGotEntryByUrl(entry) { var reader = new FileReader(); reader.onloadend = function(e) { // Send data back to the file browser extension - chrome.extension.sendMessage( + chrome.runtime.sendMessage( fileBrowserExtensionId, {fileContent: reader.result, error: null}, function(response) {}); diff --git a/chrome/test/data/extensions/api_test/filesystem_handler_write/tab.js b/chrome/test/data/extensions/api_test/filesystem_handler_write/tab.js index 14b72ee..725600e 100644 --- a/chrome/test/data/extensions/api_test/filesystem_handler_write/tab.js +++ b/chrome/test/data/extensions/api_test/filesystem_handler_write/tab.js @@ -43,14 +43,14 @@ function errorCallback(error) { }; } - chrome.extension.sendMessage(fileBrowserExtensionId, + chrome.runtime.sendMessage(fileBrowserExtensionId, {fileContent: null, error: {message: "File handler error: " + msg}}, function(response) {}); }; function onSuccess(text) { - chrome.extension.sendMessage( + chrome.runtime.sendMessage( fileBrowserExtensionId, {fileContent: text, error: null}, function(response) {}); @@ -71,7 +71,7 @@ function writeToFile(entry, text) { function runFileSystemHandlerTest(entries) { if (!entries || entries.length != 1 || !entries[0]) { - chrome.extension.sendMessage( + chrome.runtime.sendMessage( fileBrowserExtensionId, {fileContent: null, error: 'Invalid file entries.'}, function(response) {}); diff --git a/chrome/test/data/extensions/api_test/incognito/apis/background.js b/chrome/test/data/extensions/api_test/incognito/apis/background.js index b67f5e5..7300b41 100644 --- a/chrome/test/data/extensions/api_test/incognito/apis/background.js +++ b/chrome/test/data/extensions/api_test/incognito/apis/background.js @@ -92,7 +92,7 @@ chrome.test.getConfig(function(config) { chrome.tabs.executeScript(tab.id, {code: 'document.title = chrome.extension.inIncognitoContext'}, pass(function() { - assertEq(undefined, chrome.extension.lastError); + assertEq(undefined, chrome.runtime.lastError); chrome.tabs.get(tab.id, pass(function(tab) { assertEq("true", tab.title); })); @@ -105,7 +105,7 @@ chrome.test.getConfig(function(config) { chrome.tabs.executeScript(tab.id, {code: 'document.title = chrome.extension.inIncognitoContext'}, pass(function() { - assertEq(undefined, chrome.extension.lastError); + assertEq(undefined, chrome.runtime.lastError); chrome.tabs.get(tab.id, pass(function(tab) { assertEq("false", tab.title); })); diff --git a/chrome/test/data/extensions/api_test/incognito/split/background.js b/chrome/test/data/extensions/api_test/incognito/split/background.js index ac59b8d..40fabbd 100644 --- a/chrome/test/data/extensions/api_test/incognito/split/background.js +++ b/chrome/test/data/extensions/api_test/incognito/split/background.js @@ -100,7 +100,7 @@ chrome.test.getConfig(function(config) { ' inIncognitoContext: chrome.extension.inIncognitoContext' + '});'}, pass(function() { - assertEq(undefined, chrome.extension.lastError); + assertEq(undefined, chrome.runtime.lastError); })); })); diff --git a/chrome/test/data/extensions/api_test/input/test.js b/chrome/test/data/extensions/api_test/input/test.js index a087149..31611cd 100644 --- a/chrome/test/data/extensions/api_test/input/test.js +++ b/chrome/test/data/extensions/api_test/input/test.js @@ -9,7 +9,7 @@ chrome.test.runTests([ function sendKeyboardEvent() { var e = { 'type': 'keydown', 'keyIdentifier': 'A' }; chrome.experimental.input.virtualKeyboard.sendKeyboardEvent(e, function() { - if (chrome.extension.lastError) { + if (chrome.runtime.lastError) { // this is expected for now: no one is handling keys yet // chrome.test.fail(); } @@ -22,7 +22,7 @@ chrome.test.runTests([ function badKeyIdentifier() { var e = { 'type': 'keydown', 'keyIdentifier': 'BogusId' }; chrome.experimental.input.virtualKeyboard.sendKeyboardEvent(e, function() { - if (!chrome.extension.lastError) { + if (!chrome.runtime.lastError) { chrome.test.fail(); } chrome.test.succeed(); @@ -32,7 +32,7 @@ chrome.test.runTests([ function badEventType() { var e = { 'type': 'BAD', 'keyIdentifier': 'A' }; chrome.experimental.input.virtualKeyboard.sendKeyboardEvent(e, function() { - if (!chrome.extension.lastError) { + if (!chrome.runtime.lastError) { chrome.test.fail(); } chrome.test.succeed(); @@ -42,7 +42,7 @@ chrome.test.runTests([ function unmappedKeyIdentifier() { var e = { 'type': 'keydown', 'keyIdentifier': 'Again' }; chrome.experimental.input.virtualKeyboard.sendKeyboardEvent(e, function() { - if (!chrome.extension.lastError) { + if (!chrome.runtime.lastError) { chrome.test.fail(); } chrome.test.succeed(); @@ -53,7 +53,7 @@ chrome.test.runTests([ // U+00E1: LATIN SMALL LATTER A WITH ACUTE. var e = { 'type': 'keydown', 'keyIdentifier': 'U+00E1' }; chrome.experimental.input.virtualKeyboard.sendKeyboardEvent(e, function() { - if (chrome.extension.lastError) { + if (chrome.runtime.lastError) { // this is expected for now. See sendKeyboardEvent(). // chrome.test.fail(); } @@ -66,7 +66,7 @@ chrome.test.runTests([ var e = { 'type': 'keydown', 'keyIdentifier': 'U+043a' }; // lower case is also ok. chrome.experimental.input.virtualKeyboard.sendKeyboardEvent(e, function() { - if (chrome.extension.lastError) { + if (chrome.runtime.lastError) { // this is expected for now. See sendKeyboardEvent(). // chrome.test.fail(); } @@ -77,7 +77,7 @@ chrome.test.runTests([ function sendKeyboardEventBadUnicode1() { var e = { 'type': 'keydown', 'keyIdentifier': 'U+' }; chrome.experimental.input.virtualKeyboard.sendKeyboardEvent(e, function() { - if (!chrome.extension.lastError) { + if (!chrome.runtime.lastError) { chrome.test.fail(); } chrome.test.succeed(); @@ -87,7 +87,7 @@ chrome.test.runTests([ function sendKeyboardEventBadUnicode2() { var e = { 'type': 'keydown', 'keyIdentifier': 'U+1' }; chrome.experimental.input.virtualKeyboard.sendKeyboardEvent(e, function() { - if (!chrome.extension.lastError) { + if (!chrome.runtime.lastError) { chrome.test.fail(); } chrome.test.succeed(); @@ -97,7 +97,7 @@ chrome.test.runTests([ function sendKeyboardEventBadUnicode3() { var e = { 'type': 'keydown', 'keyIdentifier': 'U+111g' }; chrome.experimental.input.virtualKeyboard.sendKeyboardEvent(e, function() { - if (!chrome.extension.lastError) { + if (!chrome.runtime.lastError) { chrome.test.fail(); } chrome.test.succeed(); @@ -107,7 +107,7 @@ chrome.test.runTests([ function sendKeyboardEventBadUnicode4() { var e = { 'type': 'keydown', 'keyIdentifier': 'U+11111' }; chrome.experimental.input.virtualKeyboard.sendKeyboardEvent(e, function() { - if (!chrome.extension.lastError) { + if (!chrome.runtime.lastError) { chrome.test.fail(); } chrome.test.succeed(); diff --git a/chrome/test/data/extensions/api_test/lazy_background_page/messaging/background.js b/chrome/test/data/extensions/api_test/lazy_background_page/messaging/background.js index 06f9338..b3ef900 100644 --- a/chrome/test/data/extensions/api_test/lazy_background_page/messaging/background.js +++ b/chrome/test/data/extensions/api_test/lazy_background_page/messaging/background.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -chrome.extension.onConnect.addListener(function(port) { +chrome.runtime.onConnect.addListener(function(port) { port.onMessage.addListener(function(msg) { chrome.test.notifyPass(); }); diff --git a/chrome/test/data/extensions/api_test/lazy_background_page/messaging/content.js b/chrome/test/data/extensions/api_test/lazy_background_page/messaging/content.js index 52953cc..4a1b9b5 100644 --- a/chrome/test/data/extensions/api_test/lazy_background_page/messaging/content.js +++ b/chrome/test/data/extensions/api_test/lazy_background_page/messaging/content.js @@ -2,5 +2,5 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -var port = chrome.extension.connect(); +var port = chrome.runtime.connect(); port.postMessage({kittenMittens: true}); diff --git a/chrome/test/data/extensions/api_test/messaging/connect/page.js b/chrome/test/data/extensions/api_test/messaging/connect/page.js index 83ce26b..7d141f6 100644 --- a/chrome/test/data/extensions/api_test/messaging/connect/page.js +++ b/chrome/test/data/extensions/api_test/messaging/connect/page.js @@ -19,7 +19,7 @@ Object.prototype.toJSON = function() { }; // For complex connect tests. -chrome.extension.onConnect.addListener(function(port) { +chrome.runtime.onConnect.addListener(function(port) { console.log('connected'); port.onMessage.addListener(function(msg) { console.log('got ' + msg); @@ -46,7 +46,7 @@ chrome.extension.onConnect.addListener(function(port) { // Tests that postMessage to the extension and its response works. function testPostMessageFromTab(origPort) { var portName = "peter"; - var port = chrome.extension.connect({name: portName}); + var port = chrome.runtime.connect({name: portName}); port.postMessage({testPostMessageFromTab: true}); port.onMessage.addListener(function(msg) { origPort.postMessage({success: (msg.success && (msg.portName == portName))}); @@ -57,10 +57,10 @@ function testPostMessageFromTab(origPort) { // For test onMessage. function testSendMessageFromTab() { - chrome.extension.sendMessage({step: 1}, function(response) { + chrome.runtime.sendMessage({step: 1}, function(response) { if (response.nextStep) { console.log('testSendMessageFromTab sent'); - chrome.extension.sendMessage({step: 2}); + chrome.runtime.sendMessage({step: 2}); } }); } @@ -68,22 +68,22 @@ function testSendMessageFromTab() { // Tests sendMessage to an invalid extension. function testSendMessageFromTabError() { // try sending a request to a bad extension id - chrome.extension.sendMessage("bad-extension-id", {m: 1}, function(response) { - var success = (response === undefined && chrome.extension.lastError); - chrome.extension.sendMessage({success: success}); + chrome.runtime.sendMessage("bad-extension-id", {m: 1}, function(response) { + var success = (response === undefined && chrome.runtime.lastError); + chrome.runtime.sendMessage({success: success}); }); } // Tests connecting to an invalid extension. function testConnectFromTabError() { - var port = chrome.extension.connect("bad-extension-id"); + var port = chrome.runtime.connect("bad-extension-id"); port.onDisconnect.addListener(function() { - var success = (chrome.extension.lastError ? true : false); - chrome.extension.sendMessage({success: success}); + var success = (chrome.runtime.lastError ? true : false); + chrome.runtime.sendMessage({success: success}); }); } // For test sendMessage. -chrome.extension.onMessage.addListener(function(request, sender, sendResponse) { +chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { sendResponse({success: (request.step2 == 1)}); }); diff --git a/chrome/test/data/extensions/api_test/messaging/connect/test.js b/chrome/test/data/extensions/api_test/messaging/connect/test.js index 87dfd64..51d3baf 100644 --- a/chrome/test/data/extensions/api_test/messaging/connect/test.js +++ b/chrome/test/data/extensions/api_test/messaging/connect/test.js @@ -64,7 +64,7 @@ chrome.test.getConfig(function(config) { // Tests that postMessage from the tab and its response works. function postMessageFromTab() { - chrome.extension.onConnect.addListener(function(port) { + chrome.runtime.onConnect.addListener(function(port) { chrome.test.assertTrue(Boolean(port.sender.tab.url)); chrome.test.assertTrue(Boolean(port.sender.tab.title)); chrome.test.assertTrue(Boolean(port.sender.tab.id)); @@ -87,7 +87,7 @@ chrome.test.getConfig(function(config) { // Tests receiving a request from a content script and responding. function sendMessageFromTab() { var doneListening = chrome.test.listenForever( - chrome.extension.onMessage, + chrome.runtime.onMessage, function(request, sender, sendResponse) { chrome.test.assertTrue("url" in sender.tab, "no tab available."); chrome.test.assertEq(sender.id, location.host); @@ -113,7 +113,7 @@ chrome.test.getConfig(function(config) { // invalid extension. function sendMessageFromTabError() { chrome.test.listenOnce( - chrome.extension.onMessage, + chrome.runtime.onMessage, function(request, sender, sendResponse) { if (!request.success) chrome.test.fail(); @@ -130,7 +130,7 @@ chrome.test.getConfig(function(config) { // content script. function connectFromTabError() { chrome.test.listenOnce( - chrome.extension.onMessage, + chrome.runtime.onMessage, function(request, sender, sendResponse) { if (!request.success) chrome.test.fail(); diff --git a/chrome/test/data/extensions/api_test/messaging/connect_external/test.js b/chrome/test/data/extensions/api_test/messaging/connect_external/test.js index 706afe5..03607b9 100644 --- a/chrome/test/data/extensions/api_test/messaging/connect_external/test.js +++ b/chrome/test/data/extensions/api_test/messaging/connect_external/test.js @@ -4,14 +4,23 @@ var testId = "bjafgdebaacbbbecmhlhpofkepfkgcpa"; +// Call with |api| as either chrome.runtime or chrome.extension, so that both +// get tested (extension is aliased to runtime). +function connectExternalTest(api) { + var port = api.connect(testId, {name: "extern"}); + port.postMessage({testConnectExternal: true}); + port.onMessage.addListener(chrome.test.callbackPass(function(msg) { + chrome.test.assertTrue(msg.success, "Message failed."); + chrome.test.assertEq(msg.senderId, location.host, + "Sender ID doesn't match."); + })); +} + chrome.test.runTests([ - function connectExternal() { - var port = chrome.extension.connect(testId, {name: "extern"}); - port.postMessage({testConnectExternal: true}); - port.onMessage.addListener(chrome.test.callbackPass(function(msg) { - chrome.test.assertTrue(msg.success, "Message failed."); - chrome.test.assertEq(msg.senderId, location.host, - "Sender ID doesn't match."); - })); + function connectExternal_extension() { + connectExternalTest(chrome.extension); + }, + function connectExternal_runtime() { + connectExternalTest(chrome.runtime); } ]); diff --git a/chrome/test/data/extensions/api_test/messaging/connect_panel/panel.js b/chrome/test/data/extensions/api_test/messaging/connect_panel/panel.js index 531165b..439e137 100644 --- a/chrome/test/data/extensions/api_test/messaging/connect_panel/panel.js +++ b/chrome/test/data/extensions/api_test/messaging/connect_panel/panel.js @@ -2,4 +2,4 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -chrome.extension.connect({name:'test-connection'}); +chrome.runtime.connect({name:'test-connection'}); diff --git a/chrome/test/data/extensions/api_test/messaging/connect_panel/test.js b/chrome/test/data/extensions/api_test/messaging/connect_panel/test.js index 8cf8c8a..9784b0e 100644 --- a/chrome/test/data/extensions/api_test/messaging/connect_panel/test.js +++ b/chrome/test/data/extensions/api_test/messaging/connect_panel/test.js @@ -6,7 +6,7 @@ var panelWindowId = 0; chrome.test.runTests([ function openPanelThatConnectsToExtension() { - chrome.test.listenOnce(chrome.extension.onConnect, function(port) { + chrome.test.listenOnce(chrome.runtime.onConnect, function(port) { chrome.test.assertEq(panelWindowId, port.sender.tab.windowId); chrome.test.assertTrue(port.sender.tab.id > 0); }); diff --git a/chrome/test/data/extensions/api_test/native_messaging/test.js b/chrome/test/data/extensions/api_test/native_messaging/test.js index cb58585..b0e0c14 100644 --- a/chrome/test/data/extensions/api_test/native_messaging/test.js +++ b/chrome/test/data/extensions/api_test/native_messaging/test.js @@ -7,7 +7,7 @@ chrome.test.getConfig(function(config) { function sendMessageWithCallback() { var message = {"text": "Hi there!", "number": 3}; - chrome.extension.sendNativeMessage( + chrome.runtime.sendNativeMessage( 'echo.py', message, chrome.test.callbackPass(function(nativeResponse) { var expectedResponse = {"id": 1, "echo": message}; @@ -18,7 +18,7 @@ chrome.test.getConfig(function(config) { // The goal of this test, is just not to crash. function sendMessageWithoutCallback() { var message = {"text": "Hi there!", "number": 3}; - chrome.extension.sendNativeMessage('echo.py', message); + chrome.runtime.sendNativeMessage('echo.py', message); chrome.test.succeed(); // Mission Complete }, @@ -31,7 +31,7 @@ chrome.test.getConfig(function(config) { {"id": 3, "echo": messagesToSend[2]}]; var currentMessage = 0; - port = chrome.extension.connectNative('echo.py', + port = chrome.runtime.connectNative('echo.py', messagesToSend[currentMessage]); port.onMessage.addListener(function(message) { chrome.test.assertEq(expectedResponses[currentMessage], message); diff --git a/chrome/test/data/extensions/api_test/page_capture/test.js b/chrome/test/data/extensions/api_test/page_capture/test.js index dec1342..205530a 100644 --- a/chrome/test/data/extensions/api_test/page_capture/test.js +++ b/chrome/test/data/extensions/api_test/page_capture/test.js @@ -31,7 +31,7 @@ chrome.test.getConfig(function(config) { waitForCurrentTabLoaded(function() { chrome.pageCapture.saveAsMHTML({ "tabId": tab.id }, function(data) { - assertEq(undefined, chrome.extension.lastError); + assertEq(undefined, chrome.runtime.lastError); assertTrue(data != null); // It should contain few KBs of data. assertTrue(data.size > 100); diff --git a/chrome/test/data/extensions/api_test/permissions/optional_deny/background.js b/chrome/test/data/extensions/api_test/permissions/optional_deny/background.js index 6de0e90..0c6d0e1 100644 --- a/chrome/test/data/extensions/api_test/permissions/optional_deny/background.js +++ b/chrome/test/data/extensions/api_test/permissions/optional_deny/background.js @@ -41,7 +41,7 @@ chrome.test.getConfig(function(config) { pass(function(granted) { // They were not granted, and there should be no error. assertFalse(granted); - assertTrue(chrome.extension.lastError === undefined); + assertTrue(chrome.runtime.lastError === undefined); // Make sure they weren't granted... chrome.permissions.contains( diff --git a/chrome/test/data/extensions/api_test/speech_input/recognition/test.js b/chrome/test/data/extensions/api_test/speech_input/recognition/test.js index d896d1c..c5b67445 100644 --- a/chrome/test/data/extensions/api_test/speech_input/recognition/test.js +++ b/chrome/test/data/extensions/api_test/speech_input/recognition/test.js @@ -40,7 +40,7 @@ chrome.test.runTests([ // Stopping should fail since we're in the idle state again. chrome.experimental.speechInput.stop(function() { - chrome.test.assertEq(chrome.extension.lastError.message, + chrome.test.assertEq(chrome.runtime.lastError.message, "invalidOperation"); chrome.test.succeed(); }); diff --git a/chrome/test/data/extensions/api_test/speech_input/recognition_error/test.js b/chrome/test/data/extensions/api_test/speech_input/recognition_error/test.js index 2b9094d..b4995d0 100644 --- a/chrome/test/data/extensions/api_test/speech_input/recognition_error/test.js +++ b/chrome/test/data/extensions/api_test/speech_input/recognition_error/test.js @@ -23,7 +23,7 @@ chrome.test.runTests([ // Stopping should fail since we're in the idle state again. chrome.experimental.speechInput.stop(function() { - chrome.test.assertEq(chrome.extension.lastError.message, + chrome.test.assertEq(chrome.runtime.lastError.message, "invalidOperation"); chrome.test.succeed(); }); diff --git a/chrome/test/data/extensions/api_test/speech_input/start_error/test.js b/chrome/test/data/extensions/api_test/speech_input/start_error/test.js index 39a8831..7105c59 100644 --- a/chrome/test/data/extensions/api_test/speech_input/start_error/test.js +++ b/chrome/test/data/extensions/api_test/speech_input/start_error/test.js @@ -17,7 +17,7 @@ chrome.test.runTests([ // Start should fail because no devices are available. function started() { - chrome.test.assertEq(chrome.extension.lastError.message, + chrome.test.assertEq(chrome.runtime.lastError.message, "noRecordingDeviceFound"); // Recording shouldn't have started. @@ -27,7 +27,7 @@ chrome.test.runTests([ // Stopping should fail since we're back in the idle state. chrome.experimental.speechInput.stop(function() { - chrome.test.assertEq(chrome.extension.lastError.message, + chrome.test.assertEq(chrome.runtime.lastError.message, "invalidOperation"); chrome.test.succeed(); }); diff --git a/chrome/test/data/extensions/api_test/speech_input/start_stop/test.js b/chrome/test/data/extensions/api_test/speech_input/start_stop/test.js index 364b825..0308f95 100644 --- a/chrome/test/data/extensions/api_test/speech_input/start_stop/test.js +++ b/chrome/test/data/extensions/api_test/speech_input/start_stop/test.js @@ -44,7 +44,7 @@ chrome.test.runTests([ function testSpeechInputInvalidOperation() { // Calling start once recording should generate an invalid operation error. chrome.experimental.speechInput.stop(function() { - chrome.test.assertEq(chrome.extension.lastError.message, + chrome.test.assertEq(chrome.runtime.lastError.message, "invalidOperation"); chrome.experimental.speechInput.start({}, started); }); @@ -53,7 +53,7 @@ chrome.test.runTests([ function started() { chrome.test.assertNoLastError(); chrome.experimental.speechInput.start({}, function() { - chrome.test.assertEq(chrome.extension.lastError.message, + chrome.test.assertEq(chrome.runtime.lastError.message, "invalidOperation"); chrome.test.succeed(); }); diff --git a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test_race.js b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test_race.js index df04f0f..65d4aea 100644 --- a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test_race.js +++ b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test_race.js @@ -64,9 +64,9 @@ chrome.test.runTests([ {'format': 'png'}, function(imgDataUrl) { log('captured ' + windowId); - if (chrome.extension.lastError) { + if (chrome.runtime.lastError) { chrome.test.fail('captureVisibleTab error: ' + - chrome.extension.lastError.message); + chrome.runtime.lastError.message); } testPixelsAreExpectedColor( imgDataUrl, kWindowRect, expectedColor); diff --git a/chrome/test/data/extensions/api_test/tabs/connect/echo.js b/chrome/test/data/extensions/api_test/tabs/connect/echo.js index 1cab30c..c2a4928 100644 --- a/chrome/test/data/extensions/api_test/tabs/connect/echo.js +++ b/chrome/test/data/extensions/api_test/tabs/connect/echo.js @@ -1,8 +1,12 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + // Content script that echoes back all messages. // Posting a message with "GET" returns the name and # of connections opened. var connections = 0; -chrome.extension.onConnect.addListener(function onConnect(port) { +chrome.runtime.onConnect.addListener(function onConnect(port) { connections++; port.onMessage.addListener(function onMessage(msg) { if (msg == "GET") { diff --git a/chrome/test/data/extensions/api_test/webrequest/permissionless/rules.js b/chrome/test/data/extensions/api_test/webrequest/permissionless/rules.js index b830a60..32b0ff8 100644 --- a/chrome/test/data/extensions/api_test/webrequest/permissionless/rules.js +++ b/chrome/test/data/extensions/api_test/webrequest/permissionless/rules.js @@ -42,8 +42,8 @@ function addRules(testServerPort) { actions: [new chrome.declarativeWebRequest.CancelRequest()] }], function(rules) { - if (chrome.extension.lastError) - chrome.test.fail(chrome.extension.lastError); + if (chrome.runtime.lastError) + chrome.test.fail(chrome.runtime.lastError); chrome.test.sendMessage("rules all registered"); } ); diff --git a/chrome/test/data/extensions/browsertest/crash_25562/background.js b/chrome/test/data/extensions/browsertest/crash_25562/background.js index 0ddef86..d778fa8 100644 --- a/chrome/test/data/extensions/browsertest/crash_25562/background.js +++ b/chrome/test/data/extensions/browsertest/crash_25562/background.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -chrome.extension.onConnect.addListener(function(port) { +chrome.runtime.onConnect.addListener(function(port) { port.onMessage.addListener(function() { // Let Chrome know that the PageAction needs to be enabled for this tabId // and for the url of this page. diff --git a/chrome/test/data/extensions/browsertest/crash_25562/script.js b/chrome/test/data/extensions/browsertest/crash_25562/script.js index b602eb8..08bfee2 100644 --- a/chrome/test/data/extensions/browsertest/crash_25562/script.js +++ b/chrome/test/data/extensions/browsertest/crash_25562/script.js @@ -3,5 +3,5 @@ // found in the LICENSE file. if (window == top) { - chrome.extension.connect().postMessage(true); + chrome.runtime.connect().postMessage(true); } diff --git a/chrome/test/data/extensions/browsertest/last_error/bg.js b/chrome/test/data/extensions/browsertest/last_error/bg.js index e9f2309..71563d9 100644 --- a/chrome/test/data/extensions/browsertest/last_error/bg.js +++ b/chrome/test/data/extensions/browsertest/last_error/bg.js @@ -36,8 +36,8 @@ function testLastError() { // Now ask for the next highest tabId. chrome.tabs.get(maxTabId + 1, function(tab) { // Make sure lastError *is* set and tab is not. - if (!chrome.extension.lastError || - !chrome.extension.lastError.message || + if (!chrome.runtime.lastError || + !chrome.runtime.lastError.message || tab) fail(); diff --git a/chrome/test/data/extensions/browsertest/title_localized_pa/background.js b/chrome/test/data/extensions/browsertest/title_localized_pa/background.js index 37fae35..257d3e0 100644 --- a/chrome/test/data/extensions/browsertest/title_localized_pa/background.js +++ b/chrome/test/data/extensions/browsertest/title_localized_pa/background.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -chrome.extension.onConnect.addListener(function(port) { +chrome.runtime.onConnect.addListener(function(port) { port.onMessage.addListener(function(mybool) { // Let Chrome know that the PageAction needs to be enabled for this tabId // and for the url of this page. diff --git a/chrome/test/data/extensions/browsertest/title_localized_pa/script.js b/chrome/test/data/extensions/browsertest/title_localized_pa/script.js index b602eb8..08bfee2 100644 --- a/chrome/test/data/extensions/browsertest/title_localized_pa/script.js +++ b/chrome/test/data/extensions/browsertest/title_localized_pa/script.js @@ -3,5 +3,5 @@ // found in the LICENSE file. if (window == top) { - chrome.extension.connect().postMessage(true); + chrome.runtime.connect().postMessage(true); } diff --git a/chrome/test/data/extensions/context_menus/frames/test.js b/chrome/test/data/extensions/context_menus/frames/test.js index 65d6561..2a2bad1 100644 --- a/chrome/test/data/extensions/context_menus/frames/test.js +++ b/chrome/test/data/extensions/context_menus/frames/test.js @@ -6,11 +6,11 @@ window.onload = function() { chrome.contextMenus.create( {"title":"Page item", contexts: ["page"]}, function() { - if (!chrome.extension.lastError) { + if (!chrome.runtime.lastError) { chrome.contextMenus.create( {"title":"Frame item", contexts: ["frame"]}, function() { - if (!chrome.extension.lastError) { + if (!chrome.runtime.lastError) { chrome.test.sendMessage("created items"); } }); diff --git a/chrome/test/data/extensions/context_menus/incognito/test.js b/chrome/test/data/extensions/context_menus/incognito/test.js index c64b01a..4995774 100644 --- a/chrome/test/data/extensions/context_menus/incognito/test.js +++ b/chrome/test/data/extensions/context_menus/incognito/test.js @@ -12,7 +12,7 @@ function onclick(info) { window.onload = function() { chrome.contextMenus.create({title: "item " + incognitoStr, onclick: onclick}, function() { - if (!chrome.extension.lastError) { + if (!chrome.runtime.lastError) { chrome.test.sendMessage("created item " + incognitoStr); } }); diff --git a/chrome/test/data/extensions/context_menus/long_title/test.js b/chrome/test/data/extensions/context_menus/long_title/test.js index b807e38..e6b0ad5 100644 --- a/chrome/test/data/extensions/context_menus/long_title/test.js +++ b/chrome/test/data/extensions/context_menus/long_title/test.js @@ -10,7 +10,7 @@ window.onload = function() { } chrome.test.log("creating item"); chrome.contextMenus.create({"title":title}, function() { - if (!chrome.extension.lastError) { + if (!chrome.runtime.lastError) { chrome.test.sendMessage("created"); } }); diff --git a/chrome/test/data/extensions/context_menus/patterns/test.js b/chrome/test/data/extensions/context_menus/patterns/test.js index ef9bd45..37c8bf6 100644 --- a/chrome/test/data/extensions/context_menus/patterns/test.js +++ b/chrome/test/data/extensions/context_menus/patterns/test.js @@ -3,7 +3,7 @@ // found in the LICENSE file. var make_browsertest_proceed = function() { - if (!chrome.extension.lastError) { + if (!chrome.runtime.lastError) { chrome.test.sendMessage("created items"); } }; diff --git a/chrome/test/data/extensions/context_menus/separators/common.js b/chrome/test/data/extensions/context_menus/separators/common.js index 0122059..8707440 100644 --- a/chrome/test/data/extensions/context_menus/separators/common.js +++ b/chrome/test/data/extensions/context_menus/separators/common.js @@ -14,7 +14,7 @@ function create(title, type, parent, callback) { } chrome.contextMenus.create(props, function() { - if (!chrome.extension.lastError && callback) { + if (!chrome.runtime.lastError && callback) { callback(); } }); diff --git a/chrome/test/data/extensions/context_menus/simple/test.js b/chrome/test/data/extensions/context_menus/simple/test.js index 67494aa..75011dd 100644 --- a/chrome/test/data/extensions/context_menus/simple/test.js +++ b/chrome/test/data/extensions/context_menus/simple/test.js @@ -9,7 +9,7 @@ function onclick(info) { window.onload = function() { chrome.contextMenus.create({"title":"Extension Item 1", "onclick": onclick}, function() { - if (!chrome.extension.lastError) { + if (!chrome.runtime.lastError) { chrome.test.sendMessage("created item"); } }); diff --git a/chrome/test/data/extensions/context_menus/target_urls/test.js b/chrome/test/data/extensions/context_menus/target_urls/test.js index 9742bfd..cad65fa 100644 --- a/chrome/test/data/extensions/context_menus/target_urls/test.js +++ b/chrome/test/data/extensions/context_menus/target_urls/test.js @@ -6,7 +6,7 @@ window.onload = function() { var patterns = [ "http://*.google.com/*" ]; chrome.contextMenus.create({"title":"item1", "contexts": ["link"], "targetUrlPatterns": patterns}, function() { - if (!chrome.extension.lastError) { + if (!chrome.runtime.lastError) { chrome.test.sendMessage("created items"); } }); diff --git a/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/background.js b/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/background.js index 25ab76f..b30f849 100644 --- a/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/background.js +++ b/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/background.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -chrome.extension.onConnectExternal.addListener(function(port) { +chrome.runtime.onConnectExternal.addListener(function(port) { port.onMessage.addListener(function(msg) { if (msg.testConnectExternal) { port.postMessage({success: true, senderId: port.sender.id}); diff --git a/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/page.js b/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/page.js index 64bc454..caf13f5 100644 --- a/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/page.js +++ b/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/page.js @@ -7,7 +7,7 @@ if (typeof(contentWindow) != 'undefined') { win = contentWindow; } -chrome.extension.onConnect.addListener(function(port) { +chrome.runtime.onConnect.addListener(function(port) { console.log('connected'); port.onMessage.addListener(function(msg) { console.log('got ' + msg); @@ -30,7 +30,7 @@ chrome.extension.onConnect.addListener(function(port) { function testPostMessageFromTab(origPort) { console.log('testPostMessageFromTab'); var portName = "peter"; - var port = chrome.extension.connect({name: portName}); + var port = chrome.runtime.connect({name: portName}); port.postMessage({testPostMessageFromTab: true}); port.onMessage.addListener(function(msg) { origPort.postMessage({success: (msg.success && (msg.portName == portName))}); diff --git a/chrome/test/data/extensions/management/launch_app/test.js b/chrome/test/data/extensions/management/launch_app/test.js index 3f42c16..468db74a 100644 --- a/chrome/test/data/extensions/management/launch_app/test.js +++ b/chrome/test/data/extensions/management/launch_app/test.js @@ -13,8 +13,8 @@ window.onload = function() { // Try launching a non-app extension, which should fail. var expected_error = "Extension " + item.id + " is not an App"; chrome.management.launchApp(item.id, function() { - if (chrome.extension.lastError && - chrome.extension.lastError.message == expected_error) { + if (chrome.runtime.lastError && + chrome.runtime.lastError.message == expected_error) { chrome.test.sendMessage("got_expected_error"); } }); diff --git a/chrome/test/data/extensions/management/uninstall_extension/background.js b/chrome/test/data/extensions/management/uninstall_extension/background.js index bc7360b..5ea92dd 100644 --- a/chrome/test/data/extensions/management/uninstall_extension/background.js +++ b/chrome/test/data/extensions/management/uninstall_extension/background.js @@ -14,7 +14,7 @@ chrome.management.getAll(function(items) { chrome.management.uninstall(id, function() { // Check that the right error occured. var expectedError = 'Extension ' + id + ' cannot be modified by user'; - chrome.test.assertEq(expectedError, chrome.extension.lastError.message); + chrome.test.assertEq(expectedError, chrome.runtime.lastError.message); chrome.test.sendMessage('ready'); }); } diff --git a/chrome/test/data/extensions/uitest/window_open/newtab.js b/chrome/test/data/extensions/uitest/window_open/newtab.js index 7718f04..7721a97 100644 --- a/chrome/test/data/extensions/uitest/window_open/newtab.js +++ b/chrome/test/data/extensions/uitest/window_open/newtab.js @@ -6,7 +6,7 @@ function testExtensionApi() { try { chrome.tabs.getAllInWindow(null, function() { window.domAutomationController.send( - !chrome.extension.lastError); + !chrome.runtime.lastError); }); } catch (e) { window.domAutomationController.send(false); diff --git a/chrome/test/data/panels/context_menu/test.js b/chrome/test/data/panels/context_menu/test.js index 17e7902..1f95790 100644 --- a/chrome/test/data/panels/context_menu/test.js +++ b/chrome/test/data/panels/context_menu/test.js @@ -10,7 +10,7 @@ function onclick(info) { function panelCallback() { chrome.contextMenus.create({"title":"Extension Item 1", "onclick": onclick}, function() { - if (!chrome.extension.lastError) { + if (!chrome.runtime.lastError) { chrome.test.sendMessage("created item"); } }); diff --git a/chrome/test/data/panels/context_menu2/test.js b/chrome/test/data/panels/context_menu2/test.js index 4f27d9e..3604d58 100644 --- a/chrome/test/data/panels/context_menu2/test.js +++ b/chrome/test/data/panels/context_menu2/test.js @@ -8,7 +8,7 @@ function onclick(info) { chrome.contextMenus.create({"title":"Extension Item Bogey", "onclick": onclick}, function() { - if (!chrome.extension.lastError) { + if (!chrome.runtime.lastError) { chrome.test.sendMessage("created bogey item"); } }); diff --git a/tools/json_schema_compiler/test/permissions.json b/tools/json_schema_compiler/test/permissions.json index 377a43f..1f4cb9f 100644 --- a/tools/json_schema_compiler/test/permissions.json +++ b/tools/json_schema_compiler/test/permissions.json @@ -91,7 +91,7 @@ { "name": "request", "type": "function", - "description": "Requests access to the specified permissions. These permissions must be defined in the optional_permissions field of the manifest. If there are any problems requesting the permissions, <a href='extension.html#property-lastError'>chrome.extension.lastError</a> will be set.", + "description": "Requests access to the specified permissions. These permissions must be defined in the optional_permissions field of the manifest. If there are any problems requesting the permissions, <a href='extension.html#property-lastError'>chrome.runtime.lastError</a> will be set.", "parameters": [ { "name": "permissions", @@ -114,7 +114,7 @@ { "name": "remove", "type": "function", - "description": "Removes access to the specified permissions. If there are any problems removing the permissions, <a href='extension.html#property-lastError'>chrome.extension.lastError</a> will be set.", + "description": "Removes access to the specified permissions. If there are any problems removing the permissions, <a href='extension.html#property-lastError'>chrome.runtime.lastError</a> will be set.", "parameters": [ { "name": "permissions", diff --git a/tools/json_schema_compiler/test/tabs.json b/tools/json_schema_compiler/test/tabs.json index 1069eb6..af0910a 100644 --- a/tools/json_schema_compiler/test/tabs.json +++ b/tools/json_schema_compiler/test/tabs.json @@ -63,7 +63,7 @@ "name": "connect", "nocompile": true, "type": "function", - "description": "Connects to the content script(s) in the specified tab. The <a href='extension.html#event-onConnect'>chrome.extension.onConnect</a> event is fired in each content script running in the specified tab for the current extension. For more details, see <a href='content_scripts.html#messaging'>Content Script Messaging</a>.", + "description": "Connects to the content script(s) in the specified tab. The <a href='extension.html#event-onConnect'>chrome.runtime.onConnect</a> event is fired in each content script running in the specified tab for the current extension. For more details, see <a href='content_scripts.html#messaging'>Content Script Messaging</a>.", "parameters": [ { "type": "integer", @@ -107,7 +107,7 @@ { "name": "response", "type": "any", - "description": "The JSON response object sent by the handler of the request. If an error occurs while connecting to the specified tab, the callback will be called with no arguments and <a href='extension.html#property-lastError'>chrome.extension.lastError</a> will be set to the error message." + "description": "The JSON response object sent by the handler of the request. If an error occurs while connecting to the specified tab, the callback will be called with no arguments and <a href='extension.html#property-lastError'>chrome.runtime.lastError</a> will be set to the error message." } ] } diff --git a/tools/page_cycler/webpagereplay/extension/background.js b/tools/page_cycler/webpagereplay/extension/background.js index 207979e..e03c230 100644 --- a/tools/page_cycler/webpagereplay/extension/background.js +++ b/tools/page_cycler/webpagereplay/extension/background.js @@ -318,11 +318,11 @@ function Run() { sessionLoader.run(); } -chrome.extension.onConnect.addListener(function(port) { +chrome.runtime.onConnect.addListener(function(port) { port.onMessage.addListener(function(data) { if (data.message == "start") { window.benchmarkConfiguration = data.benchmark; Run() } }); -});
\ No newline at end of file +}); diff --git a/tools/page_cycler/webpagereplay/extension/start.js b/tools/page_cycler/webpagereplay/extension/start.js index 4808996..ef4ce301 100644 --- a/tools/page_cycler/webpagereplay/extension/start.js +++ b/tools/page_cycler/webpagereplay/extension/start.js @@ -71,7 +71,7 @@ function TryStart() { var reportDir = dirname(dirname(window.location.pathname)) + "/common"; config["reportUrl"] = "file://" + reportDir + "/report.html"; config["isRecordMode"] = isRecordMode; - var port = chrome.extension.connect(); + var port = chrome.runtime.connect(); port.postMessage({message: "start", benchmark: config}); console.log("sending start message: page count, " + config["pageSets"].length); |