{ "id": "86314", "key": "TIMOB-8374", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "14164", "description": "Release 3.0.2", "name": "Release 3.0.2", "archived": true, "released": true, "releaseDate": "2013-02-19" } ], "resolution": { "id": "5", "description": "All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.", "name": "Cannot Reproduce" }, "resolutiondate": "2013-04-17T10:16:33.000+0000", "created": "2012-02-10T07:33:33.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "parity" ], "versions": [ { "id": "12677", "description": "Release 1.8 Service Pack 1", "name": "Release 1.8.1", "archived": true, "released": true, "releaseDate": "2012-01-31" }, { "id": "13272", "description": "Release 2.0.1", "name": "Release 2.0.1", "archived": true, "released": true, "releaseDate": "2012-04-16" } ], "issuelinks": [], "assignee": { "name": "shameerj", "key": "shameerj", "displayName": "Shameer Jan", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-23T21:13:27.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "h4. Problem Description\r\nYou can add/inject CSS code in a webview in Android, but in iOS is failing.\r\n\r\nh4. Actual Results\r\nSilently fails in iOS\r\n\r\nh4. Expected Results \r\nWorking the same in iOS and Android\r\n\r\nh4. Test Case \r\napp.js:\r\n\r\n{code}\r\n// create our web view\r\nvar win = Ti.UI.createWindow({ backgroundColor: \"#fff\" });\r\nvar web = Ti.UI.createWebView({ url: \"http://chicago.craigslist.org/\" });\r\n\r\n// inject our css when the web view finishes loading (because we need to inject into the head element)\r\nweb.addEventListener('load', function () {\r\n // first, specify the CSS file that we should load\r\n var cssFileName = 'styles.css';\r\n // read in the contents\r\n var cssFromFile = Ti.Filesystem.getFile(cssFileName);\r\n // clean the contents so we can put them in a JS string\r\n var contents = String(cssFromFile.read())\r\n .split('\\r').join('')\r\n .split('\\n').join(' ')\r\n .split('\"').join('\\\\\"');\r\n // and run the JavaScript to inject the CSS by setting the URL of the web view\r\n // (hint: try running \"javascript:alert('Hello, world!');\" in your own browser to see what happens\r\n web.url =\r\n 'javascript:(function evilGenius(){'\r\n + 'var s=document.createElement(\"style\");'\r\n + 's.setAttribute(\"type\",\"text/css\");'\r\n + 's.innerHTML=\"' + contents + '\";'\r\n + 'document.getElementsByTagName(\"head\")[0].appendChild(s);'\r\n + '})();';\r\n // note that we don't use web.evalJS() -- it relies on Ti being injected in the DOM already but we're\r\n // running this on an external URL, so it won't have Ti injected! web.url is the same method evalJS uses\r\n});\r\n\r\n// show the web view\r\nwin.add(web);\r\nwin.open();\r\n{code}\r\n\r\nstyles.css:\r\n{code}\r\n/* WARNING - this WILL turn CraigsList pink! */\r\nbody\r\n{\r\nbackground-color: pink;\r\n}\r\n{code}", "attachment": [], "flagged": false, "summary": "iOS: Injecting javascript via webview url crashes iOS devices", "creator": { "name": "djsxxx", "key": "djsxxx", "displayName": "Dave Shepheard", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "djsxxx", "key": "djsxxx", "displayName": "Dave Shepheard", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Mac OS X (v10.7.3), \r\nTitanium Studio build 1.0.8, \r\nTitanium SDK version 1.8.1", "comment": { "comments": [ { "id": "195525", "author": { "name": "jyounus", "key": "jyounus", "displayName": "Junaid Younus", "active": true, "timeZone": "Europe/London" }, "body": "Tested with 2.0.1GA2 on the iOS simulator, issue still exists. Seems to work fine on a Samsung Galaxy S2 (2.3.x).", "updateAuthor": { "name": "jyounus", "key": "jyounus", "displayName": "Junaid Younus", "active": true, "timeZone": "Europe/London" }, "created": "2012-05-21T15:30:06.000+0000", "updated": "2012-05-21T15:30:06.000+0000" }, { "id": "247915", "author": { "name": "shameerj", "key": "shameerj", "displayName": "Shameer Jan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Issue does not reproduces \r\n\r\nTested with\r\n\r\nTitanium Studio, build: 3.0.1.201212181159\r\nTitanium SDK version: 3.1.0 \r\nTitanium SDK version: 3.0.2 \r\niOS iPhone Simulator: iOS SDK version: 6.0\r\n", "updateAuthor": { "name": "shameerj", "key": "shameerj", "displayName": "Shameer Jan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-04-17T10:16:33.000+0000", "updated": "2013-04-17T10:16:33.000+0000" }, { "id": "289582", "author": { "name": "shameerj", "key": "shameerj", "displayName": "Shameer Jan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "css not working for IOS simulator, but app does not crash.\nWorking fine on Android:\n\nTitanium SDK version 3.2.0.GA\niOS SDK: 7.0.3\niOS iPhone Simulator: 7.0.3\nTitanium Studio, build: 3.2.0.201312191547\n", "updateAuthor": { "name": "shameerj", "key": "shameerj", "displayName": "Shameer Jan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-24T11:06:23.000+0000", "updated": "2014-01-24T11:06:23.000+0000" }, { "id": "291256", "author": { "name": "wluu", "key": "wluu", "displayName": "Wilson Luu", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Was not able to reproduce the issue i.e. iOS does not crash when injecting javascript via webview url. \n\nI did notice this error in the Xcode console:\n{code}\n[ERROR] Error loading: http://chicago.craigslist.org/, Error: Error Domain=WebKitErrorDomain Code=101 \"The operation couldn’t be completed. (WebKitErrorDomain error 101.)\"\n{code}\n\n\nTested on:\n\nAppcelerator Studio, build: 3.2.1.201401311225\nSDK build: 3.2.0.GA, 3.2.1.v20140203174850 \nCLI: 3.2.1-beta3\nAlloy: 1.3.1-cr\nXcode: 5.0.2\nDevices: iphone 5 (6.1.3), iphone 5s (7.0.2), iphone simulator (6.1), iphone simulator (7.0.3)\n", "updateAuthor": { "name": "wluu", "key": "wluu", "displayName": "Wilson Luu", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-02-04T22:52:59.000+0000", "updated": "2014-02-04T22:52:59.000+0000" }, { "id": "415380", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Can verify this ticket as \"Cannot Reproduce\". Tested with the following environment;\r\niPhone 7 and Simulator (10.2)\r\nMacOS 10.11.6 (15G31)\r\nStudio 4.8.1.201612050850\r\nTi SDK 6.0.3 GA\r\nAppc NPM 4.2.8\r\nAppc CLI 6.1.0\r\nTi CLI 5.0.11\r\nAlloy 1.9.5\r\nArrow 1.10.1\r\nXcode 8.2 (8C38)\r\nNode v4.6.0\r\nJava 1.7.0_80", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-23T21:13:27.000+0000", "updated": "2017-03-23T21:13:27.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }