-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ios): avoid leaking objects in hasProperty callback (7_5_X) (#10525)
* fix(ios): avoid leaking objects in hasProperty callback * do it the objc way * add unit tests * add test for TIMOB-26452 * mark broken tests on android
- Loading branch information
1 parent
d012ae2
commit 639c9e6
Showing
3 changed files
with
217 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
* Appcelerator Titanium Mobile | ||
* Copyright (c) 2011-Present by Appcelerator, Inc. All Rights Reserved. | ||
* Licensed under the terms of the Apache Public License | ||
* Please see the LICENSE included with this distribution for details. | ||
*/ | ||
/* eslint-env mocha */ | ||
/* global Ti */ | ||
/* eslint no-unused-expressions: "off" */ | ||
|
||
'use strict'; | ||
|
||
var should = require('./utilities/assertions'); | ||
|
||
describe('Core', () => { | ||
describe('Runtime', () => { | ||
describe('hasProperty', () => { | ||
describe('Top-Module', () => { | ||
describe('Submodules', () => { | ||
// @fixme the not.have.property check throws an error on android | ||
it.androidBroken('should check for sub-module', () => { | ||
Ti.should.have.property('UI'); | ||
Ti.should.not.have.property('Foo'); | ||
}); | ||
}); | ||
|
||
describe('Custom properties', () => { | ||
// @fixme the not.have.property check throws an error on android | ||
it.androidBroken('should check for custom properties', () => { | ||
Ti.should.not.have.property('custom'); | ||
Ti.custom = {}; | ||
Ti.should.have.property('custom'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Proxy', () => { | ||
describe('Getter/Setter', () => { | ||
it('should check for existing getter method', () => { | ||
const tabGroup = Ti.UI.createTabGroup(); | ||
tabGroup.should.have.property('getTabs'); | ||
}); | ||
|
||
it.ios('should check for dynamic getter method', () => { | ||
const view = Ti.UI.createView(); | ||
view.should.have.property('getFoo'); | ||
}); | ||
|
||
it('should check for existing setter method', () => { | ||
const webView = Ti.UI.createWebView(); | ||
webView.should.have.property('setHtml'); | ||
}); | ||
|
||
it.ios('should check for dynamic setter method', () => { | ||
const view = Ti.UI.createView(); | ||
view.should.have.property('setFoo'); | ||
}); | ||
}); | ||
|
||
describe('Properties', () => { | ||
it('should check for properties on the object\'s target', () => { | ||
const view = Ti.UI.createView({ | ||
backgroundColor: 'black' | ||
}); | ||
view.should.not.have.property('bollocks'); | ||
view.should.have.property('backgroundColor'); | ||
}); | ||
|
||
it('should check for custom properties', () => { | ||
const view = Ti.UI.createView(); | ||
view.should.not.have.property('bollocks'); | ||
view.should.not.have.property('foo'); | ||
view.foo = 'bar'; | ||
view.should.have.property('foo'); | ||
view.foo.should.be.equal('bar'); | ||
}); | ||
|
||
it('should properly handle properties with value of nil (TIMOB-26452)', () => { | ||
should(Ti.Geolocation).have.property('lastGeolocation'); | ||
if (Ti.Platform.osname === 'android') { | ||
should(Ti.Geolocation.lastGeolocation).be.equal('{}'); | ||
} else { | ||
should.not.exist(Ti.Geolocation.lastGeolocation); | ||
} | ||
}); | ||
}); | ||
|
||
describe('toString/valueOf', () => { | ||
it('should be available on any proxy', () => { | ||
const view = Ti.UI.createView(); | ||
view.should.have.property('toString'); | ||
view.should.have.property('valueOf'); | ||
}); | ||
}); | ||
|
||
describe('className', () => { | ||
it.ios('should be availably on any proxy', () => { | ||
const view = Ti.UI.createView(); | ||
view.should.have.property('className'); | ||
}); | ||
}); | ||
|
||
describe('Methods', () => { | ||
it('should check for methods on the object\'s target', () => { | ||
const view = Ti.UI.createView(); | ||
view.should.not.have.property('addSomething'); | ||
view.should.have.property('add'); | ||
should(view.add).be.a.Function; | ||
}); | ||
}); | ||
|
||
describe('Factory Methods', () => { | ||
it('should check for dynamic create factory method', () => { | ||
Ti.UI.should.have.property('createView'); | ||
const view = Ti.UI.createView(); | ||
view.should.not.have.property('createSomething'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |