Index: ios/web/web_state/js/resources/console.js |
diff --git a/ios/web/web_state/js/resources/console.js b/ios/web/web_state/js/resources/console.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0e67644f8f4c0227e02fcf38bb25fbcd02f59b02 |
--- /dev/null |
+++ b/ios/web/web_state/js/resources/console.js |
@@ -0,0 +1,44 @@ |
+// Copyright 2015 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. |
+ |
+// Scripts to allow page console.log() etc. output to be seen on the console |
+// of the host application. |
+ |
+goog.provide('__crweb.console'); |
+ |
+/** |
+ * Namespace for this module. |
+ */ |
+__gCrWeb.console = {}; |
+ |
+/* Beginning of anonymous object. */ |
+new function() { |
+ function sendConsoleMessage(method, originalArguments) { |
+ message = Array.prototype.slice.call(originalArguments).join(' '); |
+ __gCrWeb.message.invokeOnHost({'command': 'console', |
+ 'method': method, |
+ 'message': message, |
+ 'origin': document.location.origin}); |
+ } |
+ |
+ console.log = function() { |
+ sendConsoleMessage('log', arguments); |
+ }; |
+ |
+ console.debug = function() { |
+ sendConsoleMessage('debug', arguments); |
+ }; |
+ |
+ console.info = function() { |
+ sendConsoleMessage('info', arguments); |
+ }; |
+ |
+ console.warn = function() { |
+ sendConsoleMessage('warn', arguments); |
+ }; |
+ |
+ console.error = function() { |
+ sendConsoleMessage('error', arguments); |
+ }; |
+} |