<commit_before>/*
 * Appcelerator Titanium Mobile
 * Copyright (c) 2011-2012 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.
 */

module.exports = new function() {
	var finish;
	var valueOf;
	this.init = function(testUtils) {
		finish = testUtils.finish;
		valueOf = testUtils.valueOf;
	}

	this.name = "ui";
	this.tests = [
		{name: "webviewEvalJSLockup", timeout: 10000},
		{name: "webviewBindingUnavailable", timeout: 15000},
		{name: "webviewBindingAvailable", timeout: 10000},
		{name: "webviewBindingAvailableAfterSetHtml", timeout: 10000},
		{name: "dotslashWindow"},
		{name: "absoluteAndRelativeWinURLs", timeout: 10000},
		{name: "appendRowWithHeader"},
		{name: "appendRowAsArray"},
		{name: "opacityCrash"},
		{name: "windowOrientation"},
		{name: "windowPixelFormat"},
		{name: "convertPointToView"},
		{name: "imageLoadEvent", timeout: 10000},
		{name: "tabWindowNull"},
		{name: "deleteCorrectRowIndex", timeout: 3000},
		{name: "childrenArrayEmpty"}
	]

	// https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobile/tickets/2583
	this.webviewEvalJSLockup = function(testRun) {
		var w = Ti.UI.createWindow();
		w.open();
		var wv = Ti.UI.createWebView({top: 0, width: 10, height: 10, url: 'test.html'});
		var listener = function(){
			valueOf(testRun, wv.evalJS('Mickey')).shouldBe('');
			//w.close();

			finish(testRun);
		};
		wv.addEventListener('load', listener);
		w.add(wv);
	}

	//https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobile/tickets/1036
	this.webviewBindingUnavailable = function(testRun) {
		var w = Ti.UI.createWindow();
		w.open();
		var wv = Ti.UI.createWebView({top: 0, width: 10, height: 10, url: 'http://www.google.com'});
		var listener = function(){
			valueOf(testRun, wv.evalJS('Titanium')).shouldBe('');
			//w.close();

			finish(testRun);
		};
		wv.addEventListener('load', listener);
		w.add(wv);
	}

	// https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobile/tickets/2153
	this.webviewBindingAvailable = function(testRun) {
		var w = Ti.UI.createWindow();
		w.open();
		var wv = Ti.UI.createWebView({top: 0, width: 10, height: 10, url: 'test.html'});
		var listener = function(){
			valueOf(testRun, wv.evalJS('typeof Titanium')).shouldBe('object');
			//w.close();

			finish(testRun);
		};
		wv.addEventListener('load', listener);
		w.add(wv);
	}

	this.webviewBindingAvailableAfterSetHtml = function(testRun) {
		var w = Ti.UI.createWindow();
		w.open();
		var wv = Ti.UI.createWebView({top: 0, width: 10, height: 10});
		var listener = function(){
			valueOf(testRun, wv.evalJS('typeof Titanium')).shouldBe('object');
			//w.close();

			finish(testRun);
		};
		wv.addEventListener('load', listener);
		w.add(wv);
		wv.html = "<html><body>x</body></html>";
	}

	//https://appcelerator.lighthouseapp.com/projects/32238/tickets/2443-android-paths-beginning-with-are-not-recognised
	this.dotslashWindow = function(testRun) {
		var w = Ti.UI.createWindow({url:'./testwin.js'});
		valueOf(testRun, function(){w.open();}).shouldNotThrowException();

		finish(testRun);
	}

	// https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobile/tickets/2230-android-resolve-url-failing-from-event-context#ticket-2230-6
	this.absoluteAndRelativeWinURLs = function(testRun) {
		var w = Ti.UI.createWindow({ url: 'dir/relative.js' });
		w.addEventListener("close", function() {
			valueOf(testRun, true).shouldBe(true);

			finish(testRun);
		});<commit_msg>Anvil. Revert ui.js to mobileweb version.<commit_after>/*
 * Appcelerator Titanium Mobile
 * Copyright (c) 2011-2012 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.
 */

module.exports = new function() {
	var finish;
	var valueOf;
	this.init = function(testUtils) {
		finish = testUtils.finish;
		valueOf = testUtils.valueOf;
	}

	this.name = "ui";
	this.tests = [
		{name: "webviewEvalJSLockup", timeout: 10000},
		{name: "webviewBindingUnavailable", timeout: 15000},
		{name: "webviewBindingAvailable", timeout: 10000},
		{name: "webviewBindingAvailableAfterSetHtml", timeout: 10000},
		{name: "webviewFireEvent", timeout: 10000},
		{name: "dotslashWindow"},
		{name: "absoluteAndRelativeWinURLs", timeout: 10000},
		{name: "appendRowWithHeader"},
		{name: "appendRowAsArray"},
		{name: "opacityCrash"},
		{name: "windowOrientation"},
		{name: "windowPixelFormat"},
		{name: "convertPointToView"},
		{name: "imageLoadEvent", timeout: 10000},
		{name: "tabWindowNull"},
		{name: "deleteCorrectRowIndex", timeout: 3000},
		{name: "childrenArrayEmpty"}
	]

	// https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobile/tickets/2583
	this.webviewEvalJSLockup = function(testRun) {
		var w = Ti.UI.createWindow();
		w.open();
		var wv = Ti.UI.createWebView({top: 0, width: 10, height: 10, url: 'test.html'});
		var listener = function(){
			valueOf(testRun, wv.evalJS('Mickey')).shouldBe('');
			//w.close();

			finish(testRun);
		};
		wv.addEventListener('load', listener);
		w.add(wv);
	}

	//https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobile/tickets/1036
	this.webviewBindingUnavailable = function(testRun) {
		var w = Ti.UI.createWindow();
		w.open();
		var wv = Ti.UI.createWebView({top: 0, width: 10, height: 10, url: 'http://www.google.com'});
		var listener = function(){
			valueOf(testRun, wv.evalJS('Titanium')).shouldBe('');
			//w.close();

			finish(testRun);
		};
		wv.addEventListener('load', listener);
		w.add(wv);
	}

	// https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobile/tickets/2153
	this.webviewBindingAvailable = function(testRun) {
		var w = Ti.UI.createWindow();
		w.open();
		var wv = Ti.UI.createWebView({top: 0, width: 10, height: 10, url: 'test.html'});
		var listener = function(){
			valueOf(testRun, wv.evalJS('typeof Titanium')).shouldBe('object');
			//w.close();

			finish(testRun);
		};
		wv.addEventListener('load', listener);
		w.add(wv);
	}

	this.webviewBindingAvailableAfterSetHtml = function(testRun) {
		var w = Ti.UI.createWindow();
		w.open();
		var wv = Ti.UI.createWebView({top: 0, width: 10, height: 10});
		var listener = function(){
			valueOf(testRun, wv.evalJS('typeof Titanium')).shouldBe('object');
			//w.close();

			finish(testRun);
		};
		wv.addEventListener('load', listener);
		w.add(wv);
		wv.html = "<html><body>x</body></html>";
	}

	this.webviewFireEvent = function(testRun) {
		var w = Ti.UI.createWindow();
		w.open();

		function onEventFired(e) {
			valueOf(testRun, e.object).shouldBeObject();
			valueOf(testRun, e.object.string).shouldBeString();
			valueOf(testRun, e.object.number).shouldBeNumber();
			valueOf(testRun, e.object.nullObject).shouldBeNull();
			valueOf(testRun, e.object.array).shouldBeArray();

			valueOf(testRun, e.object.array.length).shouldBe(4);
			valueOf(testRun, e.object.array[0]).shouldBeObject();
			valueOf(testRun, e.object.array[1]).shouldBeString();
			valueOf(testRun, e.object.array[2]).shouldBeNumber();
			valueOf(testRun, e.object.array[3]).shouldBeNull();

			Ti.App.removeEventListener('webViewEvent', onEventFired);
			finish(testRun);
		}

		Ti.App.addEventListener('webViewEvent', onEventFired);

		var wv = Ti.UI.createWebView({url: 'test-fire-event.html'});
		w.add(wv);
	}

	//https://appcelerator.lighthouseapp.com/projects/32238/tickets/2443-android-paths-beginning-with-are-not-recognised
	this.dotslashWindow = function(testRun) {
		var w = Ti.UI.createWindow({url:'./testwin.js'});
		valueOf(testRun, function(){w.open();}).shouldNotThrowException();

		finish(testRun);
	}

	// https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobile/tickets/2230-android-resolve-url-failing-from-event-context#ticket-2230-6
	this.absoluteAndRelativeWinURLs = function(testRun) {
		var w = Ti.UI.createWindow({ url: 'dir/relative.js' });
		w.addEventListener("close", function() {
			valueOf(testRun, true).shouldBe(true);

			finish(testRun);
		});
{'fraction_non_alphanumeric': 0.1737094985832204, 'fraction_numerical': 0.028828384871257853, 'mean_word_length': 4.676923076923077, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 10, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7241872', 'n_tokens_mistral': 3239, 'n_tokens_neox': 2816, 'n_words': 497}