Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13815] Blackberry: Can't identify functions via JS on Titanium proxy objects

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-05-31T23:09:54.000+0000
Affected Version/sRelease 3.1.0
Fix Version/s2013 Sprint 11 BB, 2013 Sprint 11, Release 3.2.0
ComponentsBlackBerry
Labelsn/a
ReporterTony Lukasavage
AssigneeJosh Roesslein
Created2013-05-10T15:19:18.000+0000
Updated2014-06-19T12:43:59.000+0000

Description

problem

When creating runtime unit tests for Alloy, I have a common expectation that I can identify an object as a Titanium proxy, and in certain cases can tell (roughly) what type of component that proxy is. The very basic code for this is as below:
// using a recent underscore.js
var _ = require('underscore')._

var someObject = Ti.UI.createWindow();

// (roughly) identify a Ti.UI.Window
if (_.isFunction(someObject.open)) {
    // this and other criteria ID this object as a Ti.UI.Window
}
The above code successfully identifies the 2 conditions on iOS, Android, and Mobileweb. On Blackberry though the conditions always return false. This has the dual problem of introducing a parity issue between BB and the other platforms, and it also breaks many of Alloy's runtime unit tests, making it very difficult to reliably test Blackberry builds.

expected

Blackberry should behave as the other platforms and return true for the function-based Titanium proxy checks.

Comments

  1. Josh Roesslein 2013-05-10

    applyProperties is not implemented on BlackBerry right now, so it will be undefined. addEventListener might be a better choice for detecting proxies at this moment for all platforms. We could probably implement this method (or at least stub it out) on BlackBerry as well which can be our action item for this ticket.
  2. Tony Lukasavage 2013-05-10

    Josh, this doesn't explain why it returns false though when I do isFunction() on a Window's open() function.
  3. Josh Roesslein 2013-05-10

    Looked into the typeof check of window.open() and it seems we are just returning a callable object rather than a normal function object instance. This is wrong and something we should address.
  4. Tony Lukasavage 2013-05-10

    thanks for digging in so quickly josh, much appreciated
  5. Josh Roesslein 2013-05-20

    Test Case

       var win = Ti.UI.createWindow();
       Ti.API.info('typeof win.open = ' + typeof(win.open));
       
    Expected: This log statement should be printed: "typeof win.open = function"
  6. Josh Roesslein 2013-05-20

    Created pull request [#43](https://github.com/appcelerator/titanium_mobile_blackberry/pull/43) for master.
  7. Samuel Dowse 2013-11-13

    Verified fixed on: Mac OSX 10.9 Mavericks Titanium Studio, build: 3.2.0.201311122225 Titanium SDK, build: 3.2.0.v20131113094843 CLI: 3.2.0 Alloy: 1.3.0 BlackBerry Simulator: 10.2.0.1791 BlackBerry identifies functions via JavaScript using Test Case provided in comments. Closing.

JSON Source