[TIMOB-11408] Android: Runtime error is thrown for require method when called from window opened via URL
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-01-29T23:37:31.000+0000 |
Affected Version/s | Release 3.0.0 |
Fix Version/s | Release 3.0.0, Release 3.1.0, 2012 Sprint 22 Core, 2012 Sprint 22, 2013 Sprint 03 API |
Components | Android |
Labels | core, qe-and100112, qe-port, regression |
Reporter | Shyam Bhadauria |
Assignee | Ping Wang |
Created | 2012-10-12T09:05:32.000+0000 |
Updated | 2013-02-04T07:14:20.000+0000 |
Description
This is a regression. It works fine on 2.1.3GA.
When the app is run, a runtime error is thrown - "Message: Uncaught ReferenceError: require is not defined". Log attached.
Steps to reproduce:
1. Use the following code in app.js
Ti.UI.createWindow({
url: "win.js", // causes new JS context
backgroundColor: "#000",
exitOnClose: true
}).open();
2. Create a file 'included.js' under 'Resources' folder and add the code below in it-
var includedWord = "YES";
3. Create another file win.js under 'Resources' folder and add the code below in it-
require("module"); // Don't need return value, just important that this runs.
Ti.include("included.js");
alert("Does this app work (YES/NO)? \nAnswer: " + includedWord);
4. Paste the attached file 'module.js' under the 'Resources' folder.
5. Run the app on android device.
Expected result:
App should display an alert 'Does this app work? YES!'
Actual result:
A runtime error is thrown. Error log attached.
Attachments
File | Date | Size |
---|---|---|
module.js | 2012-10-25T10:25:44.000+0000 | 42 |
TIMOB 5434.rtf | 2012-10-12T09:05:32.000+0000 | 1112 |
Created [PR #3244 ](https://github.com/appcelerator/titanium_mobile/pull/3244) to resolve issue on master.
Master merge done. Ready for 3.0.X PR. *Note for future testers*: The person who created the ticket didn#t include module.js, so success in this case actually means getting an error that the module is not found, as opposed to the error that require is not defined.
Created [PR #3252](https://github.com/appcelerator/titanium_mobile/pull/3252) to back port fix into 3_0_X.
3_0_X PR merged.
Please use the module.js attached (module_timob5434) to reproduce the issue along with other files.It still gives same error 'Message: Uncaught ReferenceError: require is not defined'. Tested it with : Titanium SDK:3.0.0.v20121024144610 Titanium Studio:3.0.0.201210220122
This should as a part of this PR: https://github.com/appcelerator/titanium_mobile/pull/3321
Its working fine now. Titanium SDK: 3.1.0.v20121119222601 Titanium SDK:3.0.0.v20121113170203 Titanium Studio:3.0.0.201211131839 Device : Android 2.2 LG-P970 Xcode : 4.5 Machine OS : MAC 10.8
This issue occurs again in the latest 3_0_X build: ffb007d573b779957baebb82895f7bf0b0f60d32
This regression is caused by [PR#3321](https://github.com/appcelerator/titanium_mobile/pull/3321) PR: https://github.com/appcelerator/titanium_mobile/pull/3818 For FR: 1. Run the test case in the ticket. It should run without any crash. 2. Run the test case below. It should run without any crash. The log should show: {quote} I/TiAPI (13592): ******************** module.text = I'm module I/TiAPI (13592): ******************** module.includedWord = YES I/TiAPI (13592): *************** inside module.x {quote} app.js
win.js
module.js
included.js
3. Run the test cases in TIMOB-10783, TIMOB-10091, TIMOB-11307, TIMOB-5748. 4. Run KS. 5. Run Anvil -> includes/includes test suite. simpleRequire, secondContextRequire, multipleRequire and includeFromUrlWindow should pass.
Tested with: SDK:3.0.2.v20130201161712 Studio: 3.0.2.201301281948 Device: iPhone3GS(v 5.0.1), iPhone5(v 6.0) No runtime error is thrown.