diff --git a/AppKit/CPApplication.j b/AppKit/CPApplication.j index 68b256c5f..63b1691a3 100644 --- a/AppKit/CPApplication.j +++ b/AppKit/CPApplication.j @@ -250,8 +250,13 @@ CPRunContinuesResponse = -1002; _documentController = [CPDocumentController sharedDocumentController]; var needsUntitled = !!_documentController, - URLStrings = window.cpOpeningURLStrings && window.cpOpeningURLStrings(), - index = 0, + URLStrings = nil; + +#if PLATFORM(DOM) + URLStrings = window.cpOpeningURLStrings && window.cpOpeningURLStrings(); +#endif + + var index = 0, count = [URLStrings count]; for (; index < count; ++index) @@ -1009,7 +1014,8 @@ CPRunContinuesResponse = -1002; */ - (CPArray)arguments { - if (_fullArgsString !== window.location.hash) + // FIXME This should probably not access the window object #if !PLATFORM(DOM), but the unit tests rely on it. + if (window && window.location && _fullArgsString !== window.location.hash) [self _reloadArguments]; return _args; @@ -1036,8 +1042,9 @@ CPRunContinuesResponse = -1002; if (!args || args.length == 0) { _args = []; +#if PLATFORM(DOM) window.location.hash = @"#"; - +#endif return; } @@ -1052,12 +1059,15 @@ CPRunContinuesResponse = -1002; var hash = [toEncode componentsJoinedByString:@"/"]; +#if PLATFORM(DOM) window.location.hash = @"#" + hash; +#endif } - (void)_reloadArguments { - _fullArgsString = window.location.hash; + // FIXME This should probably not access the window object #if !PLATFORM(DOM), but the unit tests rely on it. + _fullArgsString = (window && window.location) ? window.location.hash : ""; if (_fullArgsString.length) { diff --git a/AppKit/CPFontManager.j b/AppKit/CPFontManager.j index cee4f062d..cfeede594 100644 --- a/AppKit/CPFontManager.j +++ b/AppKit/CPFontManager.j @@ -99,6 +99,9 @@ var CPSharedFontManager = nil, { if (!_availableFonts) { + _availableFonts = []; + +#if PLATFORM(DOM) _CPFontDetectSpan = document.createElement("span"); _CPFontDetectSpan.fontSize = "24px"; _CPFontDetectSpan.appendChild(document.createTextNode("mmmmmmmmmml")); @@ -110,13 +113,16 @@ var CPSharedFontManager = nil, _CPFontDetectReferenceFonts = _CPFontDetectPickTwoDifferentFonts(["monospace", "serif", "sans-serif", "cursive"]); - _availableFonts = []; for (var i = 0; i < _CPFontDetectAllFonts.length; i++) { var available = _CPFontDetectFontAvailable(_CPFontDetectAllFonts[i]); if (available) _availableFonts.push(_CPFontDetectAllFonts[i]); } +#else + // If there's no font detection, just assume all fonts are available. + _availableFonts = _CPFontDetectAllFonts; +#endif } return _availableFonts; } diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index c1e14a813..ffd7de7e6 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -1858,7 +1858,7 @@ CPTexturedBackgroundWindowMask { // In Cocoa only resizable or titled windows return YES here by default. But the main browser window in Cappuccino // doesn't have these masks even that it's both titled and resizable, so we return YES when isFullPlatformWindow too. - return (_styleMask & CPResizableWindowMask) || (_styleMask & CPResizableWindowMask) || [self isFullPlatformWindow]; + return (_styleMask & CPTitledWindowMask) || (_styleMask & CPResizableWindowMask) || [self isFullPlatformWindow]; } /*! diff --git a/Foundation/CPTimer.j b/Foundation/CPTimer.j index 6edfa4818..19cca083b 100644 --- a/Foundation/CPTimer.j +++ b/Foundation/CPTimer.j @@ -254,6 +254,9 @@ var _CPTimerBridgeTimer = function(codeOrFunction, aDelay, shouldRepeat, functio theFunction = function() { codeOrFunction.apply(window, functionArgs); if (!shouldRepeat) CPTimersForTimeoutIDs[timeoutID] = nil; } } + // A call such as setTimeout(f) is technically invalid but browsers seem to treat it as setTimeout(f, 0), so so will we. + aDelay = aDelay | 0.0; + CPTimersForTimeoutIDs[timeoutID] = [CPTimer scheduledTimerWithTimeInterval:aDelay / 1000 callback:theFunction repeats:shouldRepeat]; return timeoutID; diff --git a/Tests/AppKit/CPApplicationTest.j b/Tests/AppKit/CPApplicationTest.j index 35b14ec98..f3ceefb57 100644 --- a/Tests/AppKit/CPApplicationTest.j +++ b/Tests/AppKit/CPApplicationTest.j @@ -195,7 +195,7 @@ globalResults = []; [[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveNotification:) name:CPApplicationWillTerminateNotification - object:nil]; + object:nil]; [app replyToApplicationShouldTerminate:CPTerminateNow]; [self assert:CPApplicationWillTerminateNotification equals:[globalResults[0] name]]; @@ -223,8 +223,8 @@ globalResults = []; - (void)testTargetForAction { - var mainWin = [[TestMainWindow alloc] init]; - var keyWin = [[TestKeyWindow alloc] init]; + var mainWin = [[TestMainWindow alloc] init], + keyWin = [[TestKeyWindow alloc] init]; mainWin._isVisible = YES; keyWin._isVisible = YES; [mainWin makeMainWindow]; @@ -252,6 +252,6 @@ globalResults = []; // when no target is given, targetForAction is called [self assert:app equals:[app targetForAction:@selector(someTestMethod:) to:nil from:nil]]; - } + @end