<commit_before>describe("Unit tests for frameproxy boot.", function() {
	var rootUrl = "https://cors.localhost.com",
		oldAppName = undefined,
		expectedAppName = "Microsoft Internet Explorer",
		oldUserAgent = undefined,
		oldProxyClient = undefined;

	beforeEach(function() {
		BCAPI.Mocks.Helper.Site(undefined, undefined, rootUrl);
		
		oldAppName = navigator.appName;
		oldUserAgent = navigator.userAgent;
		oldProxyClient = frameproxy.ProxyClient;
	});
	
	afterEach(function() {
		navigator.appName = oldAppName;
		navigator.userAgent = oldUserAgent;
		frameproxy.ProxyClient = oldProxyClient;
	});
	
	function _mockNavigatorBrowser(appName, userAgent) {
		navigator.__defineGetter__("userAgent", function(){
		    return userAgent;
		});

		navigator.__defineGetter__("appName", function(){
		    return appName;
		});
	}
	
	function _mockIEUserAgent(ieVersion) {
		var userAgent = "Mozilla/4.0 (compatible; MSIE " + ieVersion + "; Windows NT 6.2; Trident/6.0)";
		
		_mockNavigatorBrowser(expectedAppName, userAgent);
	};
	
	function _testProxyWorksOnIe(ieVersion) {
		var cacheEnabled = true,
			jQuery = {ajaxSetup: function(options) {
				cacheEnabled = options.cache;
			}},
			corsBoot = new BCAPI.Helper.CORS.CorsBoot(jQuery, rootUrl),
			expectedUrl = rootUrl + '/AdminConsoleXT/frameproxy.htm',
			wrapCalled = false;
		
		expect(corsBoot._jQuery).toBe(jQuery);
		expect(corsBoot._rootUrl).toBe(rootUrl);
		
		_mockIEUserAgent(ieVersion);
		
		frameproxy.ProxyClient = function(apiUrl) {
			expect(apiUrl).toBe(expectedUrl);
		};
		
		frameproxy.ProxyClient.prototype.wrapAll = function(enable) {
			expect(enable).toBe(true);
			wrapCalled = true;
		};
		
		corsBoot.boot();
		
		expect(wrapCalled).toBe(true);
		
		expect(jQuery.currentFrameProxy instanceof frameproxy.ProxyClient).toBe(true);
		expect(cacheEnabled).toBe(false);
	};
	
	it("Check proxy boot works as expected on IE 7.", function() {
		_testProxyWorksOnIe(7.0);
	});
	
	it("Check proxy boot works as expected on IE 8.", function() {
		_testProxyWorksOnIe(8.0);
	});<commit_msg>I generalized the test case for CORS boot.<commit_after>describe("Unit tests for frameproxy boot.", function() {
	var rootUrl = "https://cors.localhost.com",
		oldAppName = undefined,
		expectedAppName = "Microsoft Internet Explorer",
		oldUserAgent = undefined,
		oldProxyClient = undefined;

	beforeEach(function() {
		BCAPI.Mocks.Helper.Site(undefined, undefined, rootUrl);
		
		oldAppName = navigator.appName;
		oldUserAgent = navigator.userAgent;
		oldProxyClient = frameproxy.ProxyClient;
	});
	
	afterEach(function() {
		navigator.appName = oldAppName;
		navigator.userAgent = oldUserAgent;
		frameproxy.ProxyClient = oldProxyClient;
	});
	
	function _mockNavigatorBrowser(appName, userAgent) {
		navigator.__defineGetter__("userAgent", function(){
		    return userAgent;
		});

		navigator.__defineGetter__("appName", function(){
		    return appName;
		});
	}
	
	function _mockIEUserAgent(ieVersion) {
		var userAgent = "Mozilla/4.0 (compatible; MSIE " + ieVersion + "; Windows NT 6.2; Trident/6.0)";
		
		_mockNavigatorBrowser(expectedAppName, userAgent);
	};
	
	function _testProxy(results, appName, userAgent, ieVersion) {
		var cacheEnabled = true,
			jQuery = {ajaxSetup: function(options) {
				cacheEnabled = options.cache;
			}},
			corsBoot = new BCAPI.Helper.CORS.CorsBoot(jQuery, rootUrl),
			expectedUrl = rootUrl + '/AdminConsoleXT/frameproxy.htm',
			wrapCalled = false;
		
		expect(corsBoot._jQuery).toBe(jQuery);
		expect(corsBoot._rootUrl).toBe(rootUrl);
		
		if(ieVersion) {
			_mockIEUserAgent(ieVersion);
		} else {
			_mockNavigatorBrowser(appName, userAgent);
		}
		
		frameproxy.ProxyClient = function(apiUrl) {
			expect(apiUrl).toBe(expectedUrl);
		};
		
		frameproxy.ProxyClient.prototype.wrapAll = function(enable) {
			expect(enable).toBe(results.wrapAll);
			wrapCalled = true;
		};
		
		corsBoot.boot();
		
		expect(wrapCalled).toBe(results.wrapAll);
		
		if(results.wrapAll) {
			expect(jQuery.currentFrameProxy instanceof frameproxy.ProxyClient).toBe(true);
		} else {
			expect(jQuery.currentFrameProxy).toBe(undefined);			
		}
		
		expect(cacheEnabled).toBe(!results.wrapAll);
	}
	
	function _testProxyWorksOnIe(ieVersion) {
		var results = {"wrapAll": true};
		
		_testProxy(results, undefined, undefined, ieVersion);
	};
	
	it("Check proxy boot works as expected on IE 7.", function() {
		_testProxyWorksOnIe(7.0);
	});
	
	it("Check proxy boot works as expected on IE 8.", function() {
		_testProxyWorksOnIe(8.0);
	});
{'fraction_non_alphanumeric': 0.12751381215469612, 'fraction_numerical': 0.005303867403314917, 'mean_word_length': 4.4595898673100125, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, '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': '1525453', 'n_tokens_mistral': 1654, 'n_tokens_neox': 1430, 'n_words': 265}