Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27054] iOS: Ti.API.log() function no longer works within WebView's HTML JS code as of 8.0.0

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2019-06-04T21:43:44.000+0000
Affected Version/sRelease 8.0.0
Fix Version/sRelease 8.0.2
ComponentsiOS
LabelsWebView, engSchedule, html, ios, log, regression
ReporterJoshua Quick
AssigneeVijay Singh
Created2019-05-02T17:40:59.000+0000
Updated2019-06-04T21:43:44.000+0000

Description

*Summary:* The [Ti.API.log()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.API-method-log) function no longer works within a WebView's HTML <script/> code as of Titanium 8.0.0. *Steps to reproduce:*

Set up a Classic Titanium "app.js" with the below code.

Build and run on iOS with Titanium 8.0.0 or 8.0.1.

Notice that *none* of the below messages get logged.

Build and run with Titanium 7.x.x.

Notice that the below message do get logged.

var htmlText =
		'<!DOCTYPE html>\n' +
		'<html>\n' +
		'	<head>\n' +
		'		<meta name="viewport" content="width=device-width, initial-scale=1.0">\n' +
		'	</head>\n' +
		'	<body>\n' +
		'		<p>HTML JavaScript Logging Test</p>\n' +
		'	</body>\n' +
		'	<script>\n' +
		'		document.addEventListener("DOMContentLoaded", function(e) {\n' +
		'			Ti.API.log("info", "@@@ Logging via Ti.API.log(info,message) method.");\n' +
		'			Ti.API.log("warn", "@@@ Logging via Ti.API.log(warn,message) method.");\n' +
		'			Ti.API.log("error", "@@@ Logging via Ti.API.log(error,message) method.");\n' +
		'		});\n' +
		'	</script>\n' +
		'</html>\n';

var window = Ti.UI.createWindow();
var webView = Ti.UI.createWebView({
	html: htmlText,
});
window.add(webView);
window.open();
*Work-Around:* Use the following instead. They work in 8.0.x and older versions.
Ti.API.info("My info.");
Ti.API.warn("My warning.");
Ti.API.error("My error");

Comments

  1. Vijay Singh 2019-05-03

    PR(Master) - https://github.com/appcelerator/titanium_mobile/pull/10877 Note- Above PR is same as of ticket TIMOB-27055. Fixed both issue in same ticket in master. PR(8_0_X) - https://github.com/appcelerator/titanium_mobile/pull/10922
  2. Keerthi Mahalingam 2019-06-01

    FR Passed. Waiting on Jenkins
  3. Keerthi Mahalingam 2019-06-03

    Waiting for resolving jenkin's failure to merge
  4. Christopher Williams 2019-06-03

    merged to master, 8_0_X, 8_1_X
  5. Keerthi Mahalingam 2019-06-04

    Verified the fix on SDK 8.2.0.v20190603133455, SDK 8.1.0.v20190603133458 and SDK 8.0.2.v20190603133031. Ti.API.log() logged in the console correctly.Closing
       Operating System
         Name                        = Mac OS X
         Version                     = 10.13.6
         Memory                      = 17179869184
       Node.js
         Node.js Version             = 8.9.1
         npm Version                 = 5.5.1
       Titanium CLI
         CLI Version                 = 5.1.1
       Titanium SDK
         SDK Version                 = 8.1.0.v20190603133458 ,8.2.0.v20190603133455 and 8.0.2.v20190603133031
       

JSON Source