From e83e5b7c293637ddb7bd5e5f768236d9edf5a4b2 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Tue, 4 May 2010 15:04:51 -0700 Subject: [PATCH 1/4] Only send open if we aren't already open --- Objective-J/CFHTTPRequest.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Objective-J/CFHTTPRequest.js b/Objective-J/CFHTTPRequest.js index de32c1897..d4007f585 100644 --- a/Objective-J/CFHTTPRequest.js +++ b/Objective-J/CFHTTPRequest.js @@ -92,6 +92,7 @@ if (!NativeRequest) GLOBAL(CFHTTPRequest) = function() { + this._isOpen = false; this._requestHeaders = {}; this._mimeType = null; @@ -207,6 +208,7 @@ CFHTTPRequest.prototype.overrideMimeType = function(/*String*/ aMimeType) CFHTTPRequest.prototype.open = function(/*String*/ aMethod, /*String*/ aURL, /*Boolean*/ isAsynchronous, /*String*/ aUser, /*String*/ aPassword) { + this._isOpen = true; this._URL = aURL; this._async = isAsynchronous; this._method = aMethod; @@ -217,19 +219,23 @@ CFHTTPRequest.prototype.open = function(/*String*/ aMethod, /*String*/ aURL, /*B CFHTTPRequest.prototype.send = function(/*Object*/ aBody) { - delete this._nativeRequest.onreadystatechange; - for (var i in this._requestHeaders) { if (this._requestHeaders.hasOwnProperty(i)) this._nativeRequest.setRequestHeader(i, this._requestHeaders[i]); } + if (!this._isOpen) + { + delete this._nativeRequest.onreadystatechange; + this._nativeRequest.open(this._method, this._URL, this._async, this._user, this._password); + this._nativeRequest.onreadystatechange = this._stateChangeHandler; + } + if (this._mimeType && "overrideMimeType" in this._nativeRequest) this._nativeRequest.overrideMimeType(this._mimeType); - this._nativeRequest.open(this._method, this._URL, this._async, this._user, this._password); - this._nativeRequest.onreadystatechange = this._stateChangeHandler; + this._isOpen = false; try { @@ -244,6 +250,7 @@ CFHTTPRequest.prototype.send = function(/*Object*/ aBody) CFHTTPRequest.prototype.abort = function() { + this._isOpen = false; return this._nativeRequest.abort(); } From e97af776a0fcec10593e9ae1b741aa02d6c1ba94 Mon Sep 17 00:00:00 2001 From: Tom Robinson Date: Tue, 4 May 2010 15:40:35 -0700 Subject: [PATCH 2/4] Fix press/flatten due to changes to CFHTTPRequest. --- CommonJS/lib/cappuccino/objj-flatten-additions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CommonJS/lib/cappuccino/objj-flatten-additions.js b/CommonJS/lib/cappuccino/objj-flatten-additions.js index 2b4781e62..4c69f133e 100644 --- a/CommonJS/lib/cappuccino/objj-flatten-additions.js +++ b/CommonJS/lib/cappuccino/objj-flatten-additions.js @@ -1,6 +1,7 @@ var URLCache = { }; +var CFHTTPRequest_open = CFHTTPRequest.prototype.open; CFHTTPRequest.prototype.open = function(/*String*/ method, /*String*/ url, /*Boolean*/ async, /*String*/ user, /*String*/ password) { var cachedRequest = CFHTTPRequest._lookupCachedRequest(url); @@ -13,7 +14,7 @@ CFHTTPRequest.prototype.open = function(/*String*/ method, /*String*/ url, /*Boo ObjectiveJ.determineAndDispatchHTTPRequestEvents(self); }; } - return this._nativeRequest.open(method, url, async, user, password); + return CFHTTPRequest_open.apply(this, arguments); } CFHTTPRequest._cacheRequest = function(/*CFURL|String*/ aURL, /*Number*/ status, /*Object*/ headers, /*String*/ body) From 4b775796be844e7f9c7dbdf75e26bba872b7b668 Mon Sep 17 00:00:00 2001 From: Tom Robinson Date: Tue, 4 May 2010 15:41:50 -0700 Subject: [PATCH 3/4] Add a test for capp gen, press, and flatten. --- Tests/Tools/ToolsTest.j | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Tests/Tools/ToolsTest.j diff --git a/Tests/Tools/ToolsTest.j b/Tests/Tools/ToolsTest.j new file mode 100644 index 000000000..6705affee --- /dev/null +++ b/Tests/Tools/ToolsTest.j @@ -0,0 +1,39 @@ +var OS = require("os"); +var FILE = require("file"); + +function cleanup() { + ["ToolsTestApp", "PressTestApp", "FlattenTestApp"].forEach(function(dir) { + if (FILE.isDirectory(dir)) + FILE.rmtree(dir); + }); +} + +@implementation ToolsTest : OJTestCase +{ +} + +- (void)setUp +{ + cleanup(); +} + +- (void)testTools +{ + var status; + + status = OS.system(["capp", "gen", "ToolsTestApp"]); + [self assert:status equals:0 message:"capp gen failed"]; + + status = OS.system(["press", "-f", "ToolsTestApp", "PressTestApp"]); + [self assert:status equals:0 message:"press failed"]; + + status = OS.system(["flatten", "-f", "ToolsTestApp", "FlattenTestApp"]); + [self assert:status equals:0 message:"flatten failed"]; +} + +- (void)tearDown +{ + cleanup(); +} + +@end From b5971eae95e45962958bf7263e02a454e5cf74ae Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Tue, 4 May 2010 19:08:23 -0700 Subject: [PATCH 4/4] Missed this, it's no longer needed. --- AppKit/Platform/DOM/CPPlatformWindow+DOM.j | 2 -- 1 file changed, 2 deletions(-) diff --git a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j index efb025890..7d4f519c7 100644 --- a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j +++ b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j @@ -130,8 +130,6 @@ var CPDOMEventGetClickCount, StopDOMEventPropagation, StopContextMenuDOMEventPropagation; -var _DOMEventGuard; - //right now we hard code q, w, r and t as keys to propogate //these aren't normal keycodes, they are with modifier key codes //might be mac only, we should investigate futher later.