diff --git a/xpcom/io/nsLocalFileOSX.mm b/xpcom/io/nsLocalFileOSX.mm
index 670bfc2ab7f..83cdacafd13 100644
--- a/xpcom/io/nsLocalFileOSX.mm
+++ b/xpcom/io/nsLocalFileOSX.mm
@@ -2230,35 +2230,15 @@ NS_IMETHODIMP nsLocalFile::IsPackage(PRBool *_retval)
NS_ENSURE_ARG(_retval);
*_retval = PR_FALSE;
- FSRef fsRef;
- nsresult rv = GetFSRefInternal(fsRef);
- if (NS_FAILED(rv))
- return rv;
-
- FSCatalogInfo catalogInfo;
- OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoNodeFlags + kFSCatInfoFinderInfo,
- &catalogInfo, nsnull, nsnull, nsnull);
- if (err != noErr)
- return MacErrorMapper(err);
- if ((catalogInfo.nodeFlags & kFSNodeIsDirectoryMask) != 0) {
- FileInfo *fInfoPtr = (FileInfo *)(catalogInfo.finderInfo);
- if ((fInfoPtr->finderFlags & kHasBundle) != 0) {
- *_retval = PR_TRUE;
- }
- else {
- // Folders ending with ".app" are also considered to
- // be packages, even if the top-level folder doesn't have bundle set
- nsCAutoString name;
- if (NS_SUCCEEDED(rv = GetNativeLeafName(name))) {
- const char *extPtr = strrchr(name.get(), '.');
- if (extPtr) {
- if ((nsCRT::strcasecmp(extPtr, ".app") == 0))
- *_retval = PR_TRUE;
- }
- }
- }
+ CFURLRef urlRef;
+ if (NS_SUCCEEDED(GetCFURL(&urlRef)) && urlRef) {
+ *_retval = [[NSWorkspace sharedWorkspace] isFilePackageAtPath:[(NSURL *)urlRef path]];
+ ::CFRelease(urlRef);
+
+ return NS_OK;
}
- return NS_OK;
+
+ return NS_ERROR_FAILURE;
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}
diff --git a/xpcom/tests/unit/data/SmallApp.app/Contents/Info.plist b/xpcom/tests/unit/data/SmallApp.app/Contents/Info.plist
new file mode 100644
index 00000000000..8388fa2a558
--- /dev/null
+++ b/xpcom/tests/unit/data/SmallApp.app/Contents/Info.plist
@@ -0,0 +1,26 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ English
+ CFBundleExecutable
+ SmallApp
+ CFBundleIdentifier
+ com.yourcompany.SmallApp
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ SmallApp
+ CFBundlePackageType
+ APPL
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ 1.0
+ NSMainNibFile
+ MainMenu
+ NSPrincipalClass
+ NSApplication
+
+
diff --git a/xpcom/tests/unit/data/SmallApp.app/Contents/MacOS/SmallApp b/xpcom/tests/unit/data/SmallApp.app/Contents/MacOS/SmallApp
new file mode 100755
index 00000000000..c821003d341
Binary files /dev/null and b/xpcom/tests/unit/data/SmallApp.app/Contents/MacOS/SmallApp differ
diff --git a/xpcom/tests/unit/data/SmallApp.app/Contents/PkgInfo b/xpcom/tests/unit/data/SmallApp.app/Contents/PkgInfo
new file mode 100644
index 00000000000..bd04210fb49
--- /dev/null
+++ b/xpcom/tests/unit/data/SmallApp.app/Contents/PkgInfo
@@ -0,0 +1 @@
+APPL????
\ No newline at end of file
diff --git a/xpcom/tests/unit/data/SmallApp.app/Contents/Resources/English.lproj/InfoPlist.strings b/xpcom/tests/unit/data/SmallApp.app/Contents/Resources/English.lproj/InfoPlist.strings
new file mode 100644
index 00000000000..5e45963c382
Binary files /dev/null and b/xpcom/tests/unit/data/SmallApp.app/Contents/Resources/English.lproj/InfoPlist.strings differ
diff --git a/xpcom/tests/unit/data/SmallApp.app/Contents/Resources/English.lproj/MainMenu.nib/designable.nib b/xpcom/tests/unit/data/SmallApp.app/Contents/Resources/English.lproj/MainMenu.nib/designable.nib
new file mode 100644
index 00000000000..59f8803c5dd
--- /dev/null
+++ b/xpcom/tests/unit/data/SmallApp.app/Contents/Resources/English.lproj/MainMenu.nib/designable.nib
@@ -0,0 +1,343 @@
+
+
+
+ 0
+ 9E17
+ 644
+ 949.33
+ 352.00
+
+
+
+
+
+ YES
+
+
+ terminate:
+
+
+
+ 369
+
+
+
+
+ YES
+
+ 0
+
+ YES
+
+
+
+
+
+ -2
+
+
+ RmlsZSdzIE93bmVyA
+
+
+ -1
+
+
+ First Responder
+
+
+ -3
+
+
+ Application
+
+
+ 29
+
+
+ YES
+
+
+
+
+
+
+
+
+
+ MainMenu
+
+
+ 19
+
+
+ YES
+
+
+
+
+ 56
+
+
+ YES
+
+
+
+
+
+ 103
+
+
+ YES
+
+
+ 1
+
+
+ 217
+
+
+ YES
+
+
+
+
+ 83
+
+
+ YES
+
+
+
+
+ 57
+
+
+ YES
+
+
+
+
+
+ 136
+
+
+ 1111
+
+
+ 295
+
+
+ YES
+
+
+
+
+ 299
+
+
+ YES
+
+
+
+
+
+
+ YES
+
+ YES
+ -1.IBPluginDependency
+ -2.IBPluginDependency
+ -3.IBPluginDependency
+ 103.IBPluginDependency
+ 103.ImportedFromIB2
+ 136.IBPluginDependency
+ 136.ImportedFromIB2
+ 19.IBPluginDependency
+ 19.ImportedFromIB2
+ 217.IBPluginDependency
+ 217.ImportedFromIB2
+ 29.IBEditorWindowLastContentRect
+ 29.IBPluginDependency
+ 29.ImportedFromIB2
+ 29.WindowOrigin
+ 29.editorWindowContentRectSynchronizationRect
+ 295.IBPluginDependency
+ 299.IBPluginDependency
+ 56.IBPluginDependency
+ 56.ImportedFromIB2
+ 57.IBEditorWindowLastContentRect
+ 57.IBPluginDependency
+ 57.ImportedFromIB2
+ 57.editorWindowContentRectSynchronizationRect
+ 83.IBPluginDependency
+ 83.ImportedFromIB2
+
+
+ YES
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilderKit
+ com.apple.InterfaceBuilderKit
+ com.apple.InterfaceBuilder.CocoaPlugin
+
+ com.apple.InterfaceBuilder.CocoaPlugin
+
+ com.apple.InterfaceBuilder.CocoaPlugin
+
+ com.apple.InterfaceBuilder.CocoaPlugin
+
+ {{0, 975}, {478, 20}}
+ com.apple.InterfaceBuilder.CocoaPlugin
+
+ {74, 862}
+ {{6, 978}, {478, 20}}
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+
+ {{12, 952}, {218, 23}}
+ com.apple.InterfaceBuilder.CocoaPlugin
+
+ {{23, 794}, {245, 183}}
+ com.apple.InterfaceBuilder.CocoaPlugin
+
+
+
+
+ YES
+
+ YES
+
+
+ YES
+
+
+
+
+ YES
+
+ YES
+
+
+ YES
+
+
+
+ 374
+
+
+ 0
+ ../SmallApp.xcodeproj
+ 3
+
+
diff --git a/xpcom/tests/unit/data/SmallApp.app/Contents/Resources/English.lproj/MainMenu.nib/keyedobjects.nib b/xpcom/tests/unit/data/SmallApp.app/Contents/Resources/English.lproj/MainMenu.nib/keyedobjects.nib
new file mode 100644
index 00000000000..bb27d4a5d62
Binary files /dev/null and b/xpcom/tests/unit/data/SmallApp.app/Contents/Resources/English.lproj/MainMenu.nib/keyedobjects.nib differ
diff --git a/xpcom/tests/unit/data/presentation.key/.typeAttributes.dict b/xpcom/tests/unit/data/presentation.key/.typeAttributes.dict
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/xpcom/tests/unit/data/presentation.key/Contents/PkgInfo b/xpcom/tests/unit/data/presentation.key/Contents/PkgInfo
new file mode 100644
index 00000000000..b0bc8e0761a
--- /dev/null
+++ b/xpcom/tests/unit/data/presentation.key/Contents/PkgInfo
@@ -0,0 +1 @@
+????????
\ No newline at end of file
diff --git a/xpcom/tests/unit/data/presentation.key/index.apxl.gz b/xpcom/tests/unit/data/presentation.key/index.apxl.gz
new file mode 100644
index 00000000000..26178d809e1
Binary files /dev/null and b/xpcom/tests/unit/data/presentation.key/index.apxl.gz differ
diff --git a/xpcom/tests/unit/data/presentation.key/thumbs/st0.tiff b/xpcom/tests/unit/data/presentation.key/thumbs/st0.tiff
new file mode 100644
index 00000000000..8b49316b4d2
Binary files /dev/null and b/xpcom/tests/unit/data/presentation.key/thumbs/st0.tiff differ
diff --git a/xpcom/tests/unit/test_mac_bundle.js b/xpcom/tests/unit/test_mac_bundle.js
new file mode 100644
index 00000000000..484ef89b93c
--- /dev/null
+++ b/xpcom/tests/unit/test_mac_bundle.js
@@ -0,0 +1,18 @@
+function run_test() {
+ // this is a hack to skip the rest of the code on non-Mac platforms,
+ // since #ifdef is not available to xpcshell tests...
+ var thisFile = do_get_file("xpcom/tests/unit/test_mac_bundle.js");
+ if (!thisFile instanceof Components.interfaces.nsILocalFileMac)
+ return;
+
+ // OK, here's the real part of the test:
+ // make sure these two test bundles are recognized as bundles (or "packages")
+ var keynoteBundle = do_get_file("xpcom/tests/unit/data/presentation.key");
+ var appBundle = do_get_file("xpcom/tests/unit/data/SmallApp.app");
+
+ do_check_true(keynoteBundle instanceof Components.interfaces.nsILocalFileMac);
+ do_check_true(appBundle instanceof Components.interfaces.nsILocalFileMac);
+
+ do_check_true(keynoteBundle.isPackage());
+ do_check_true(appBundle.isPackage());
+}