diff --git a/dom/base/nsIObjectLoadingContent.idl b/dom/base/nsIObjectLoadingContent.idl index 6cf0c535f1..953a259118 100644 --- a/dom/base/nsIObjectLoadingContent.idl +++ b/dom/base/nsIObjectLoadingContent.idl @@ -25,7 +25,7 @@ class nsNPAPIPluginInstance; * interface to mirror this interface when changing it. */ -[scriptable, uuid(5efbd411-5bbe-4de1-9f3a-1c3459696eb2)] +[scriptable, uuid(2eb3195e-3eea-4083-bb1d-d2d70fa35ccb)] interface nsIObjectLoadingContent : nsISupports { /** @@ -65,8 +65,6 @@ interface nsIObjectLoadingContent : nsISupports const unsigned long PLUGIN_VULNERABLE_UPDATABLE = 9; // The plugin is vulnerable (no update available) const unsigned long PLUGIN_VULNERABLE_NO_UPDATE = 10; - // The plugin is in play preview mode - const unsigned long PLUGIN_PLAY_PREVIEW = 11; /** * The actual mime type (the one we got back from the network @@ -128,8 +126,7 @@ interface nsIObjectLoadingContent : nsISupports in boolean submittedCrashReport); /** - * This method will play a plugin that has been stopped by the - * click-to-play plugins or play-preview features. + * This method will play a plugin that has been stopped by click-to-play. */ void playPlugin(); @@ -144,7 +141,7 @@ interface nsIObjectLoadingContent : nsISupports /** * This attribute will return true if the current content type has been * activated, either explicitly or by passing checks that would have it be - * click-to-play or play-preview. + * click-to-play. */ readonly attribute boolean activated; @@ -184,11 +181,6 @@ interface nsIObjectLoadingContent : nsISupports */ readonly attribute bool hasRunningPlugin; - /** - * This method will disable the play-preview plugin state. - */ - void cancelPlayPreview(); - /** * If this plugin runs out-of-process, it has a runID to differentiate * between different times the plugin process has been instantiated. diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index c30760854a..bf0ecdd811 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -709,7 +709,6 @@ nsObjectLoadingContent::nsObjectLoadingContent() , mInstantiating(false) , mNetworkCreated(true) , mActivated(false) - , mPlayPreviewCanceled(false) , mIsStopping(false) , mIsLoading(false) , mScriptRequested(false) {} @@ -1411,8 +1410,6 @@ nsObjectLoadingContent::ObjectState() const return NS_EVENT_STATE_USERDISABLED; case eFallbackClickToPlay: return NS_EVENT_STATE_TYPE_CLICK_TO_PLAY; - case eFallbackPlayPreview: - return NS_EVENT_STATE_TYPE_PLAY_PREVIEW; case eFallbackDisabled: return NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_HANDLER_DISABLED; case eFallbackBlocklisted: @@ -3112,7 +3109,7 @@ nsObjectLoadingContent::PlayPlugin() LOG(("OBJLC [%p]: Activated by user", this)); } - // If we're in a click-to-play or play preview state, we need to reload + // If we're in a click-to-play state, reload. // Fallback types >= eFallbackClickToPlay are plugin-replacement types, see // header if (mType == eType_Null && mFallbackType >= eFallbackClickToPlay) { @@ -3127,7 +3124,6 @@ nsObjectLoadingContent::Reload(bool aClearActivation) { if (aClearActivation) { mActivated = false; - mPlayPreviewCanceled = false; } return LoadObject(true, true); @@ -3167,22 +3163,6 @@ nsObjectLoadingContent::GetHasRunningPlugin(bool *aHasPlugin) return NS_OK; } -NS_IMETHODIMP -nsObjectLoadingContent::CancelPlayPreview() -{ - if (!nsContentUtils::IsCallerChrome()) - return NS_ERROR_NOT_AVAILABLE; - - mPlayPreviewCanceled = true; - - // If we're in play preview state already, reload - if (mType == eType_Null && mFallbackType == eFallbackPlayPreview) { - return LoadObject(true, true); - } - - return NS_OK; -} - NS_IMETHODIMP nsObjectLoadingContent::GetRunID(uint32_t* aRunID) { @@ -3233,31 +3213,6 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp RefPtr pluginHost = nsPluginHost::GetInst(); - nsCOMPtr playPreviewInfo; - bool isPlayPreviewSpecified = NS_SUCCEEDED(pluginHost->GetPlayPreviewInfo( - mContentType, getter_AddRefs(playPreviewInfo))); - if (isPlayPreviewSpecified) { - // Checking PlayPreview whitelist as well. - nsCString uriSpec, baseSpec; - if (mURI) { - mURI->GetSpec(uriSpec); - } - if (mBaseURI) { - mBaseURI->GetSpec(baseSpec); - } - playPreviewInfo->CheckWhitelist(baseSpec, uriSpec, &isPlayPreviewSpecified); - } - bool ignoreCTP = false; - if (isPlayPreviewSpecified) { - playPreviewInfo->GetIgnoreCTP(&ignoreCTP); - } - if (isPlayPreviewSpecified && !mPlayPreviewCanceled && - ignoreCTP) { - // play preview in ignoreCTP mode is shown even if the native plugin - // is not present/installed - aReason = eFallbackPlayPreview; - return false; - } // at this point if it's not a plugin, we let it play/fallback if (!aIgnoreCurrentType && mType != eType_Plugin) { return true; @@ -3267,8 +3222,6 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp // * Assume a default of click-to-play // * If globally disabled, per-site permissions cannot override. // * If blocklisted, override the reason with the blocklist reason - // * If not blocklisted but playPreview, override the reason with the - // playPreview reason. // * Check per-site permissions and follow those if specified. // * Honor per-plugin disabled permission // * Blocklisted plugins are forced to CtP @@ -3285,8 +3238,9 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp } // Before we check permissions, get the blocklist state of this plugin to set - // the fallback reason correctly. - uint32_t blocklistState = nsIBlocklistService::STATE_NOT_BLOCKED; + // the fallback reason correctly. In the content process this will involve + // an ipc call to chrome. + uint32_t blocklistState = nsIBlocklistService::STATE_BLOCKED; pluginHost->GetBlocklistStateForType(mContentType, nsPluginHost::eExcludeNone, &blocklistState); @@ -3303,12 +3257,6 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp aReason = eFallbackVulnerableNoUpdate; } - if (aReason == eFallbackClickToPlay && isPlayPreviewSpecified && - !mPlayPreviewCanceled && !ignoreCTP) { - // play preview in click-to-play mode is shown instead of standard CTP UI - aReason = eFallbackPlayPreview; - } - // Check the permission manager for permission based on the principal of // the toplevel content. diff --git a/dom/base/nsObjectLoadingContent.h b/dom/base/nsObjectLoadingContent.h index e8516d6779..19d5c6ca5a 100644 --- a/dom/base/nsObjectLoadingContent.h +++ b/dom/base/nsObjectLoadingContent.h @@ -94,9 +94,6 @@ class nsObjectLoadingContent : public nsImageLoadingContent eFallbackVulnerableUpdatable = nsIObjectLoadingContent::PLUGIN_VULNERABLE_UPDATABLE, // The plugin is vulnerable (no update available) eFallbackVulnerableNoUpdate = nsIObjectLoadingContent::PLUGIN_VULNERABLE_NO_UPDATE, - // The plugin is disabled and play preview content is displayed until - // the extension code enables it by sending the MozPlayPlugin event - eFallbackPlayPreview = nsIObjectLoadingContent::PLUGIN_PLAY_PREVIEW }; nsObjectLoadingContent(); @@ -225,10 +222,6 @@ class nsObjectLoadingContent : public nsImageLoadingContent { return !!mInstanceOwner; } - void CancelPlayPreview(mozilla::ErrorResult& aRv) - { - aRv = CancelPlayPreview(); - } void SwapFrameLoaders(nsXULElement& aOtherOwner, mozilla::ErrorResult& aRv) { aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); @@ -622,16 +615,13 @@ class nsObjectLoadingContent : public nsImageLoadingContent // activated by PlayPlugin(). (see ShouldPlay()) bool mActivated : 1; - // Used to keep track of whether or not a plugin is blocked by play-preview. - bool mPlayPreviewCanceled : 1; - // Protects DoStopPlugin from reentry (bug 724781). bool mIsStopping : 1; // Protects LoadObject from re-entry bool mIsLoading : 1; - // For plugin stand-in types (click-to-play, play preview, ...) tracks + // For plugin stand-in types (click-to-play) tracks // whether content js has tried to access the plugin script object. bool mScriptRequested : 1; diff --git a/dom/events/EventStates.h b/dom/events/EventStates.h index f869919db4..fe8f0315b2 100644 --- a/dom/events/EventStates.h +++ b/dom/events/EventStates.h @@ -262,8 +262,6 @@ private: #define NS_EVENT_STATE_LTR NS_DEFINE_EVENT_STATE_MACRO(42) // Element is rtl (for :dir pseudo-class) #define NS_EVENT_STATE_RTL NS_DEFINE_EVENT_STATE_MACRO(43) -// Handler for play preview plugin -#define NS_EVENT_STATE_TYPE_PLAY_PREVIEW NS_DEFINE_EVENT_STATE_MACRO(44) // Element is highlighted (devtools inspector) #define NS_EVENT_STATE_DEVTOOLS_HIGHLIGHTED NS_DEFINE_EVENT_STATE_MACRO(45) // Element is an unresolved custom element candidate diff --git a/dom/indexedDB/ActorsChild.cpp b/dom/indexedDB/ActorsChild.cpp index 53a550ccb5..1b9ebff79f 100644 --- a/dom/indexedDB/ActorsChild.cpp +++ b/dom/indexedDB/ActorsChild.cpp @@ -830,14 +830,14 @@ class WorkerPermissionChallenge; // This class calles WorkerPermissionChallenge::OperationCompleted() in the // worker thread. -class WorkerPermissionOperationCompleted final : public WorkerRunnable +class WorkerPermissionOperationCompleted final : public WorkerControlRunnable { RefPtr mChallenge; public: WorkerPermissionOperationCompleted(WorkerPrivate* aWorkerPrivate, WorkerPermissionChallenge* aChallenge) - : WorkerRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount) + : WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount) , mChallenge(aChallenge) { MOZ_ASSERT(NS_IsMainThread()); @@ -943,11 +943,7 @@ public: RefPtr runnable = new WorkerPermissionOperationCompleted(mWorkerPrivate, this); - if (!runnable->Dispatch(nullptr)) { - NS_WARNING("Failed to dispatch a runnable to the worker thread."); - return; - } - + MOZ_ALWAYS_TRUE(runnable->Dispatch(nullptr)); return; } @@ -1419,7 +1415,7 @@ BackgroundFactoryRequestChild::RecvPermissionChallenge( JSContext* cx = workerPrivate->GetJSContext(); MOZ_ASSERT(cx); - if (!workerPrivate->AddFeature(cx, challenge)) { + if (NS_WARN_IF(!workerPrivate->AddFeature(cx, challenge))) { return false; } @@ -1441,7 +1437,9 @@ BackgroundFactoryRequestChild::RecvPermissionChallenge( nsCOMPtr ownerElement = do_QueryInterface(window->GetChromeEventHandler()); if (NS_WARN_IF(!ownerElement)) { - return false; + // If this fails, the page was navigated. Fail the permission check by + // forcing an immediate retry. + return SendPermissionRetry(); } RefPtr helper = diff --git a/dom/indexedDB/IDBFactory.cpp b/dom/indexedDB/IDBFactory.cpp index fbbdecc587..38fd07f5ae 100644 --- a/dom/indexedDB/IDBFactory.cpp +++ b/dom/indexedDB/IDBFactory.cpp @@ -133,10 +133,8 @@ IDBFactory::CreateForWindow(nsPIDOMWindow* aWindow, if (!(NS_SUCCEEDED(rv) && nsContentUtils::IsSystemPrincipal(principal)) && NS_WARN_IF(!Preferences::GetBool(kPrefIndexedDBEnabled, false))) { - // IndexedDB is disabled and the caller is content. - NS_WARNING("An attempt to use IndexedDB was made, but it is not enabled."); *aFactory = nullptr; - return NS_OK; + return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; } if (rv == NS_ERROR_DOM_NOT_SUPPORTED_ERR) { @@ -685,8 +683,6 @@ IDBFactory::OpenInternal(nsIPrincipal* aPrincipal, } if (!mBackgroundActor && mPendingRequests.IsEmpty()) { - // We need to start the sequence to create a background actor for this - // thread. BackgroundChildImpl::ThreadLocal* threadLocal = BackgroundChildImpl::GetThreadLocalForCurrentThread(); @@ -706,12 +702,18 @@ IDBFactory::OpenInternal(nsIPrincipal* aPrincipal, newIDBThreadLocal = idbThreadLocal = new ThreadLocal(id); } - RefPtr cb = - new BackgroundCreateCallback(this, idbThreadLocal->GetLoggingInfo()); - if (NS_WARN_IF(!BackgroundChild::GetOrCreateForCurrentThread(cb))) { - IDB_REPORT_INTERNAL_ERR(); - aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - return nullptr; + if (PBackgroundChild* actor = BackgroundChild::GetForCurrentThread()) { + BackgroundActorCreated(actor, idbThreadLocal->GetLoggingInfo()); + } else { + // We need to start the sequence to create a background actor for this + // thread. + RefPtr cb = + new BackgroundCreateCallback(this, idbThreadLocal->GetLoggingInfo()); + if (NS_WARN_IF(!BackgroundChild::GetOrCreateForCurrentThread(cb))) { + IDB_REPORT_INTERNAL_ERR(); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } } if (newIDBThreadLocal) { diff --git a/dom/plugins/base/moz.build b/dom/plugins/base/moz.build index bc1fcb7293..c4aea79c59 100644 --- a/dom/plugins/base/moz.build +++ b/dom/plugins/base/moz.build @@ -30,7 +30,6 @@ EXPORTS += [ 'nsPluginLogging.h', 'nsPluginNativeWindow.h', 'nsPluginNativeWindowGtk.h', - 'nsPluginPlayPreviewInfo.h', 'nsPluginsCID.h', 'nsPluginsDir.h', 'nsPluginTags.h', @@ -46,7 +45,6 @@ UNIFIED_SOURCES += [ 'nsNPAPIPluginStreamListener.cpp', 'nsPluginInstanceOwner.cpp', 'nsPluginModule.cpp', - 'nsPluginPlayPreviewInfo.cpp', 'nsPluginStreamListenerPeer.cpp', 'nsPluginTags.cpp', 'PluginPRLibrary.cpp', diff --git a/dom/plugins/base/nsIPluginHost.idl b/dom/plugins/base/nsIPluginHost.idl index 7c1feb9691..9d037a7d1d 100644 --- a/dom/plugins/base/nsIPluginHost.idl +++ b/dom/plugins/base/nsIPluginHost.idl @@ -12,22 +12,7 @@ "@mozilla.org/plugin/host;1" %} -[scriptable, uuid(57069ada-2845-46ef-b57f-233596d1c02c)] -interface nsIPluginPlayPreviewInfo : nsISupports -{ - readonly attribute AUTF8String mimeType; - readonly attribute boolean ignoreCTP; - readonly attribute AUTF8String redirectURL; - readonly attribute AUTF8String whitelist; - - /** - * Checks if pageURI and objectURI matches once of the entries in - * the whitelist. If whitelist is empty, returns true. - */ - boolean checkWhitelist(in AUTF8String pageURI, in AUTF8String objectURI); -}; - -[scriptable, uuid(50677599-323f-4c7d-a450-307bdb7acbf0)] +[scriptable, uuid(f938f5ba-7093-42cd-a559-af8039d99204)] interface nsIPluginHost : nsISupports { /** @@ -92,27 +77,6 @@ interface nsIPluginHost : nsISupports */ boolean siteHasData(in nsIPluginTag plugin, in AUTF8String domain); - /** - * Registers the play preview plugin mode for specific mime type - * - * @param mimeType: specifies plugin mime type. - * @param ignoreCTP: if true, the play preview ignores CTP rules, e.g. - whitelisted websites, will not notify about plugin - presence in the address bar. - * @param redirectURL: specifies url for the overlay iframe - * @param whitelist: specifies plugin whitelist in form of comma separated - * "[@page_url object_url|@page_url|object_url]" entries, - * e.g. @http://example.org/* http://example.org/t.swf - */ - void registerPlayPreviewMimeType(in AUTF8String mimeType, - [optional] in boolean ignoreCTP, - [optional] in AUTF8String redirectURL, - [optional] in AUTF8String whitelist); - - void unregisterPlayPreviewMimeType(in AUTF8String mimeType); - - nsIPluginPlayPreviewInfo getPlayPreviewInfo(in AUTF8String mimeType); - /** * Get the "permission string" for the plugin. This is a string that can be * passed to the permission manager to see whether the plugin is allowed to @@ -183,10 +147,4 @@ interface nsIPluginHost : nsISupports * passed in the FakePluginTagInit when registering. */ void unregisterFakePlugin(in AUTF8String handlerURI); - - /** - * Returns true if plugins with the given mimetype will run out of process. - */ - boolean isPluginOOP(in AUTF8String aMimeType); }; - diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp index dff177d10f..ca80a0bd0c 100644 --- a/dom/plugins/base/nsPluginHost.cpp +++ b/dom/plugins/base/nsPluginHost.cpp @@ -109,6 +109,10 @@ #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) #endif +#if MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif + #include "npapi.h" using namespace mozilla; @@ -245,6 +249,11 @@ IsTypeInList(const nsCString& aMimeType, nsCString aTypeList) commaSeparated += aMimeType; commaSeparated.Append(','); + // Lower-case the search string and MIME type to properly handle a mixed-case + // type, as MIME types are case insensitive. + ToLowerCase(searchStr); + ToLowerCase(commaSeparated); + return FindInReadable(commaSeparated, start, end); } @@ -968,6 +977,12 @@ nsPluginHost::TrySetUpPluginInstance(const nsACString &aMimeType, plugin->GetLibrary()->SetHasLocalInstance(); +#if defined(MOZ_WIDGET_ANDROID) && defined(MOZ_CRASHREPORTER) + if (pluginTag->mIsFlashPlugin) { + CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("FlashVersion"), pluginTag->Version()); + } +#endif + RefPtr instance = new nsNPAPIPluginInstance(); // This will create the owning reference. The connection must be made between the @@ -1082,18 +1097,6 @@ nsPluginHost::GetBlocklistStateForType(const nsACString &aMimeType, return tag->GetBlocklistState(aState); } -NS_IMETHODIMP -nsPluginHost::IsPluginOOP(const nsACString& aMimeType, - bool* aResult) -{ - nsPluginTag* tag = FindNativePluginForType(aMimeType, true); - if (!tag) { - return NS_ERROR_NOT_AVAILABLE; - } - *aResult = nsNPAPIPlugin::RunPluginOOP(tag); - return NS_OK; -} - NS_IMETHODIMP nsPluginHost::GetPermissionStringForType(const nsACString &aMimeType, uint32_t aExcludeFlags, @@ -1372,6 +1375,13 @@ nsPluginHost::GetPluginForContentProcess(uint32_t aPluginId, nsNPAPIPlugin** aPl nsPluginTag* pluginTag = PluginWithId(aPluginId); if (pluginTag) { + // When setting up a bridge, double check with chrome to see if this plugin + // is blocked hard. Note this does not protect against vulnerable plugins + // that the user has explicitly allowed. :( + if (pluginTag->IsBlocklisted()) { + return NS_ERROR_PLUGIN_BLOCKLISTED; + } + nsresult rv = EnsurePluginLoaded(pluginTag); if (NS_FAILED(rv)) { return rv; @@ -1610,58 +1620,6 @@ nsPluginHost::UnregisterFakePlugin(const nsACString& aHandlerURI) return NS_OK; } -NS_IMETHODIMP -nsPluginHost::RegisterPlayPreviewMimeType(const nsACString& mimeType, - bool ignoreCTP, - const nsACString& redirectURL, - const nsACString& whitelist) -{ - nsAutoCString mt(mimeType); - nsAutoCString url(redirectURL); - if (url.Length() == 0) { - // using default play preview iframe URL, if redirectURL is not specified - url.AssignLiteral("data:application/x-moz-playpreview;,"); - url.Append(mimeType); - } - nsAutoCString wl(whitelist); - - RefPtr playPreview = - new nsPluginPlayPreviewInfo(mt.get(), ignoreCTP, url.get(), wl.get()); - mPlayPreviewMimeTypes.AppendElement(playPreview); - return NS_OK; -} - -NS_IMETHODIMP -nsPluginHost::UnregisterPlayPreviewMimeType(const nsACString& mimeType) -{ - nsAutoCString mimeTypeToRemove(mimeType); - for (uint32_t i = mPlayPreviewMimeTypes.Length(); i > 0; i--) { - RefPtr pp = mPlayPreviewMimeTypes[i - 1]; - if (PL_strcasecmp(pp.get()->mMimeType.get(), mimeTypeToRemove.get()) == 0) { - mPlayPreviewMimeTypes.RemoveElementAt(i - 1); - break; - } - } - return NS_OK; -} - -NS_IMETHODIMP -nsPluginHost::GetPlayPreviewInfo(const nsACString& mimeType, - nsIPluginPlayPreviewInfo** aResult) -{ - nsAutoCString mimeTypeToFind(mimeType); - for (uint32_t i = 0; i < mPlayPreviewMimeTypes.Length(); i++) { - RefPtr pp = mPlayPreviewMimeTypes[i]; - if (PL_strcasecmp(pp.get()->mMimeType.get(), mimeTypeToFind.get()) == 0) { - *aResult = new nsPluginPlayPreviewInfo(pp.get()); - NS_ADDREF(*aResult); - return NS_OK; - } - } - *aResult = nullptr; - return NS_ERROR_NOT_AVAILABLE; -} - // FIXME-jsplugins Is this method actually needed? NS_IMETHODIMP nsPluginHost::GetFakePlugin(const nsACString & aMimeType, @@ -1798,7 +1756,8 @@ nsPluginHost::GetSpecialType(const nsACString & aMIMEType) } if (aMIMEType.LowerCaseEqualsASCII("application/x-shockwave-flash") || - aMIMEType.LowerCaseEqualsASCII("application/futuresplash")) { + aMIMEType.LowerCaseEqualsASCII("application/futuresplash") || + aMIMEType.LowerCaseEqualsASCII("application/x-shockwave-flash-test")) { return eSpecialType_Flash; } @@ -1984,13 +1943,19 @@ bool nsPluginHost::ShouldAddPlugin(nsPluginTag* aPluginTag) { #if 0 && defined(XP_WIN) && (defined(__x86_64__) || defined(_M_X64)) - // On 64-bit windows, the only plugin we should load is flash. Use library - // filename and MIME type to check. + // On 64-bit windows, the only plugins we should load are flash and + // silverlight. Use library filename and MIME type to check. if (StringBeginsWith(aPluginTag->FileName(), NS_LITERAL_CSTRING("NPSWF"), nsCaseInsensitiveCStringComparator()) && (aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-shockwave-flash")) || aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-shockwave-flash-test")))) { return true; } + if (StringBeginsWith(aPluginTag->FileName(), NS_LITERAL_CSTRING("npctrl"), nsCaseInsensitiveCStringComparator()) && + (aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-silverlight-test")) || + aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-silverlight-2")) || + aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-silverlight")))) { + return true; + } // Accept the test plugin MIME types, so mochitests still work. if (aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-test")) || aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-Second-Test")) || @@ -2631,12 +2596,6 @@ nsPluginHost::FindPluginsForContent(uint32_t aPluginEpoch, /// to be more sane and avoid this dance nsPluginTag *tag = static_cast(basetag.get()); - if (!nsNPAPIPlugin::RunPluginOOP(tag)) { - // Don't expose non-OOP plugins to content processes since we have no way - // to bridge them over. - continue; - } - aPlugins->AppendElement(PluginTag(tag->mId, tag->Name(), tag->Description(), diff --git a/dom/plugins/base/nsPluginHost.h b/dom/plugins/base/nsPluginHost.h index e719163a92..fc826cbc3b 100644 --- a/dom/plugins/base/nsPluginHost.h +++ b/dom/plugins/base/nsPluginHost.h @@ -12,7 +12,6 @@ #include "prlink.h" #include "prclist.h" #include "nsIPluginTag.h" -#include "nsPluginPlayPreviewInfo.h" #include "nsPluginsDir.h" #include "nsPluginDirServiceProvider.h" #include "nsAutoPtr.h" @@ -373,7 +372,6 @@ private: RefPtr mPlugins; RefPtr mCachedPlugins; RefPtr mInvalidPlugins; - nsTArray< RefPtr > mPlayPreviewMimeTypes; nsTArray< RefPtr > mFakePlugins; diff --git a/dom/plugins/base/nsPluginPlayPreviewInfo.cpp b/dom/plugins/base/nsPluginPlayPreviewInfo.cpp deleted file mode 100644 index c2a4ae18ed..0000000000 --- a/dom/plugins/base/nsPluginPlayPreviewInfo.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsPluginPlayPreviewInfo.h" -#include "nsWildCard.h" - -using namespace mozilla; - -nsPluginPlayPreviewInfo::nsPluginPlayPreviewInfo(const char* aMimeType, - bool aIgnoreCTP, - const char* aRedirectURL, - const char* aWhitelist) - : mMimeType(aMimeType), mIgnoreCTP(aIgnoreCTP), mRedirectURL(aRedirectURL), - mWhitelist(aWhitelist) {} - -nsPluginPlayPreviewInfo::nsPluginPlayPreviewInfo( - const nsPluginPlayPreviewInfo* aSource) -{ - MOZ_ASSERT(aSource); - - mMimeType = aSource->mMimeType; - mIgnoreCTP = aSource->mIgnoreCTP; - mRedirectURL = aSource->mRedirectURL; - mWhitelist = aSource->mWhitelist; -} - -nsPluginPlayPreviewInfo::~nsPluginPlayPreviewInfo() -{ -} - -NS_IMPL_ISUPPORTS(nsPluginPlayPreviewInfo, nsIPluginPlayPreviewInfo) - -NS_IMETHODIMP -nsPluginPlayPreviewInfo::GetMimeType(nsACString& aMimeType) -{ - aMimeType = mMimeType; - return NS_OK; -} - -NS_IMETHODIMP -nsPluginPlayPreviewInfo::GetIgnoreCTP(bool* aIgnoreCTP) -{ - *aIgnoreCTP = mIgnoreCTP; - return NS_OK; -} - -NS_IMETHODIMP -nsPluginPlayPreviewInfo::GetRedirectURL(nsACString& aRedirectURL) -{ - aRedirectURL = mRedirectURL; - return NS_OK; -} - -NS_IMETHODIMP -nsPluginPlayPreviewInfo::GetWhitelist(nsACString& aWhitelist) -{ - aWhitelist = mWhitelist; - return NS_OK; -} - -/* static */ nsresult -nsPluginPlayPreviewInfo::CheckWhitelist(const nsACString& aPageURI, - const nsACString& aObjectURI, - const nsACString& aWhitelist, - bool *_retval) -{ - if (aWhitelist.Length() == 0) { - // Considering empty whitelist as '*' entry. - *_retval = true; - return NS_OK; - } - - // Parses whitelist as comma separated entries of - // [@page_url object_url|@page_url|object_url] - // where page_url and object_url pattern matches for aPageURI - // and aObjectURI, and performs matching as the same time. - nsACString::const_iterator start, end; - aWhitelist.BeginReading(start); - aWhitelist.EndReading(end); - - nsAutoCString pageURI(aPageURI); - nsAutoCString objectURI(aObjectURI); - nsACString::const_iterator pos = start, entryStart, entryEnd; - nsACString::const_iterator pagePatternStart, pagePatternEnd; - nsACString::const_iterator objectPatternStart, objectPatternEnd; - int matchResult; - bool matched, didMatching; - while (pos != end) { - matched = true; - didMatching = false; - entryStart = pos; - // Looking for end of the entry. - while (pos != end && *pos != ',') { - pos++; - } - entryEnd = pos; - if (entryStart != entryEnd && *entryStart == '@') { - // Pattern for aPageURL is found, finding a space or end of the entry. - pagePatternStart = entryStart; - pagePatternStart++; - pagePatternEnd = pagePatternStart; - while (pagePatternEnd != entryEnd && *pagePatternEnd != ' ') { - pagePatternEnd++; - } - nsAutoCString pagePattern(Substring(pagePatternStart, pagePatternEnd)); - matchResult = NS_WildCardMatch(pageURI.get(), pagePattern.get(), true); - matched &= matchResult == MATCH; - didMatching = true; - objectPatternStart = pagePatternEnd; - } else { - objectPatternStart = entryStart; - } - while (objectPatternStart != entryEnd && *objectPatternStart == ' ') { - objectPatternStart++; - } - if (objectPatternStart != entryEnd) { - // Pattern for aObjectURL is found, removing trailing spaces. - objectPatternEnd = entryEnd; - --objectPatternEnd; - while (objectPatternStart != objectPatternEnd && - *objectPatternEnd == ' ') { - objectPatternEnd--; - }; - objectPatternEnd++; - nsAutoCString objectPattern(Substring(objectPatternStart, - objectPatternEnd)); - matchResult = NS_WildCardMatch(objectURI.get(), objectPattern.get(), true); - matched &= matchResult == MATCH; - didMatching = true; - } - // Ignoring match result for empty entries. - if (didMatching && matched) { - *_retval = true; - return NS_OK; - } - if (pos == end) { - break; - } - pos++; - } - - *_retval = false; - return NS_OK; -} - -NS_IMETHODIMP -nsPluginPlayPreviewInfo::CheckWhitelist(const nsACString& aPageURI, - const nsACString& aObjectURI, - bool *_retval) -{ - return CheckWhitelist(aPageURI, aObjectURI, mWhitelist, _retval); -} diff --git a/dom/plugins/base/nsPluginPlayPreviewInfo.h b/dom/plugins/base/nsPluginPlayPreviewInfo.h deleted file mode 100644 index a28bba593a..0000000000 --- a/dom/plugins/base/nsPluginPlayPreviewInfo.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsPluginPlayPreviewInfo_h_ -#define nsPluginPlayPreviewInfo_h_ - -#include "nsString.h" -#include "nsIPluginHost.h" - -class nsPluginPlayPreviewInfo : public nsIPluginPlayPreviewInfo -{ - virtual ~nsPluginPlayPreviewInfo(); - -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIPLUGINPLAYPREVIEWINFO - - nsPluginPlayPreviewInfo(const char* aMimeType, - bool aIgnoreCTP, - const char* aRedirectURL, - const char* aWhitelist); - explicit nsPluginPlayPreviewInfo(const nsPluginPlayPreviewInfo* aSource); - - /** This function checks aPageURI and aObjectURI against the whitelist - * specified in aWhitelist. This is public static function because this - * whitelist checking code needs to be accessed without any instances of - * nsIPluginPlayPreviewInfo. In particular, the Shumway whitelist is - * obtained directly from prefs and compared using this code for telemetry - * purposes. - */ - static nsresult CheckWhitelist(const nsACString& aPageURI, - const nsACString& aObjectURI, - const nsACString& aWhitelist, - bool *_retval); - - nsCString mMimeType; - bool mIgnoreCTP; - nsCString mRedirectURL; - nsCString mWhitelist; -}; - - -#endif // nsPluginPlayPreviewInfo_h_ diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index f0bc626dd1..14d0c60977 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -178,26 +178,7 @@ PluginInstanceParent::InitMetadata(const nsACString& aMimeType, return false; } nsCOMPtr baseUri(owner->GetBaseURI()); - nsresult rv = NS_MakeAbsoluteURI(mSrcAttribute, aSrcAttribute, baseUri); - if (NS_FAILED(rv)) { - return false; - } - // Check the whitelist - nsAutoCString baseUrlSpec; - rv = baseUri->GetSpec(baseUrlSpec); - if (NS_FAILED(rv)) { - return false; - } - auto whitelist = Preferences::GetCString(kShumwayWhitelistPref); - // Empty whitelist is interpreted by CheckWhitelist as "allow everything," - // which is not valid for our use case and should be treated as a failure. - if (whitelist.IsEmpty()) { - return false; - } - rv = nsPluginPlayPreviewInfo::CheckWhitelist(baseUrlSpec, mSrcAttribute, - whitelist, - &mIsWhitelistedForShumway); - return NS_SUCCEEDED(rv); + return NS_SUCCEEDED(NS_MakeAbsoluteURI(mSrcAttribute, aSrcAttribute, baseUri)); } void diff --git a/dom/plugins/test/mochitest/chrome.ini b/dom/plugins/test/mochitest/chrome.ini index af68f7c8c8..557d4f6a8c 100644 --- a/dom/plugins/test/mochitest/chrome.ini +++ b/dom/plugins/test/mochitest/chrome.ini @@ -3,7 +3,7 @@ skip-if = (buildapp == 'b2g' || buildapp == 'mulet') support-files = hang_test.js privatemode_perwindowpb.xul - utils.js + plugin-utils.js [test_bug479979.xul] [test_bug751809.html] diff --git a/dom/plugins/test/mochitest/mochitest.ini b/dom/plugins/test/mochitest/mochitest.ini index 21ce540821..43382a2ea7 100644 --- a/dom/plugins/test/mochitest/mochitest.ini +++ b/dom/plugins/test/mochitest/mochitest.ini @@ -20,7 +20,7 @@ support-files = plugin_window.html pluginstream.js post.sjs - utils.js + plugin-utils.js [test_GCrace.html] [test_NPNVdocumentOrigin.html] @@ -106,9 +106,13 @@ skip-if = e10s [test_twostreams.html] [test_windowed_invalidate.html] skip-if = os != "win" +[test_windowless_flash.html] +skip-if = !(os == "win" && processor == "x86_64") [test_windowless_ime.html] skip-if = os != "win" [test_visibility.html] skip-if = toolkit == "cocoa" [test_zero_opacity.html] skip-if = e10s +[test_bug1165981.html] +skip-if = !(os == "win" && processor == "x86_64") diff --git a/dom/plugins/test/mochitest/plugin_test.html b/dom/plugins/test/mochitest/plugin_test.html index bc2e2f742c..ffa89747bf 100644 --- a/dom/plugins/test/mochitest/plugin_test.html +++ b/dom/plugins/test/mochitest/plugin_test.html @@ -1,4 +1,4 @@ - + diff --git a/dom/plugins/test/mochitest/plugin_visibility_loader.html b/dom/plugins/test/mochitest/plugin_visibility_loader.html index a8713948ac..22802d9a51 100644 --- a/dom/plugins/test/mochitest/plugin_visibility_loader.html +++ b/dom/plugins/test/mochitest/plugin_visibility_loader.html @@ -1,6 +1,6 @@ - - - -

This Page Has a Solid Plugin

- -

+ + + +

This Page Has a Solid Plugin

+ +

diff --git a/dom/plugins/test/mochitest/test_GCrace.html b/dom/plugins/test/mochitest/test_GCrace.html index 7edbcaecdf..baa426f7fe 100644 --- a/dom/plugins/test/mochitest/test_GCrace.html +++ b/dom/plugins/test/mochitest/test_GCrace.html @@ -3,7 +3,7 @@ - + diff --git a/dom/plugins/test/mochitest/test_NPNVdocumentOrigin.html b/dom/plugins/test/mochitest/test_NPNVdocumentOrigin.html index 21902e6899..75ec66e138 100644 --- a/dom/plugins/test/mochitest/test_NPNVdocumentOrigin.html +++ b/dom/plugins/test/mochitest/test_NPNVdocumentOrigin.html @@ -2,7 +2,7 @@ Test NPNVdocumentOrigin - + - + - + diff --git a/dom/plugins/test/mochitest/test_bug1165981.html b/dom/plugins/test/mochitest/test_bug1165981.html new file mode 100644 index 0000000000..88f2c7ab10 --- /dev/null +++ b/dom/plugins/test/mochitest/test_bug1165981.html @@ -0,0 +1,73 @@ + + + Bug 1165981 Test + + + + + + + + + + + + + + diff --git a/dom/plugins/test/mochitest/test_bug406541.html b/dom/plugins/test/mochitest/test_bug406541.html index 0a386bce5e..6ce9d4554f 100644 --- a/dom/plugins/test/mochitest/test_bug406541.html +++ b/dom/plugins/test/mochitest/test_bug406541.html @@ -3,7 +3,7 @@ Test for Bug 406541 - + diff --git a/dom/plugins/test/mochitest/test_bug479979.xul b/dom/plugins/test/mochitest/test_bug479979.xul index c669b21dcd..1f295cbeb5 100644 --- a/dom/plugins/test/mochitest/test_bug479979.xul +++ b/dom/plugins/test/mochitest/test_bug479979.xul @@ -6,7 +6,7 @@ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + - + diff --git a/dom/plugins/test/mochitest/test_bug539565-1.html b/dom/plugins/test/mochitest/test_bug539565-1.html index 7257417240..022b8cfc61 100644 --- a/dom/plugins/test/mochitest/test_bug539565-1.html +++ b/dom/plugins/test/mochitest/test_bug539565-1.html @@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=539565 Test #1 for Bug 539565 - + - + - + diff --git a/dom/plugins/test/mochitest/test_bug751809.html b/dom/plugins/test/mochitest/test_bug751809.html index ccc6695cdb..c9c1e3d25f 100644 --- a/dom/plugins/test/mochitest/test_bug751809.html +++ b/dom/plugins/test/mochitest/test_bug751809.html @@ -4,7 +4,7 @@ - + - + diff --git a/dom/plugins/test/mochitest/test_bug777098.html b/dom/plugins/test/mochitest/test_bug777098.html index 79a2559ff0..77ba9ed316 100644 --- a/dom/plugins/test/mochitest/test_bug777098.html +++ b/dom/plugins/test/mochitest/test_bug777098.html @@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=777098 Test for Bug 777098 - + diff --git a/dom/plugins/test/mochitest/test_bug784131.html b/dom/plugins/test/mochitest/test_bug784131.html index eac426bb62..ff2dd19c17 100644 --- a/dom/plugins/test/mochitest/test_bug784131.html +++ b/dom/plugins/test/mochitest/test_bug784131.html @@ -3,7 +3,7 @@ Test for Bug 784131 - + diff --git a/dom/plugins/test/mochitest/test_bug813906.html b/dom/plugins/test/mochitest/test_bug813906.html index 4ee9d08a56..04c34daafe 100644 --- a/dom/plugins/test/mochitest/test_bug813906.html +++ b/dom/plugins/test/mochitest/test_bug813906.html @@ -3,7 +3,7 @@ Test for Bug 813906 - + diff --git a/dom/plugins/test/mochitest/test_bug852315.html b/dom/plugins/test/mochitest/test_bug852315.html index 03e73c4795..cc9c97613f 100644 --- a/dom/plugins/test/mochitest/test_bug852315.html +++ b/dom/plugins/test/mochitest/test_bug852315.html @@ -3,7 +3,7 @@ Test for Bug 852315 - + diff --git a/dom/plugins/test/mochitest/test_bug854082.html b/dom/plugins/test/mochitest/test_bug854082.html index b6537289ec..ff3d1e1e86 100644 --- a/dom/plugins/test/mochitest/test_bug854082.html +++ b/dom/plugins/test/mochitest/test_bug854082.html @@ -3,7 +3,7 @@ Test for Bug 854082 - + diff --git a/dom/plugins/test/mochitest/test_bug863792.html b/dom/plugins/test/mochitest/test_bug863792.html index 0bb60f89e7..ccd0fc83c9 100644 --- a/dom/plugins/test/mochitest/test_bug863792.html +++ b/dom/plugins/test/mochitest/test_bug863792.html @@ -3,7 +3,7 @@ Test for Bug 863792 - + diff --git a/dom/plugins/test/mochitest/test_bug967694.html b/dom/plugins/test/mochitest/test_bug967694.html index eae26419f0..8a7602134d 100644 --- a/dom/plugins/test/mochitest/test_bug967694.html +++ b/dom/plugins/test/mochitest/test_bug967694.html @@ -3,7 +3,7 @@ Test for Bug 967694 - + diff --git a/dom/plugins/test/mochitest/test_bug985859.html b/dom/plugins/test/mochitest/test_bug985859.html index 695b4dfb4b..1a4329ab4a 100644 --- a/dom/plugins/test/mochitest/test_bug985859.html +++ b/dom/plugins/test/mochitest/test_bug985859.html @@ -3,7 +3,7 @@ Test for Bug 985859 - + diff --git a/dom/plugins/test/mochitest/test_bug986930.html b/dom/plugins/test/mochitest/test_bug986930.html index 620f93913f..f86539e58f 100644 --- a/dom/plugins/test/mochitest/test_bug986930.html +++ b/dom/plugins/test/mochitest/test_bug986930.html @@ -5,7 +5,7 @@ Test for Bug 986930 - + - + - + diff --git a/dom/plugins/test/mochitest/test_cocoa_window_focus.html b/dom/plugins/test/mochitest/test_cocoa_window_focus.html index c94f25a6f1..3458c24eb9 100644 --- a/dom/plugins/test/mochitest/test_cocoa_window_focus.html +++ b/dom/plugins/test/mochitest/test_cocoa_window_focus.html @@ -2,7 +2,7 @@ NPCocoaEventWindowFocusChanged Tests - + diff --git a/dom/plugins/test/mochitest/test_convertpoint.xul b/dom/plugins/test/mochitest/test_convertpoint.xul index c121cf4d1d..5db01a253e 100644 --- a/dom/plugins/test/mochitest/test_convertpoint.xul +++ b/dom/plugins/test/mochitest/test_convertpoint.xul @@ -6,7 +6,7 @@ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + diff --git a/dom/plugins/test/mochitest/test_cookies.html b/dom/plugins/test/mochitest/test_cookies.html index 6e1934994f..f527967706 100644 --- a/dom/plugins/test/mochitest/test_cookies.html +++ b/dom/plugins/test/mochitest/test_cookies.html @@ -2,7 +2,7 @@ NPAPI Cookie Tests - + diff --git a/dom/plugins/test/mochitest/test_copyText.html b/dom/plugins/test/mochitest/test_copyText.html index c2f51f1a8d..bed7db977d 100644 --- a/dom/plugins/test/mochitest/test_copyText.html +++ b/dom/plugins/test/mochitest/test_copyText.html @@ -3,7 +3,7 @@ Test copying text from browser to plugin - + - + - + diff --git a/dom/plugins/test/mochitest/test_enumerate.html b/dom/plugins/test/mochitest/test_enumerate.html index 035c42eb5a..af8431c7cc 100644 --- a/dom/plugins/test/mochitest/test_enumerate.html +++ b/dom/plugins/test/mochitest/test_enumerate.html @@ -1,36 +1,36 @@ - - - NPAPI Cookie Tests - - - - - - - - - -

- - - - + + + NPAPI Cookie Tests + + + + + + + + + +

+ + + + diff --git a/dom/plugins/test/mochitest/test_fullpage.html b/dom/plugins/test/mochitest/test_fullpage.html index 18ef16380d..680eb73a01 100644 --- a/dom/plugins/test/mochitest/test_fullpage.html +++ b/dom/plugins/test/mochitest/test_fullpage.html @@ -3,7 +3,7 @@ - + diff --git a/dom/plugins/test/mochitest/test_getauthenticationinfo.html b/dom/plugins/test/mochitest/test_getauthenticationinfo.html index 6735812112..dfd2fbed38 100644 --- a/dom/plugins/test/mochitest/test_getauthenticationinfo.html +++ b/dom/plugins/test/mochitest/test_getauthenticationinfo.html @@ -3,7 +3,7 @@ Test for Login Manager - + diff --git a/dom/plugins/test/mochitest/test_instance_re-parent.html b/dom/plugins/test/mochitest/test_instance_re-parent.html index 0c0561981b..4f3d178de0 100644 --- a/dom/plugins/test/mochitest/test_instance_re-parent.html +++ b/dom/plugins/test/mochitest/test_instance_re-parent.html @@ -5,7 +5,7 @@ - + - + diff --git a/dom/plugins/test/mochitest/test_instance_unparent2.html b/dom/plugins/test/mochitest/test_instance_unparent2.html index 21a90da4a6..dc0c13f04d 100644 --- a/dom/plugins/test/mochitest/test_instance_unparent2.html +++ b/dom/plugins/test/mochitest/test_instance_unparent2.html @@ -4,7 +4,7 @@ Test removing an instance's DOM node - + diff --git a/dom/plugins/test/mochitest/test_instance_unparent3.html b/dom/plugins/test/mochitest/test_instance_unparent3.html index 26a4ddfb0a..5fc6108a85 100644 --- a/dom/plugins/test/mochitest/test_instance_unparent3.html +++ b/dom/plugins/test/mochitest/test_instance_unparent3.html @@ -4,7 +4,7 @@ Test removing an instance's DOM node - + diff --git a/dom/plugins/test/mochitest/test_instantiation.html b/dom/plugins/test/mochitest/test_instantiation.html index d84d39ebdd..e8fc077459 100644 --- a/dom/plugins/test/mochitest/test_instantiation.html +++ b/dom/plugins/test/mochitest/test_instantiation.html @@ -1,33 +1,33 @@ - - Plugin instantiation - - - - - - - + + Plugin instantiation + + + + + + + diff --git a/dom/plugins/test/mochitest/test_mixed_case_mime.html b/dom/plugins/test/mochitest/test_mixed_case_mime.html index cb091a8cbb..9258541bb7 100644 --- a/dom/plugins/test/mochitest/test_mixed_case_mime.html +++ b/dom/plugins/test/mochitest/test_mixed_case_mime.html @@ -2,7 +2,7 @@ Test mixed case mimetype for plugins - + - + - + diff --git a/dom/plugins/test/mochitest/test_npn_asynccall.html b/dom/plugins/test/mochitest/test_npn_asynccall.html index 14617aa5f2..4f007aacb0 100644 --- a/dom/plugins/test/mochitest/test_npn_asynccall.html +++ b/dom/plugins/test/mochitest/test_npn_asynccall.html @@ -3,7 +3,7 @@ NPN_AsyncCallback Tests - + diff --git a/dom/plugins/test/mochitest/test_npn_timers.html b/dom/plugins/test/mochitest/test_npn_timers.html index 076c04f0da..64d5aebbda 100644 --- a/dom/plugins/test/mochitest/test_npn_timers.html +++ b/dom/plugins/test/mochitest/test_npn_timers.html @@ -3,7 +3,7 @@ NPN_Timer Tests - + diff --git a/dom/plugins/test/mochitest/test_npobject_getters.html b/dom/plugins/test/mochitest/test_npobject_getters.html index 9287121ba3..5a9a47081a 100644 --- a/dom/plugins/test/mochitest/test_npobject_getters.html +++ b/dom/plugins/test/mochitest/test_npobject_getters.html @@ -1,7 +1,7 @@ NPNV*NPObject accessibility tests - + + diff --git a/dom/plugins/test/mochitest/test_npruntime_construct.html b/dom/plugins/test/mochitest/test_npruntime_construct.html index f481884f9f..bd85930a4f 100644 --- a/dom/plugins/test/mochitest/test_npruntime_construct.html +++ b/dom/plugins/test/mochitest/test_npruntime_construct.html @@ -1,32 +1,32 @@ - - - - Test whether windowless plugins receive correct visible/invisible notifications. - - - - - - - -

- - - - + + + + Test whether windowless plugins receive correct visible/invisible notifications. + + + + + + + +

+ + + + diff --git a/dom/plugins/test/mochitest/test_npruntime_identifiers.html b/dom/plugins/test/mochitest/test_npruntime_identifiers.html index 33b5d41b81..a19a59be52 100644 --- a/dom/plugins/test/mochitest/test_npruntime_identifiers.html +++ b/dom/plugins/test/mochitest/test_npruntime_identifiers.html @@ -1,67 +1,67 @@ - - - NPN_Invoke Tests - - - - - -

- - - - - - - + + + NPN_Invoke Tests + + + + + +

+ + + + + + + diff --git a/dom/plugins/test/mochitest/test_npruntime_npnevaluate.html b/dom/plugins/test/mochitest/test_npruntime_npnevaluate.html index 6581b3984d..4a1c22978b 100644 --- a/dom/plugins/test/mochitest/test_npruntime_npnevaluate.html +++ b/dom/plugins/test/mochitest/test_npruntime_npnevaluate.html @@ -3,7 +3,7 @@ NPN_Evaluate Tests - + diff --git a/dom/plugins/test/mochitest/test_npruntime_npninvoke.html b/dom/plugins/test/mochitest/test_npruntime_npninvoke.html index 86eb04c237..ff4c92a6d5 100644 --- a/dom/plugins/test/mochitest/test_npruntime_npninvoke.html +++ b/dom/plugins/test/mochitest/test_npruntime_npninvoke.html @@ -3,7 +3,7 @@ NPN_Invoke Tests - + diff --git a/dom/plugins/test/mochitest/test_npruntime_npninvokedefault.html b/dom/plugins/test/mochitest/test_npruntime_npninvokedefault.html index 597db0cc1c..79a75e7551 100644 --- a/dom/plugins/test/mochitest/test_npruntime_npninvokedefault.html +++ b/dom/plugins/test/mochitest/test_npruntime_npninvokedefault.html @@ -3,7 +3,7 @@ NPN_Invoke_Default Tests - + diff --git a/dom/plugins/test/mochitest/test_painting.html b/dom/plugins/test/mochitest/test_painting.html index f79df0ce68..08ebd46757 100644 --- a/dom/plugins/test/mochitest/test_painting.html +++ b/dom/plugins/test/mochitest/test_painting.html @@ -38,7 +38,7 @@ - + - + diff --git a/dom/plugins/test/mochitest/test_plugin_tag_clicktoplay.html b/dom/plugins/test/mochitest/test_plugin_tag_clicktoplay.html index fcc84fdd59..f67a78bca5 100644 --- a/dom/plugins/test/mochitest/test_plugin_tag_clicktoplay.html +++ b/dom/plugins/test/mochitest/test_plugin_tag_clicktoplay.html @@ -5,7 +5,7 @@ Test Modifying Plugin click-to-play Flag - + - + diff --git a/dom/plugins/test/mochitest/test_pluginstream_asfileonly.html b/dom/plugins/test/mochitest/test_pluginstream_asfileonly.html index be49cc4601..96c9b85dce 100644 --- a/dom/plugins/test/mochitest/test_pluginstream_asfileonly.html +++ b/dom/plugins/test/mochitest/test_pluginstream_asfileonly.html @@ -5,7 +5,7 @@ src="/tests/SimpleTest/SimpleTest.js"> - + diff --git a/dom/plugins/test/mochitest/test_pluginstream_err.html b/dom/plugins/test/mochitest/test_pluginstream_err.html index f5e0101ab1..0ac2a5efc2 100644 --- a/dom/plugins/test/mochitest/test_pluginstream_err.html +++ b/dom/plugins/test/mochitest/test_pluginstream_err.html @@ -9,7 +9,7 @@ Tests for plugin stream error conditions. NPAPI Stream Error Tests - + diff --git a/dom/plugins/test/mochitest/test_pluginstream_geturl.html b/dom/plugins/test/mochitest/test_pluginstream_geturl.html index 12de91f70e..fe69427a42 100644 --- a/dom/plugins/test/mochitest/test_pluginstream_geturl.html +++ b/dom/plugins/test/mochitest/test_pluginstream_geturl.html @@ -5,7 +5,7 @@ src="/tests/SimpleTest/SimpleTest.js"> - + diff --git a/dom/plugins/test/mochitest/test_pluginstream_geturlnotify.html b/dom/plugins/test/mochitest/test_pluginstream_geturlnotify.html index 07a813d6f4..ee4c2b119d 100644 --- a/dom/plugins/test/mochitest/test_pluginstream_geturlnotify.html +++ b/dom/plugins/test/mochitest/test_pluginstream_geturlnotify.html @@ -5,7 +5,7 @@ src="/tests/SimpleTest/SimpleTest.js"> - + diff --git a/dom/plugins/test/mochitest/test_pluginstream_newstream.html b/dom/plugins/test/mochitest/test_pluginstream_newstream.html index a499196f0d..3972fd7ed4 100644 --- a/dom/plugins/test/mochitest/test_pluginstream_newstream.html +++ b/dom/plugins/test/mochitest/test_pluginstream_newstream.html @@ -5,7 +5,7 @@ src="/tests/SimpleTest/SimpleTest.js"> - + diff --git a/dom/plugins/test/mochitest/test_pluginstream_post.html b/dom/plugins/test/mochitest/test_pluginstream_post.html index a74e0e6f42..da12ff3b0e 100644 --- a/dom/plugins/test/mochitest/test_pluginstream_post.html +++ b/dom/plugins/test/mochitest/test_pluginstream_post.html @@ -5,7 +5,7 @@ src="/tests/SimpleTest/SimpleTest.js"> - + diff --git a/dom/plugins/test/mochitest/test_pluginstream_poststream.html b/dom/plugins/test/mochitest/test_pluginstream_poststream.html index f32ff7cf79..ed2e8ce2c7 100644 --- a/dom/plugins/test/mochitest/test_pluginstream_poststream.html +++ b/dom/plugins/test/mochitest/test_pluginstream_poststream.html @@ -5,7 +5,7 @@ src="/tests/SimpleTest/SimpleTest.js"> - + diff --git a/dom/plugins/test/mochitest/test_pluginstream_referer.html b/dom/plugins/test/mochitest/test_pluginstream_referer.html index e0b3409928..e1b63fb959 100644 --- a/dom/plugins/test/mochitest/test_pluginstream_referer.html +++ b/dom/plugins/test/mochitest/test_pluginstream_referer.html @@ -2,7 +2,7 @@ Do plugin stream requests send the Referer header correctly? - + diff --git a/dom/plugins/test/mochitest/test_pluginstream_seek.html b/dom/plugins/test/mochitest/test_pluginstream_seek.html index 984d43d3b0..6915a766e8 100644 --- a/dom/plugins/test/mochitest/test_pluginstream_seek.html +++ b/dom/plugins/test/mochitest/test_pluginstream_seek.html @@ -5,7 +5,7 @@ src="/tests/SimpleTest/SimpleTest.js"> - + diff --git a/dom/plugins/test/mochitest/test_pluginstream_seek_close.html b/dom/plugins/test/mochitest/test_pluginstream_seek_close.html index 07958ddd7b..46fd3962ab 100644 --- a/dom/plugins/test/mochitest/test_pluginstream_seek_close.html +++ b/dom/plugins/test/mochitest/test_pluginstream_seek_close.html @@ -3,7 +3,7 @@ NPAPI Seekable NPStream Test - + - + diff --git a/dom/plugins/test/mochitest/test_pluginstream_src_dynamic.html b/dom/plugins/test/mochitest/test_pluginstream_src_dynamic.html index b679008a3d..2a7db9916d 100644 --- a/dom/plugins/test/mochitest/test_pluginstream_src_dynamic.html +++ b/dom/plugins/test/mochitest/test_pluginstream_src_dynamic.html @@ -1,43 +1,43 @@ - - - NPAPI src="" NPStream Test - - - - - - - -

- - - - - - - - + + + NPAPI src="" NPStream Test + + + + + + + +

+ + + + + + + + diff --git a/dom/plugins/test/mochitest/test_pluginstream_src_referer.html b/dom/plugins/test/mochitest/test_pluginstream_src_referer.html index 9a191b82c6..9e96016ff6 100644 --- a/dom/plugins/test/mochitest/test_pluginstream_src_referer.html +++ b/dom/plugins/test/mochitest/test_pluginstream_src_referer.html @@ -2,7 +2,7 @@ Do plugin stream src requests send the Referer header correctly? - + diff --git a/dom/plugins/test/mochitest/test_positioning.html b/dom/plugins/test/mochitest/test_positioning.html index 666a841a73..4a4fc1d3d0 100644 --- a/dom/plugins/test/mochitest/test_positioning.html +++ b/dom/plugins/test/mochitest/test_positioning.html @@ -1,56 +1,56 @@ - - - - Test whether windowless plugins receive correct visible/invisible notifications. - - - - - - - -

- - - - + + + + Test whether windowless plugins receive correct visible/invisible notifications. + + + + + + + +

+ + + + diff --git a/dom/plugins/test/mochitest/test_privatemode_perwindowpb.xul b/dom/plugins/test/mochitest/test_privatemode_perwindowpb.xul index b325ba4e38..5c9ae5083b 100644 --- a/dom/plugins/test/mochitest/test_privatemode_perwindowpb.xul +++ b/dom/plugins/test/mochitest/test_privatemode_perwindowpb.xul @@ -8,7 +8,7 @@ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> + diff --git a/dom/plugins/test/mochitest/test_propertyAndMethod.html b/dom/plugins/test/mochitest/test_propertyAndMethod.html index 226f1a2960..6e638e4191 100644 --- a/dom/plugins/test/mochitest/test_propertyAndMethod.html +++ b/dom/plugins/test/mochitest/test_propertyAndMethod.html @@ -3,7 +3,7 @@ NPObject with property and method with the same name - + diff --git a/dom/plugins/test/mochitest/test_queryContentsScaleFactor.html b/dom/plugins/test/mochitest/test_queryContentsScaleFactor.html index a3372252c3..1ff141e92a 100644 --- a/dom/plugins/test/mochitest/test_queryContentsScaleFactor.html +++ b/dom/plugins/test/mochitest/test_queryContentsScaleFactor.html @@ -2,7 +2,7 @@ NPAPI NPNVcontentsScaleFactor Test - + diff --git a/dom/plugins/test/mochitest/test_redirect_handling.html b/dom/plugins/test/mochitest/test_redirect_handling.html index cbf1c6c2b6..7d60ec06e9 100644 --- a/dom/plugins/test/mochitest/test_redirect_handling.html +++ b/dom/plugins/test/mochitest/test_redirect_handling.html @@ -2,7 +2,7 @@ Basic NPAPI Redirect Handling - + - + - + diff --git a/dom/plugins/test/mochitest/test_src_url_change.html b/dom/plugins/test/mochitest/test_src_url_change.html index 1450e7eeed..8e8f4d326a 100644 --- a/dom/plugins/test/mochitest/test_src_url_change.html +++ b/dom/plugins/test/mochitest/test_src_url_change.html @@ -4,7 +4,7 @@ Test changing src attribute - + diff --git a/dom/plugins/test/mochitest/test_streamNotify.html b/dom/plugins/test/mochitest/test_streamNotify.html index feb979d3d1..d1aa8be8da 100644 --- a/dom/plugins/test/mochitest/test_streamNotify.html +++ b/dom/plugins/test/mochitest/test_streamNotify.html @@ -1,7 +1,7 @@ NPN_Get/PostURLNotify tests - + - + diff --git a/dom/plugins/test/mochitest/test_stringHandling.html b/dom/plugins/test/mochitest/test_stringHandling.html index bf735be041..023fcfcb05 100644 --- a/dom/plugins/test/mochitest/test_stringHandling.html +++ b/dom/plugins/test/mochitest/test_stringHandling.html @@ -2,7 +2,7 @@ NPAPI string test - + diff --git a/dom/plugins/test/mochitest/test_twostreams.html b/dom/plugins/test/mochitest/test_twostreams.html index 1e69aa1655..c2b3672c83 100644 --- a/dom/plugins/test/mochitest/test_twostreams.html +++ b/dom/plugins/test/mochitest/test_twostreams.html @@ -1,46 +1,46 @@ - - - Dual NPAPI NP_ASFILEONLY NPStream Test - - - - - -

- - - - - - - - - + + + Dual NPAPI NP_ASFILEONLY NPStream Test + + + + + +

+ + + + + + + + + diff --git a/dom/plugins/test/mochitest/test_windowed_invalidate.html b/dom/plugins/test/mochitest/test_windowed_invalidate.html index 31d7081f54..a19e4c8c53 100644 --- a/dom/plugins/test/mochitest/test_windowed_invalidate.html +++ b/dom/plugins/test/mochitest/test_windowed_invalidate.html @@ -3,7 +3,7 @@ Test NPN_Invalidate working for a windowed plugin - + diff --git a/dom/plugins/test/mochitest/test_windowless_flash.html b/dom/plugins/test/mochitest/test_windowless_flash.html new file mode 100644 index 0000000000..8274a78aeb --- /dev/null +++ b/dom/plugins/test/mochitest/test_windowless_flash.html @@ -0,0 +1,33 @@ + + + + + + + + + + +

+ +
+ + + +
+ + diff --git a/dom/plugins/test/mochitest/test_wmode.xul b/dom/plugins/test/mochitest/test_wmode.xul index cd437874d7..b45038835a 100644 --- a/dom/plugins/test/mochitest/test_wmode.xul +++ b/dom/plugins/test/mochitest/test_wmode.xul @@ -6,7 +6,7 @@ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + diff --git a/dom/plugins/test/mochitest/test_xulbrowser_plugin_visibility.xul b/dom/plugins/test/mochitest/test_xulbrowser_plugin_visibility.xul index 3872eb0eb0..8cccb8bf7d 100644 --- a/dom/plugins/test/mochitest/test_xulbrowser_plugin_visibility.xul +++ b/dom/plugins/test/mochitest/test_xulbrowser_plugin_visibility.xul @@ -1,24 +1,24 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/dom/plugins/test/mochitest/test_zero_opacity.html b/dom/plugins/test/mochitest/test_zero_opacity.html index 5c868e482e..c768cafd53 100644 --- a/dom/plugins/test/mochitest/test_zero_opacity.html +++ b/dom/plugins/test/mochitest/test_zero_opacity.html @@ -1,44 +1,44 @@ - - - - Test whether windowed plugins with opacity:0 get their window set correctly - - - - - - - -

- + + + + Test whether windowed plugins with opacity:0 get their window set correctly + + + + + + + +

+ \ No newline at end of file diff --git a/dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xul b/dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xul index a0e3fc4e10..d087305200 100644 --- a/dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xul +++ b/dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xul @@ -1,139 +1,139 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/dom/plugins/test/testaddon/Makefile.in b/dom/plugins/test/testaddon/Makefile.in index 15b93f0407..7b6dd6bc5f 100644 --- a/dom/plugins/test/testaddon/Makefile.in +++ b/dom/plugins/test/testaddon/Makefile.in @@ -5,10 +5,10 @@ include $(topsrcdir)/config/rules.mk ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa) -plugin_file_names = Test.plugin SecondTest.plugin +plugin_file_names = Test.plugin SecondTest.plugin ThirdTest.plugin npswftest.plugin npctrltest.plugin addon_file_name = testaddon_$(TARGET_XPCOM_ABI).xpi else -plugin_file_names = $(DLL_PREFIX)nptest$(DLL_SUFFIX) $(DLL_PREFIX)npsecondtest$(DLL_SUFFIX) +plugin_file_names = $(DLL_PREFIX)nptest$(DLL_SUFFIX) $(DLL_PREFIX)npsecondtest$(DLL_SUFFIX) $(DLL_PREFIX)npthirdtest$(DLL_SUFFIX) $(DLL_PREFIX)npswftest$(DLL_SUFFIX) $(DLL_PREFIX)npctrltest$(DLL_SUFFIX) addon_file_name = testaddon.xpi endif diff --git a/dom/plugins/test/testplugin/flashplugin/Info.plist b/dom/plugins/test/testplugin/flashplugin/Info.plist new file mode 100644 index 0000000000..ae61aadaab --- /dev/null +++ b/dom/plugins/test/testplugin/flashplugin/Info.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + libnpswftest.dylib + CFBundleIdentifier + org.mozilla.FlashTestPlugin + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BRPL + CFBundleShortVersionString + 1.0.0.0 + CFBundleSignature + FLASHTEST + CFBundleVersion + 1.0.0.0 + WebPluginName + Flash Test Plug-in + WebPluginDescription + Flash plug-in for testing purposes. + WebPluginMIMETypes + + application/x-shockwave-flash-test + + WebPluginExtensions + + swf + + WebPluginTypeDescription + Flash test type + + + + diff --git a/dom/plugins/test/testplugin/flashplugin/Makefile.in b/dom/plugins/test/testplugin/flashplugin/Makefile.in new file mode 100644 index 0000000000..b752d61506 --- /dev/null +++ b/dom/plugins/test/testplugin/flashplugin/Makefile.in @@ -0,0 +1,9 @@ +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + +RELATIVE_PATH=.. +COCOA_NAME=npswftest +include @srcdir@/../testplugin.mk + diff --git a/dom/plugins/test/testplugin/flashplugin/moz.build b/dom/plugins/test/testplugin/flashplugin/moz.build new file mode 100644 index 0000000000..b21e5cdfea --- /dev/null +++ b/dom/plugins/test/testplugin/flashplugin/moz.build @@ -0,0 +1,10 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +SharedLibrary('npswftest') + +relative_path = 'flashplugin' +include('../testplugin.mozbuild') diff --git a/dom/plugins/test/testplugin/flashplugin/nptest.def b/dom/plugins/test/testplugin/flashplugin/nptest.def new file mode 100644 index 0000000000..3a62d05d95 --- /dev/null +++ b/dom/plugins/test/testplugin/flashplugin/nptest.def @@ -0,0 +1,7 @@ +LIBRARY NPSWFTEST + +EXPORTS + NP_GetEntryPoints @1 + NP_Initialize @2 + NP_Shutdown @3 + NP_GetMIMEDescription @4 diff --git a/dom/plugins/test/testplugin/flashplugin/nptest.rc b/dom/plugins/test/testplugin/flashplugin/nptest.rc new file mode 100644 index 0000000000..34d409e38b --- /dev/null +++ b/dom/plugins/test/testplugin/flashplugin/nptest.rc @@ -0,0 +1,42 @@ +#include + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,0 + PRODUCTVERSION 1,0,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "mozilla.org" + VALUE "FileDescription", L"Flash plug-in for testing purposes." + VALUE "FileExtents", "swf" + VALUE "FileOpenName", "Flash test type" + VALUE "FileVersion", "1.0" + VALUE "InternalName", "npswftest" + VALUE "MIMEType", "application/x-shockwave-flash-test" + VALUE "OriginalFilename", "npswftest.dll" + VALUE "ProductName", "Flash Test Plug-in" + VALUE "ProductVersion", "1.0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END diff --git a/dom/plugins/test/testplugin/flashplugin/nptest_name.cpp b/dom/plugins/test/testplugin/flashplugin/nptest_name.cpp new file mode 100644 index 0000000000..952ef5c47b --- /dev/null +++ b/dom/plugins/test/testplugin/flashplugin/nptest_name.cpp @@ -0,0 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const char *sPluginName = "Flash Test Plug-in"; +const char *sPluginDescription = "Flash plug-in for testing purposes."; +const char *sMimeDescription = "application/x-shockwave-flash-test:swf:Flash test type"; diff --git a/dom/plugins/test/testplugin/moz.build b/dom/plugins/test/testplugin/moz.build index 4676b53784..05edcef7c4 100644 --- a/dom/plugins/test/testplugin/moz.build +++ b/dom/plugins/test/testplugin/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -DIRS += ['secondplugin', 'javaplugin'] +DIRS += ['secondplugin', 'javaplugin', 'thirdplugin', 'flashplugin', 'silverlightplugin'] SharedLibrary('nptest') diff --git a/dom/plugins/test/testplugin/silverlightplugin/Info.plist b/dom/plugins/test/testplugin/silverlightplugin/Info.plist new file mode 100644 index 0000000000..7a8094b83c --- /dev/null +++ b/dom/plugins/test/testplugin/silverlightplugin/Info.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + libnpctrltest.dylib + CFBundleIdentifier + org.mozilla.SilverlightTestPlugin + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BRPL + CFBundleShortVersionString + 1.0.0.0 + CFBundleSignature + SILVERLIGHTTEST + CFBundleVersion + 1.0.0.0 + WebPluginName + Silverlight Test Plug-in + WebPluginDescription + Silverlight plug-in for testing purposes. + WebPluginMIMETypes + + application/x-silverlight-test + + WebPluginExtensions + + xaml + + WebPluginTypeDescription + Silverlight test type + + + + diff --git a/dom/plugins/test/testplugin/silverlightplugin/Makefile.in b/dom/plugins/test/testplugin/silverlightplugin/Makefile.in new file mode 100644 index 0000000000..ebab18fbd2 --- /dev/null +++ b/dom/plugins/test/testplugin/silverlightplugin/Makefile.in @@ -0,0 +1,9 @@ +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + +RELATIVE_PATH=.. +COCOA_NAME=npctrltest +include @srcdir@/../testplugin.mk + diff --git a/dom/plugins/test/testplugin/silverlightplugin/moz.build b/dom/plugins/test/testplugin/silverlightplugin/moz.build new file mode 100644 index 0000000000..affa3d7a22 --- /dev/null +++ b/dom/plugins/test/testplugin/silverlightplugin/moz.build @@ -0,0 +1,10 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +SharedLibrary('npctrltest') + +relative_path = 'silverlightplugin' +include('../testplugin.mozbuild') diff --git a/dom/plugins/test/testplugin/silverlightplugin/nptest.def b/dom/plugins/test/testplugin/silverlightplugin/nptest.def new file mode 100644 index 0000000000..b25c6c8c52 --- /dev/null +++ b/dom/plugins/test/testplugin/silverlightplugin/nptest.def @@ -0,0 +1,7 @@ +LIBRARY NPCTRLTEST + +EXPORTS + NP_GetEntryPoints @1 + NP_Initialize @2 + NP_Shutdown @3 + NP_GetMIMEDescription @4 diff --git a/dom/plugins/test/testplugin/silverlightplugin/nptest.rc b/dom/plugins/test/testplugin/silverlightplugin/nptest.rc new file mode 100644 index 0000000000..a48654bc56 --- /dev/null +++ b/dom/plugins/test/testplugin/silverlightplugin/nptest.rc @@ -0,0 +1,42 @@ +#include + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,0 + PRODUCTVERSION 1,0,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "mozilla.org" + VALUE "FileDescription", L"Silverlight plug-in for testing purposes." + VALUE "FileExtents", "xaml" + VALUE "FileOpenName", "Silverlight test type" + VALUE "FileVersion", "1.0" + VALUE "InternalName", "npctrltest" + VALUE "MIMEType", "application/x-silverlight-test" + VALUE "OriginalFilename", "npctrltest.dll" + VALUE "ProductName", "Silverlight Test Plug-in" + VALUE "ProductVersion", "1.0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END diff --git a/dom/plugins/test/testplugin/silverlightplugin/nptest_name.cpp b/dom/plugins/test/testplugin/silverlightplugin/nptest_name.cpp new file mode 100644 index 0000000000..2cdfaa5f1c --- /dev/null +++ b/dom/plugins/test/testplugin/silverlightplugin/nptest_name.cpp @@ -0,0 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const char *sPluginName = "Silverlight Test Plug-in"; +const char *sPluginDescription = "Silverlight plug-in for testing purposes."; +const char *sMimeDescription = "application/x-silverlight-test:xaml:Silverlight test type"; diff --git a/dom/plugins/test/testplugin/thirdplugin/Info.plist b/dom/plugins/test/testplugin/thirdplugin/Info.plist new file mode 100644 index 0000000000..96e18ba755 --- /dev/null +++ b/dom/plugins/test/testplugin/thirdplugin/Info.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + libnpthirdtest.dylib + CFBundleIdentifier + org.mozilla.ThirdTestPlugin + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BRPL + CFBundleShortVersionString + 1.0.0.0 + CFBundleSignature + THIRDTEST + CFBundleVersion + 1.0.0.0 + WebPluginName + Third Test Plug-in + WebPluginDescription + Third plug-in for testing purposes. + WebPluginMIMETypes + + application/x-Third-Test + + WebPluginExtensions + + ts2 + + WebPluginTypeDescription + Third test type + + + + diff --git a/dom/plugins/test/testplugin/thirdplugin/Makefile.in b/dom/plugins/test/testplugin/thirdplugin/Makefile.in new file mode 100644 index 0000000000..4c38699549 --- /dev/null +++ b/dom/plugins/test/testplugin/thirdplugin/Makefile.in @@ -0,0 +1,8 @@ +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + +RELATIVE_PATH=.. +COCOA_NAME=ThirdTest +include @srcdir@/../testplugin.mk diff --git a/dom/plugins/test/testplugin/thirdplugin/moz.build b/dom/plugins/test/testplugin/thirdplugin/moz.build new file mode 100644 index 0000000000..50498b37c4 --- /dev/null +++ b/dom/plugins/test/testplugin/thirdplugin/moz.build @@ -0,0 +1,10 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +SharedLibrary('npthirdtest') + +relative_path = 'thirdplugin' +include('../testplugin.mozbuild') diff --git a/dom/plugins/test/testplugin/thirdplugin/nptest.def b/dom/plugins/test/testplugin/thirdplugin/nptest.def new file mode 100644 index 0000000000..8ea68ba410 --- /dev/null +++ b/dom/plugins/test/testplugin/thirdplugin/nptest.def @@ -0,0 +1,7 @@ +LIBRARY NPTHIRDTEST + +EXPORTS + NP_GetEntryPoints @1 + NP_Initialize @2 + NP_Shutdown @3 + NP_GetMIMEDescription @4 diff --git a/dom/plugins/test/testplugin/thirdplugin/nptest.rc b/dom/plugins/test/testplugin/thirdplugin/nptest.rc new file mode 100644 index 0000000000..de1576920e --- /dev/null +++ b/dom/plugins/test/testplugin/thirdplugin/nptest.rc @@ -0,0 +1,42 @@ +#include + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,0 + PRODUCTVERSION 1,0,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "mozilla.org" + VALUE "FileDescription", L"Third plug-in for testing purposes." + VALUE "FileExtents", "ts2" + VALUE "FileOpenName", "Third test type" + VALUE "FileVersion", "1.0" + VALUE "InternalName", "npthirdtest" + VALUE "MIMEType", "application/x-Third-Test" + VALUE "OriginalFilename", "npthirdtest.dll" + VALUE "ProductName", "Third Test Plug-in" + VALUE "ProductVersion", "1.0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END diff --git a/dom/plugins/test/testplugin/thirdplugin/nptest_name.cpp b/dom/plugins/test/testplugin/thirdplugin/nptest_name.cpp new file mode 100644 index 0000000000..34eb5973d4 --- /dev/null +++ b/dom/plugins/test/testplugin/thirdplugin/nptest_name.cpp @@ -0,0 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const char *sPluginName = "Third Test Plug-in"; +const char *sPluginDescription = "Third plug-in for testing purposes."; +const char *sMimeDescription = "application/x-Third-Test:ts3:Third test type"; diff --git a/dom/plugins/test/unit/test_allowed_types.js b/dom/plugins/test/unit/test_allowed_types.js new file mode 100644 index 0000000000..d610e5d1cb --- /dev/null +++ b/dom/plugins/test/unit/test_allowed_types.js @@ -0,0 +1,140 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +Components.utils.import("resource://gre/modules/Services.jsm"); + +function run_test() { + const pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost); + const pluginDefaultState = Services.prefs.getIntPref("plugin.default.state"); + + function reload_plugins_with_allowed_types(allowed_types) { + if (typeof allowed_types === "undefined") { + // If we didn't get an allowed_types string, then unset the pref, + // so the caller can test the behavior when the pref isn't set. + Services.prefs.clearUserPref("plugin.allowed_types"); + } else { + Services.prefs.setCharPref("plugin.allowed_types", allowed_types); + } + pluginHost.reloadPlugins(); + } + + function get_status_for_type(type) { + try { + return pluginHost.getStateForType(type); + } catch(ex) { + // If the type is not allowed, then nsIPluginHost.getStateForType throws + // NS_ERROR_NOT_AVAILABLE, for which we return undefined to make it easier + // to write assertions about the API. + if (ex.result === Cr.NS_ERROR_NOT_AVAILABLE) { + return undefined; + } + throw ex; + } + } + + // If allowed_types isn't set, then all plugin types are enabled. + reload_plugins_with_allowed_types(); + do_check_eq(get_status_for_type("application/x-test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-Second-Test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-nonexistent"), undefined); + + // If allowed_types is set to the empty string, then all plugin types are enabled. + reload_plugins_with_allowed_types(""); + do_check_eq(get_status_for_type("application/x-test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-Second-Test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-nonexistent"), undefined); + + // If allowed_types is set to anything other than the empty string, + // then only types that exactly match its comma-separated entries are enabled, + // so a single space disables all types. + reload_plugins_with_allowed_types(" "); + do_check_eq(get_status_for_type("application/x-test"), undefined); + do_check_eq(get_status_for_type("application/x-Second-Test"), undefined); + do_check_eq(get_status_for_type("application/x-nonexistent"), undefined); + + // The rest of the assertions test various values of allowed_types to ensure + // that the correct types are enabled. + + reload_plugins_with_allowed_types("application/x-test"); + do_check_eq(get_status_for_type("application/x-test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-Second-Test"), undefined); + do_check_eq(get_status_for_type("application/x-nonexistent"), undefined); + + reload_plugins_with_allowed_types("application/x-Second-Test"); + do_check_eq(get_status_for_type("application/x-test"), undefined); + do_check_eq(get_status_for_type("application/x-Second-Test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-nonexistent"), undefined); + + reload_plugins_with_allowed_types("application/x-nonexistent"); + do_check_eq(get_status_for_type("application/x-test"), undefined); + do_check_eq(get_status_for_type("application/x-Second-Test"), undefined); + do_check_eq(get_status_for_type("application/x-nonexistent"), undefined); + + reload_plugins_with_allowed_types("application/x-test,application/x-Second-Test"); + do_check_eq(get_status_for_type("application/x-test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-Second-Test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-nonexistent"), undefined); + + reload_plugins_with_allowed_types("application/x-Second-Test,application/x-test"); + do_check_eq(get_status_for_type("application/x-test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-Second-Test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-nonexistent"), undefined); + + reload_plugins_with_allowed_types("application/x-test,application/x-nonexistent"); + do_check_eq(get_status_for_type("application/x-test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-Second-Test"), undefined); + do_check_eq(get_status_for_type("application/x-nonexistent"), undefined); + + reload_plugins_with_allowed_types("application/x-nonexistent,application/x-test"); + do_check_eq(get_status_for_type("application/x-test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-Second-Test"), undefined); + do_check_eq(get_status_for_type("application/x-nonexistent"), undefined); + + reload_plugins_with_allowed_types("application/x-test,application/x-Second-Test,application/x-nonexistent"); + do_check_eq(get_status_for_type("application/x-test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-Second-Test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-nonexistent"), undefined); + + reload_plugins_with_allowed_types("application/x-test,application/x-nonexistent,application/x-Second-Test"); + do_check_eq(get_status_for_type("application/x-test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-Second-Test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-nonexistent"), undefined); + + reload_plugins_with_allowed_types("application/x-Second-Test,application/x-test,application/x-nonexistent"); + do_check_eq(get_status_for_type("application/x-test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-Second-Test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-nonexistent"), undefined); + + reload_plugins_with_allowed_types("application/x-Second-Test,application/x-nonexistent,application/x-test"); + do_check_eq(get_status_for_type("application/x-test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-Second-Test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-nonexistent"), undefined); + + reload_plugins_with_allowed_types("application/x-nonexistent,application/x-test,application/x-Second-Test"); + do_check_eq(get_status_for_type("application/x-test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-Second-Test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-nonexistent"), undefined); + + reload_plugins_with_allowed_types("application/x-nonexistent,application/x-Second-Test,application/x-test"); + do_check_eq(get_status_for_type("application/x-test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-Second-Test"), pluginDefaultState); + do_check_eq(get_status_for_type("application/x-nonexistent"), undefined); + + // Plugin types are case-insensitive, so matching should be too. + reload_plugins_with_allowed_types("APPLICATION/X-TEST"); + do_check_eq(get_status_for_type("application/x-test"), pluginDefaultState); + reload_plugins_with_allowed_types("application/x-test"); + do_check_eq(get_status_for_type("APPLICATION/X-TEST"), pluginDefaultState); + + // Types must match exactly, so supersets should not enable subset types. + reload_plugins_with_allowed_types("application/x-test-superset"); + do_check_eq(get_status_for_type("application/x-test"), undefined); + reload_plugins_with_allowed_types("superset-application/x-test"); + do_check_eq(get_status_for_type("application/x-test"), undefined); + + // Clean up. + Services.prefs.clearUserPref("plugin.allowed_types"); + Services.prefs.clearUserPref("plugin.importedState"); +} diff --git a/dom/plugins/test/unit/xpcshell.ini b/dom/plugins/test/unit/xpcshell.ini index 715604c9ee..af511cb378 100644 --- a/dom/plugins/test/unit/xpcshell.ini +++ b/dom/plugins/test/unit/xpcshell.ini @@ -1,5 +1,5 @@ [DEFAULT] -skip-if = buildapp == 'mulet' || toolkit == 'android' || toolkit == 'gonk' +skip-if = toolkit == 'android' || toolkit == 'gonk' head = head_plugins.js tail = tags = addons diff --git a/dom/webidl/HTMLObjectElement.webidl b/dom/webidl/HTMLObjectElement.webidl index 43aaa0dd40..4bfa1a8035 100644 --- a/dom/webidl/HTMLObjectElement.webidl +++ b/dom/webidl/HTMLObjectElement.webidl @@ -129,9 +129,6 @@ interface MozObjectLoadingContent { // The plugin is vulnerable (no update available) [ChromeOnly] const unsigned long PLUGIN_VULNERABLE_NO_UPDATE = 10; - // The plugin is in play preview mode - [ChromeOnly] - const unsigned long PLUGIN_PLAY_PREVIEW = 11; /** * The actual mime type (the one we got back from the network @@ -163,8 +160,8 @@ interface MozObjectLoadingContent { sequence getPluginParameters(); /** - * This method will play a plugin that has been stopped by the - * click-to-play plugins or play-preview features. + * This method will play a plugin that has been stopped by the click-to-play + * feature. */ [ChromeOnly, Throws] void playPlugin(); @@ -181,7 +178,7 @@ interface MozObjectLoadingContent { /** * This attribute will return true if the current content type has been * activated, either explicitly or by passing checks that would have it be - * click-to-play or play-preview. + * click-to-play. */ [ChromeOnly] readonly attribute boolean activated; @@ -206,12 +203,6 @@ interface MozObjectLoadingContent { [ChromeOnly] readonly attribute boolean hasRunningPlugin; - /** - * This method will disable the play-preview plugin state. - */ - [ChromeOnly, Throws] - void cancelPlayPreview(); - [ChromeOnly, Throws] readonly attribute unsigned long runID; }; diff --git a/js/src/asmjs/WasmFrameIterator.cpp b/js/src/asmjs/WasmFrameIterator.cpp index 5636469740..d4ec7a387d 100644 --- a/js/src/asmjs/WasmFrameIterator.cpp +++ b/js/src/asmjs/WasmFrameIterator.cpp @@ -510,6 +510,7 @@ ProfilingFrameIterator::ProfilingFrameIterator(const WasmActivation& activation, codeRange_(nullptr), callerFP_(nullptr), callerPC_(nullptr), + stackAddress_(nullptr), exitReason_(ExitReason::None) { // If profiling hasn't been enabled for this module, then CallerFPFromFP diff --git a/js/src/asmjs/WasmIonCompile.cpp b/js/src/asmjs/WasmIonCompile.cpp index 11c46fd55e..1c2fa10258 100644 --- a/js/src/asmjs/WasmIonCompile.cpp +++ b/js/src/asmjs/WasmIonCompile.cpp @@ -2589,7 +2589,7 @@ EmitIfElse(FunctionCompiler& f, bool hasElse, ExprType expected, MDefinition** d if (expected != ExprType::Void) *def = f.popPhiOutput(); - MOZ_ASSERT((expected != ExprType::Void) == !!*def); + MOZ_ASSERT_IF(!f.inDeadCode(), (expected != ExprType::Void) == !!*def); return true; } diff --git a/js/src/asmjs/WasmModule.cpp b/js/src/asmjs/WasmModule.cpp index 99688e0d0e..3c1c83b49d 100644 --- a/js/src/asmjs/WasmModule.cpp +++ b/js/src/asmjs/WasmModule.cpp @@ -231,14 +231,9 @@ StaticLinkData::clone(JSContext* cx, StaticLinkData* out) const size_t StaticLinkData::sizeOfExcludingThis(MallocSizeOf mallocSizeOf) const { - size_t size = internalLinks.sizeOfExcludingThis(mallocSizeOf) + - symbolicLinks.sizeOfExcludingThis(mallocSizeOf) + - SizeOfVectorExcludingThis(funcPtrTables, mallocSizeOf); - - for (const Uint32Vector& offsets : symbolicLinks) - size += offsets.sizeOfExcludingThis(mallocSizeOf); - - return size; + return internalLinks.sizeOfExcludingThis(mallocSizeOf) + + symbolicLinks.sizeOfExcludingThis(mallocSizeOf) + + SizeOfVectorExcludingThis(funcPtrTables, mallocSizeOf); } static size_t @@ -400,16 +395,22 @@ CodeRange::CodeRange(uint32_t funcIndex, uint32_t funcLineOrBytecode, FuncOffset end_ = offsets.end; } +static size_t +NullableStringLength(const char* chars) +{ + return chars ? strlen(chars) : 0; +} + size_t CacheableChars::serializedSize() const { - return sizeof(uint32_t) + strlen(get()); + return sizeof(uint32_t) + NullableStringLength(get()); } uint8_t* CacheableChars::serialize(uint8_t* cursor) const { - uint32_t length = strlen(get()); + uint32_t length = NullableStringLength(get()); cursor = WriteBytes(cursor, &length, sizeof(uint32_t)); cursor = WriteBytes(cursor, get(), length); return cursor; @@ -432,7 +433,7 @@ CacheableChars::deserialize(ExclusiveContext* cx, const uint8_t* cursor) bool CacheableChars::clone(JSContext* cx, CacheableChars* out) const { - uint32_t length = strlen(get()); + uint32_t length = NullableStringLength(get()); UniqueChars chars(cx->pod_calloc(length + 1)); if (!chars) diff --git a/js/src/asmjs/WasmText.cpp b/js/src/asmjs/WasmText.cpp index ef1ad08533..5853b0e048 100644 --- a/js/src/asmjs/WasmText.cpp +++ b/js/src/asmjs/WasmText.cpp @@ -1077,15 +1077,15 @@ ConsumeTextByte(const char16_t** curp, const char16_t* end, uint8_t *byte = null case '\"': u8 = '\"'; break; case '\'': u8 = '\''; break; default: { - uint8_t lowNibble; - if (!IsHexDigit(*cur, &lowNibble)) + uint8_t highNibble; + if (!IsHexDigit(*cur, &highNibble)) return false; if (++cur == end) return false; - uint8_t highNibble; - if (!IsHexDigit(*cur, &highNibble)) + uint8_t lowNibble; + if (!IsHexDigit(*cur, &lowNibble)) return false; u8 = lowNibble | (highNibble << 4); diff --git a/js/src/asmjs/WasmTypes.h b/js/src/asmjs/WasmTypes.h index 05aaf9e764..6bc872fb97 100644 --- a/js/src/asmjs/WasmTypes.h +++ b/js/src/asmjs/WasmTypes.h @@ -48,7 +48,9 @@ typedef Vector Uint32Vector; // The ValType enum represents the WebAssembly "value type", which are used to // specify the type of locals and parameters. -enum class ValType : uint8_t +// FIXME: uint16_t would make more sense for the underlying storage class, but +// causes miscompilations in GCC (fixed in 4.8.5 and 4.9.3). +enum class ValType { I32, I64, @@ -143,7 +145,7 @@ class Val // void represented by the empty list). For now it's easier to have a flat enum // and be explicit about conversions to/from value types. -enum class ExprType : uint8_t +enum class ExprType : uint16_t { I32 = uint8_t(ValType::I32), I64 = uint8_t(ValType::I64), diff --git a/js/src/builtin/Array.js b/js/src/builtin/Array.js index f8c3421609..18f4b7ec62 100644 --- a/js/src/builtin/Array.js +++ b/js/src/builtin/Array.js @@ -715,6 +715,7 @@ function CreateArrayIterator(obj, kind) { return CreateArrayIteratorAt(obj, kind, 0); } + function ArrayIteratorNext() { if (!IsObject(this) || !IsArrayIterator(this)) { return callFunction(CallArrayIteratorMethodIfWrapped, this, diff --git a/js/src/builtin/Function.js b/js/src/builtin/Function.js index 83a5931931..b6b637ceac 100644 --- a/js/src/builtin/Function.js +++ b/js/src/builtin/Function.js @@ -55,6 +55,9 @@ function FunctionBind(thisArg, ...boundArgs) { if (typeof targetName !== "string") targetName = ""; + // 9.2.11 SetFunctionName, Step 5.a. + targetName = "bound " + targetName; + // Steps 10-11, 15-16. _FinishBoundFunctionInit(F, target, L, targetName); diff --git a/js/src/builtin/ModuleObject.cpp b/js/src/builtin/ModuleObject.cpp index 64a5db9cf7..eefe54f6e0 100644 --- a/js/src/builtin/ModuleObject.cpp +++ b/js/src/builtin/ModuleObject.cpp @@ -582,6 +582,7 @@ ModuleObject::create(ExclusiveContext* cx, HandleObject enclosingStaticScope) IndirectBindingMap* bindings = zone->new_(zone); if (!bindings || !bindings->init()) { ReportOutOfMemory(cx); + js_delete(bindings); return nullptr; } @@ -894,6 +895,7 @@ ModuleObject::createNamespace(JSContext* cx, HandleModuleObject self, HandleObje IndirectBindingMap* bindings = zone->new_(zone); if (!bindings || !bindings->init()) { ReportOutOfMemory(cx); + js_delete(bindings); return nullptr; } diff --git a/js/src/builtin/Profilers.cpp b/js/src/builtin/Profilers.cpp index 100b26fbe6..d7a6649c6d 100644 --- a/js/src/builtin/Profilers.cpp +++ b/js/src/builtin/Profilers.cpp @@ -505,12 +505,11 @@ bool js_StartPerf() pid_t childPid = fork(); if (childPid == 0) { - /* perf record --append --pid $mainPID --output=$outfile $MOZ_PROFILE_PERF_FLAGS */ + /* perf record --pid $mainPID --output=$outfile $MOZ_PROFILE_PERF_FLAGS */ char mainPidStr[16]; snprintf(mainPidStr, sizeof(mainPidStr), "%d", mainPid); - const char* defaultArgs[] = {"perf", "record", "--append", - "--pid", mainPidStr, "--output", outfile}; + const char* defaultArgs[] = {"perf", "record", "--pid", mainPidStr, "--output", outfile}; Vector args; if (!args.append(defaultArgs, ArrayLength(defaultArgs))) @@ -521,15 +520,14 @@ bool js_StartPerf() flags = "--call-graph"; } - char* flags2 = (char*)js_malloc(strlen(flags) + 1); + UniqueChars flags2((char*)js_malloc(strlen(flags) + 1)); if (!flags2) return false; - strcpy(flags2, flags); + strcpy(flags2.get(), flags); - // Split |flags2| on spaces. (Don't bother to free it -- we're going to - // exec anyway.) + // Split |flags2| on spaces. char* toksave; - char* tok = strtok_r(flags2, " ", &toksave); + char* tok = strtok_r(flags2.get(), " ", &toksave); while (tok) { if (!args.append(tok)) return false; @@ -545,17 +543,15 @@ bool js_StartPerf() fprintf(stderr, "Unable to start perf.\n"); exit(1); } - else if (childPid > 0) { + if (childPid > 0) { perfPid = childPid; /* Give perf a chance to warm up. */ usleep(500 * 1000); return true; } - else { - UnsafeError("js_StartPerf: fork() failed\n"); - return false; - } + UnsafeError("js_StartPerf: fork() failed\n"); + return false; } bool js_StopPerf() diff --git a/js/src/builtin/SIMD.cpp b/js/src/builtin/SIMD.cpp index bc2fc34900..e033d3b2f3 100644 --- a/js/src/builtin/SIMD.cpp +++ b/js/src/builtin/SIMD.cpp @@ -355,7 +355,7 @@ const JSFunctionSpec Bool16x8Defn::Methods[] = { const JSFunctionSpec Bool32x4Defn::Methods[] = { #define SIMD_BOOL32X4_FUNCTION_ITEM(Name, Func, Operands) \ - JS_FN(#Name, js::simd_bool32x4_##Name, Operands, 0), + JS_INLINABLE_FN(#Name, js::simd_bool32x4_##Name, Operands, 0, SimdBool32x4_##Name), BOOL32X4_FUNCTION_LIST(SIMD_BOOL32X4_FUNCTION_ITEM) #undef SIMD_BOOL32X4_FUNCTION_ITEM JS_FS_END diff --git a/js/src/builtin/SelfHostingDefines.h b/js/src/builtin/SelfHostingDefines.h index db7ed70b79..880dc81d08 100644 --- a/js/src/builtin/SelfHostingDefines.h +++ b/js/src/builtin/SelfHostingDefines.h @@ -19,12 +19,6 @@ #define FUN_APPLY(FUN, RECEIVER, ARGS) \ callFunction(std_Function_apply, FUN, RECEIVER, ARGS) -// Unforgeable versions of ARRAY.push(ELEMENT) and ARRAY.slice. -#define ARRAY_PUSH(ARRAY, ELEMENT) \ - callFunction(std_Array_push, ARRAY, ELEMENT); -#define ARRAY_SLICE(ARRAY, ELEMENT) \ - callFunction(std_Array_slice, ARRAY, ELEMENT); - // Property descriptor attributes. #define ATTR_ENUMERABLE 0x01 #define ATTR_CONFIGURABLE 0x02 diff --git a/js/src/builtin/String.js b/js/src/builtin/String.js index b4e6b4fe05..80e513f17a 100644 --- a/js/src/builtin/String.js +++ b/js/src/builtin/String.js @@ -68,7 +68,7 @@ function String_substr(start, length) { intStart = std_Math_max(intStart + size, 0); // Step 9. - var resultLength = std_Math_min(std_Math_max(end, 0), size - intStart) + var resultLength = std_Math_min(std_Math_max(end, 0), size - intStart); // Step 10. if (resultLength <= 0) diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index a50fed98fe..b599763ebf 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -1207,11 +1207,30 @@ OOMTest(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (args.length() != 1 || !args[0].isObject() || !args[0].toObject().is()) { - JS_ReportError(cx, "oomTest() takes a single function argument."); + if (args.length() < 1 || args.length() > 2) { + JS_ReportError(cx, "oomTest() takes between 1 and 2 arguments."); return false; } + if (!args[0].isObject() || !args[0].toObject().is()) { + JS_ReportError(cx, "The first argument to oomTest() must be a function."); + return false; + } + + if (args.length() == 2 && !args[1].isBoolean()) { + JS_ReportError(cx, "The optional second argument to oomTest() must be a boolean."); + return false; + } + + bool expectExceptionOnFailure = true; + if (args.length() == 2) + expectExceptionOnFailure = args[1].toBoolean(); + + // There are some places where we do fail without raising an exception, so + // we can't expose this to the fuzzers by default. + if (fuzzingSafe) + expectExceptionOnFailure = false; + if (disableOOMFunctions) { args.rval().setUndefined(); return true; @@ -1269,6 +1288,16 @@ OOMTest(JSContext* cx, unsigned argc, Value* vp) MOZ_ASSERT_IF(ok, !cx->isExceptionPending()); + if (ok) { + MOZ_ASSERT(!cx->isExceptionPending(), + "Thunk execution succeeded but an exception was raised - " + "missing error check?"); + } else if (expectExceptionOnFailure) { + MOZ_ASSERT(cx->isExceptionPending(), + "Thunk execution failed but no exception was raised - " + "missing call to js::ReportOutOfMemory()?"); + } + // Note that it is possible that the function throws an exception // unconnected to OOM, in which case we ignore it. More correct // would be to have the caller pass some kind of exception @@ -2102,12 +2131,12 @@ Deserialize(JSContext* cx, unsigned argc, Value* vp) } static bool -Neuter(JSContext* cx, unsigned argc, Value* vp) +DetachArrayBuffer(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() != 2) { - JS_ReportError(cx, "wrong number of arguments to neuter()"); + JS_ReportError(cx, "wrong number of arguments to detachArrayBuffer()"); return false; } @@ -2116,7 +2145,7 @@ Neuter(JSContext* cx, unsigned argc, Value* vp) return false; if (!obj) { - JS_ReportError(cx, "neuter must be passed an object"); + JS_ReportError(cx, "detachArrayBuffer must be passed an object"); return false; } @@ -2133,7 +2162,7 @@ Neuter(JSContext* cx, unsigned argc, Value* vp) } else if (strcmp(dataDisposition.ptr(), "change-data") == 0) { changeData = ChangeData; } else { - JS_ReportError(cx, "unknown parameter 2 to neuter()"); + JS_ReportError(cx, "unknown parameter 2 to detachArrayBuffer()"); return false; } @@ -2563,7 +2592,11 @@ FindPath(JSContext* cx, unsigned argc, Value* vp) if (!obj) return false; - if (!JS_DefineProperty(cx, obj, "node", nodes[i], + RootedValue wrapped(cx, nodes[i]); + if (!cx->compartment()->wrap(cx, &wrapped)) + return false; + + if (!JS_DefineProperty(cx, obj, "node", wrapped, JSPROP_ENUMERATE, nullptr, nullptr)) return false; @@ -3493,10 +3526,13 @@ static const JSFunctionSpecWithHelp TestingFunctions[] = { " oomAtAllocation() and return whether any allocation had been caused to fail."), JS_FN_HELP("oomTest", OOMTest, 0, 0, -"oomTest(function)", +"oomTest(function, [expectExceptionOnFailure = true])", " Test that the passed function behaves correctly under OOM conditions by\n" " repeatedly executing it and simulating allocation failure at successive\n" -" allocations until the function completes without seeing a failure."), +" allocations until the function completes without seeing a failure.\n" +" By default this tests that an exception is raised if execution fails, but\n" +" this can be disabled by passing false as the optional second parameter.\n" +" This is also disabled when --fuzzing-safe is specified."), #endif JS_FN_HELP("makeFakePromise", MakeFakePromise, 0, 0, @@ -3728,12 +3764,12 @@ gc::ZealModeHelpText), "deserialize(clonebuffer)", " Deserialize data generated by serialize."), - JS_FN_HELP("neuter", Neuter, 1, 0, -"neuter(buffer, \"change-data\"|\"same-data\")", -" Neuter the given ArrayBuffer object as if it had been transferred to a\n" -" WebWorker. \"change-data\" will update the internal data pointer.\n" -" \"same-data\" will leave it set to its original value, to mimic eg\n" -" asm.js ArrayBuffer neutering."), + JS_FN_HELP("detachArrayBuffer", DetachArrayBuffer, 1, 0, +"detachArrayBuffer(buffer, \"change-data\"|\"same-data\")", +" Detach the given ArrayBuffer object from its memory, i.e. as if it\n" +" had been transferred to a WebWorker. \"change-data\" will update\n" +" the internal data pointer. \"same-data\" will leave it set to \n" +" its original value, mimicking, e.g., asm.js ArrayBuffer detaching."), JS_FN_HELP("helperThreadCount", HelperThreadCount, 0, 0, "helperThreadCount()", diff --git a/js/src/builtin/Utilities.js b/js/src/builtin/Utilities.js index 67cecc15e1..9c590b2018 100644 --- a/js/src/builtin/Utilities.js +++ b/js/src/builtin/Utilities.js @@ -155,12 +155,14 @@ function GetIterator(obj, method) { } var _builtinCtorsCache = {__proto__: null}; + function GetBuiltinConstructor(builtinName) { var ctor = _builtinCtorsCache[builtinName] || (_builtinCtorsCache[builtinName] = GetBuiltinConstructorImpl(builtinName)); assert(ctor, `No builtin with name "${builtinName}" found`); return ctor; } + function GetBuiltinPrototype(builtinName) { return (_builtinCtorsCache[builtinName] || GetBuiltinConstructor(builtinName)).prototype; } diff --git a/js/src/ctypes/CTypes.cpp b/js/src/ctypes/CTypes.cpp index 562b3861fd..73bddaaa65 100644 --- a/js/src/ctypes/CTypes.cpp +++ b/js/src/ctypes/CTypes.cpp @@ -434,6 +434,7 @@ namespace CDataFinalizer { namespace Methods { static bool Dispose(JSContext* cx, unsigned argc, Value* vp); static bool Forget(JSContext* cx, unsigned argc, Value* vp); + static bool ReadString(JSContext* cx, unsigned argc, Value* vp); static bool ToSource(JSContext* cx, unsigned argc, Value* vp); static bool ToString(JSContext* cx, unsigned argc, Value* vp); } // namespace Methods @@ -483,7 +484,6 @@ namespace CDataFinalizer { */ static bool GetValue(JSContext* cx, JSObject* obj, MutableHandleValue result); - static JSObject* GetCData(JSContext* cx, JSObject* obj); } // namespace CDataFinalizer @@ -675,7 +675,7 @@ static const JSFunctionSpec sCDataFunctions[] = { static const JSFunctionSpec sCDataFinalizerFunctions[] = { JS_FN("dispose", CDataFinalizer::Methods::Dispose, 0, CDATAFINALIZERFN_FLAGS), JS_FN("forget", CDataFinalizer::Methods::Forget, 0, CDATAFINALIZERFN_FLAGS), - JS_FN("readString",CData::ReadString, 0, CDATAFINALIZERFN_FLAGS), + JS_FN("readString", CDataFinalizer::Methods::ReadString, 0, CDATAFINALIZERFN_FLAGS), JS_FN("toString", CDataFinalizer::Methods::ToString, 0, CDATAFINALIZERFN_FLAGS), JS_FN("toSource", CDataFinalizer::Methods::ToSource, 0, CDATAFINALIZERFN_FLAGS), JS_FS_END @@ -1337,6 +1337,35 @@ ArgumentTypeMismatch(JSContext* cx, const char* arg, const char* func, return false; } +static bool +CannotConstructError(JSContext* cx, const char* type) +{ + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_CANNOT_CONSTRUCT, type); + return false; +} + +static bool +DuplicateFieldError(JSContext* cx, Handle name) +{ + JSAutoByteString nameBytes; + const char* nameStr = nameBytes.encodeLatin1(cx, name); + if (!nameStr) + return false; + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_DUPLICATE_FIELD, nameStr); + return false; +} + +static bool +EmptyFinalizerCallError(JSContext* cx, const char* funName) +{ + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_EMPTY_FIN_CALL, funName); + return false; +} + static bool EmptyFinalizerError(JSContext* cx, ConversionType convType, HandleObject funObj = nullptr, unsigned argIndex = 0) @@ -1403,6 +1432,110 @@ FieldCountMismatch(JSContext* cx, return false; } +static bool +FieldDescriptorCountError(JSContext* cx, Value val, size_t length) +{ + RootedValue typeVal(cx, val); + JSAutoByteString valBytes; + const char* valStr = CTypesToSourceForError(cx, typeVal, valBytes); + if (!valStr) + return false; + + char lengthStr[16]; + JS_snprintf(lengthStr, 16, "%u", length); + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_FIELD_DESC_COUNT, valStr, lengthStr); + return false; +} + +static bool +FieldDescriptorNameError(JSContext* cx, HandleId id) +{ + JSAutoByteString idBytes; + RootedValue idVal(cx, IdToValue(id)); + const char* propStr = CTypesToSourceForError(cx, idVal, idBytes); + if (!propStr) + return false; + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_FIELD_DESC_NAME, propStr); + return false; +} + +static bool +FieldDescriptorSizeError(JSContext* cx, HandleObject typeObj, HandleId id) +{ + RootedValue typeVal(cx, ObjectValue(*typeObj)); + JSAutoByteString typeBytes; + const char* typeStr = CTypesToSourceForError(cx, typeVal, typeBytes); + if (!typeStr) + return false; + + RootedString idStr(cx, IdToString(cx, id)); + JSAutoByteString idBytes; + const char* propStr = idBytes.encodeLatin1(cx, idStr); + if (!propStr) + return false; + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_FIELD_DESC_SIZE, typeStr, propStr); + return false; +} + +static bool +FieldDescriptorNameTypeError(JSContext* cx, Value val) +{ + RootedValue typeVal(cx, val); + JSAutoByteString valBytes; + const char* valStr = CTypesToSourceForError(cx, typeVal, valBytes); + if (!valStr) + return false; + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_FIELD_DESC_NAMETYPE, valStr); + return false; +} + +static bool +FieldDescriptorTypeError(JSContext* cx, HandleValue poroVal, HandleId id) +{ + JSAutoByteString typeBytes; + const char* typeStr = CTypesToSourceForError(cx, poroVal, typeBytes); + if (!typeStr) + return false; + + RootedString idStr(cx, IdToString(cx, id)); + JSAutoByteString idBytes; + const char* propStr = idBytes.encodeLatin1(cx, idStr); + if (!propStr) + return false; + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_FIELD_DESC_TYPE, typeStr, propStr); + return false; +} + +static bool +FieldMissingError(JSContext* cx, JSObject* typeObj, JSFlatString* name_) +{ + JSAutoByteString typeBytes; + RootedString name(cx, name_); + RootedValue typeVal(cx, ObjectValue(*typeObj)); + const char* typeStr = CTypesToSourceForError(cx, typeVal, typeBytes); + if (!typeStr) + return false; + + JSAutoByteString nameBytes; + const char* nameStr = nameBytes.encodeLatin1(cx, name); + if (!nameStr) + return false; + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_FIELD_MISSING, typeStr, nameStr); + return false; +} + static bool FinalizerSizeError(JSContext* cx, HandleObject funObj, HandleValue actual) { @@ -1425,6 +1558,164 @@ FinalizerSizeError(JSContext* cx, HandleObject funObj, HandleValue actual) return false; } +static bool +FunctionArgumentLengthMismatch(JSContext* cx, + unsigned expectedCount, unsigned actualCount, + HandleObject funObj, HandleObject typeObj, + bool isVariadic) +{ + AutoString funSource; + JSAutoByteString funBytes; + Value slot = JS_GetReservedSlot(funObj, SLOT_REFERENT); + if (!slot.isUndefined() && Library::IsLibrary(&slot.toObject())) { + BuildFunctionTypeSource(cx, funObj, funSource); + } else { + BuildFunctionTypeSource(cx, typeObj, funSource); + } + const char* funStr = EncodeLatin1(cx, funSource, funBytes); + if (!funStr) + return false; + + char expectedCountStr[16]; + JS_snprintf(expectedCountStr, 16, "%u", expectedCount); + char actualCountStr[16]; + JS_snprintf(actualCountStr, 16, "%u", actualCount); + + const char* variadicStr = isVariadic ? " or more": ""; + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_ARG_COUNT_MISMATCH, + funStr, expectedCountStr, variadicStr, actualCountStr); + return false; +} + +static bool +FunctionArgumentTypeError(JSContext* cx, + uint32_t index, Value type, const char* reason) +{ + RootedValue val(cx, type); + JSAutoByteString valBytes; + const char* valStr = CTypesToSourceForError(cx, val, valBytes); + if (!valStr) + return false; + + char indexStr[16]; + JS_snprintf(indexStr, 16, "%u", index + 1); + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_ARG_TYPE_ERROR, indexStr, reason, valStr); + return false; +} + +static bool +FunctionReturnTypeError(JSContext* cx, Value type, const char* reason) +{ + RootedValue val(cx, type); + JSAutoByteString valBytes; + const char* valStr = CTypesToSourceForError(cx, val, valBytes); + if (!valStr) + return false; + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_RET_TYPE_ERROR, reason, valStr); + return false; +} + +static bool +IncompatibleCallee(JSContext* cx, const char* funName, HandleObject actualObj) +{ + JSAutoByteString valBytes; + RootedValue val(cx, ObjectValue(*actualObj)); + const char* valStr = CTypesToSourceForError(cx, val, valBytes); + if (!valStr) + return false; + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_INCOMPATIBLE_CALLEE, funName, valStr); + return false; +} + +static bool +IncompatibleThisProto(JSContext* cx, const char* funName, + const char* actualType) +{ + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_INCOMPATIBLE_THIS, + funName, actualType); + return false; +} + +static bool +IncompatibleThisProto(JSContext* cx, const char* funName, HandleValue actualVal) +{ + JSAutoByteString valBytes; + const char* valStr = CTypesToSourceForError(cx, actualVal, valBytes); + if (!valStr) + return false; + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_INCOMPATIBLE_THIS_VAL, + funName, "incompatible object", valStr); + return false; +} + +static bool +IncompatibleThisType(JSContext* cx, const char* funName, const char* actualType) +{ + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_INCOMPATIBLE_THIS_TYPE, funName, actualType); + return false; +} + +static bool +IncompatibleThisType(JSContext* cx, const char* funName, const char* actualType, + HandleValue actualVal) +{ + JSAutoByteString valBytes; + const char* valStr = CTypesToSourceForError(cx, actualVal, valBytes); + if (!valStr) + return false; + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_INCOMPATIBLE_THIS_VAL, + funName, actualType, valStr); + return false; +} + +static bool +InvalidIndexError(JSContext* cx, HandleValue val) +{ + JSAutoByteString idBytes; + const char* indexStr = CTypesToSourceForError(cx, val, idBytes); + if (!indexStr) + return false; + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_INVALID_INDEX, indexStr); + return false; +} + +static bool +InvalidIndexError(JSContext* cx, HandleId id) +{ + RootedValue idVal(cx, IdToValue(id)); + return InvalidIndexError(cx, idVal); +} + +static bool +InvalidIndexRangeError(JSContext* cx, size_t index, size_t length) +{ + char indexStr[16]; + JS_snprintf(indexStr, 16, "%u", index); + + char lengthStr[16]; + JS_snprintf(lengthStr, 16, "%u", length); + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_INVALID_RANGE, indexStr, lengthStr); + return false; +} + static bool NonPrimitiveError(JSContext* cx, HandleObject typeObj) { @@ -1442,6 +1733,33 @@ NonPrimitiveError(JSContext* cx, HandleObject typeObj) return false; } +static bool +NonStringBaseError(JSContext* cx, HandleValue thisVal) +{ + JSAutoByteString valBytes; + const char* valStr = CTypesToSourceForError(cx, thisVal, valBytes); + if (!valStr) + return false; + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_NON_STRING_BASE, valStr); + return false; +} + +static bool +NullPointerError(JSContext* cx, const char* action, HandleObject obj) +{ + JSAutoByteString valBytes; + RootedValue val(cx, ObjectValue(*obj)); + const char* valStr = CTypesToSourceForError(cx, val, valBytes); + if (!valStr) + return false; + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_NULL_POINTER, action, valStr); + return false; +} + static bool PropNameNonStringError(JSContext* cx, HandleId id, HandleValue actual, ConversionType convType, @@ -1509,6 +1827,85 @@ TypeOverflow(JSContext* cx, const char* expected, HandleValue actual) return false; } +static bool +UndefinedSizeCastError(JSContext* cx, HandleObject targetTypeObj) +{ + AutoString targetTypeSource; + JSAutoByteString targetTypeBytes; + BuildTypeSource(cx, targetTypeObj, true, targetTypeSource); + const char* targetTypeStr = EncodeLatin1(cx, targetTypeSource, + targetTypeBytes); + if (!targetTypeStr) + return false; + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_UNDEFINED_SIZE_CAST, targetTypeStr); + return false; +} + +static bool +SizeMismatchCastError(JSContext* cx, + HandleObject sourceTypeObj, HandleObject targetTypeObj, + size_t sourceSize, size_t targetSize) +{ + AutoString sourceTypeSource; + JSAutoByteString sourceTypeBytes; + BuildTypeSource(cx, sourceTypeObj, true, sourceTypeSource); + const char* sourceTypeStr = EncodeLatin1(cx, sourceTypeSource, + sourceTypeBytes); + if (!sourceTypeStr) + return false; + + AutoString targetTypeSource; + JSAutoByteString targetTypeBytes; + BuildTypeSource(cx, targetTypeObj, true, targetTypeSource); + const char* targetTypeStr = EncodeLatin1(cx, targetTypeSource, + targetTypeBytes); + if (!targetTypeStr) + return false; + + char sourceSizeStr[16]; + char targetSizeStr[16]; + JS_snprintf(sourceSizeStr, 16, "%u", sourceSize); + JS_snprintf(targetSizeStr, 16, "%u", targetSize); + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_SIZE_MISMATCH_CAST, + targetTypeStr, sourceTypeStr, + targetSizeStr, sourceSizeStr); + return false; +} + +static bool +UndefinedSizePointerError(JSContext* cx, const char* action, HandleObject obj) +{ + JSAutoByteString valBytes; + RootedValue val(cx, ObjectValue(*obj)); + const char* valStr = CTypesToSourceForError(cx, val, valBytes); + if (!valStr) + return false; + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_UNDEFINED_SIZE, action, valStr); + return false; +} + +static bool +VariadicArgumentTypeError(JSContext* cx, uint32_t index, HandleValue actual) +{ + JSAutoByteString valBytes; + const char* valStr = CTypesToSourceForError(cx, actual, valBytes); + if (!valStr) + return false; + + char indexStr[16]; + JS_snprintf(indexStr, 16, "%u", index + 1); + + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_VARG_TYPE_ERROR, indexStr, valStr); + return false; +} + static JSObject* InitCTypeClass(JSContext* cx, HandleObject ctypesObj) { @@ -3895,8 +4292,7 @@ ConstructAbstract(JSContext* cx, Value* vp) { // Calling an abstract base class constructor is disallowed. - JS_ReportError(cx, "cannot construct from abstract type"); - return false; + return CannotConstructError(cx, "abstract type"); } /******************************************************************************* @@ -3912,8 +4308,7 @@ CType::ConstructData(JSContext* cx, // get the callee object... RootedObject obj(cx, &args.callee()); if (!CType::IsCType(obj)) { - JS_ReportError(cx, "not a CType"); - return false; + return IncompatibleCallee(cx, "CType constructor", obj); } // How we construct the CData object depends on what type we represent. @@ -3922,10 +4317,10 @@ CType::ConstructData(JSContext* cx, // * __proto__ === t.prototype switch (GetTypeCode(obj)) { case TYPE_void_t: - JS_ReportError(cx, "cannot construct from void_t"); - return false; + return CannotConstructError(cx, "void_t"); case TYPE_function: - JS_ReportError(cx, "cannot construct from FunctionType; use FunctionType.ptr instead"); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, + CTYPESMSG_FUNCTION_CONSTRUCT); return false; case TYPE_pointer: return PointerType::ConstructData(cx, obj, args); @@ -4455,8 +4850,7 @@ CType::CreateArray(JSContext* cx, unsigned argc, Value* vp) if (!baseType) return false; if (!CType::IsCType(baseType)) { - JS_ReportError(cx, "not a CType"); - return false; + return IncompatibleThisProto(cx, "CType.prototype.array", args.thisv()); } // Construct and return a new ArrayType object. @@ -4487,8 +4881,8 @@ CType::ToString(JSContext* cx, unsigned argc, Value* vp) if (!obj) return false; if (!CType::IsCType(obj) && !CType::IsCTypeProto(obj)) { - JS_ReportError(cx, "not a CType"); - return false; + return IncompatibleThisProto(cx, "CType.prototype.toString", + InformalValueTypeName(args.thisv())); } // Create the appropriate string depending on whether we're sCTypeClass or @@ -4517,10 +4911,9 @@ CType::ToSource(JSContext* cx, unsigned argc, Value* vp) JSObject* obj = JS_THIS_OBJECT(cx, vp); if (!obj) return false; - if (!CType::IsCType(obj) && !CType::IsCTypeProto(obj)) - { - JS_ReportError(cx, "not a CType"); - return false; + if (!CType::IsCType(obj) && !CType::IsCTypeProto(obj)) { + return IncompatibleThisProto(cx, "CType.prototype.toSource", + InformalValueTypeName(args.thisv())); } // Create the appropriate string depending on whether we're sCTypeClass or @@ -4607,8 +5000,8 @@ ABI::ToSource(JSContext* cx, unsigned argc, Value* vp) if (!obj) return false; if (!ABI::IsABI(obj)) { - JS_ReportError(cx, "not an ABI"); - return false; + return IncompatibleThisProto(cx, "ABI.prototype.toSource", + InformalValueTypeName(args.thisv())); } JSString* result; @@ -4703,8 +5096,7 @@ PointerType::ConstructData(JSContext* cx, const CallArgs& args) { if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_pointer) { - JS_ReportError(cx, "not a PointerType"); - return false; + return IncompatibleCallee(cx, "PointerType constructor", obj); } if (args.length() > 3) { @@ -4823,15 +5215,15 @@ PointerType::IsNull(JSContext* cx, unsigned argc, Value* vp) if (!obj) return false; if (!CData::IsCData(obj)) { - JS_ReportError(cx, "not a CData"); - return false; + return IncompatibleThisProto(cx, "PointerType.prototype.isNull", + args.thisv()); } // Get pointer type and base type. JSObject* typeObj = CData::GetCType(obj); if (CType::GetTypeCode(typeObj) != TYPE_pointer) { - JS_ReportError(cx, "not a PointerType"); - return false; + return IncompatibleThisType(cx, "PointerType.prototype.isNull", + "non-PointerType CData", args.thisv()); } void* data = *static_cast(CData::GetData(obj)); @@ -4842,24 +5234,31 @@ PointerType::IsNull(JSContext* cx, unsigned argc, Value* vp) bool PointerType::OffsetBy(JSContext* cx, const CallArgs& args, int offset) { - JSObject* obj = JS_THIS_OBJECT(cx, args.base()); + RootedObject obj(cx, JS_THIS_OBJECT(cx, args.base())); if (!obj) return false; if (!CData::IsCData(obj)) { - JS_ReportError(cx, "not a CData"); - return false; + if (offset == 1) { + return IncompatibleThisProto(cx, "PointerType.prototype.increment", + args.thisv()); + } + return IncompatibleThisProto(cx, "PointerType.prototype.decrement", + args.thisv()); } RootedObject typeObj(cx, CData::GetCType(obj)); if (CType::GetTypeCode(typeObj) != TYPE_pointer) { - JS_ReportError(cx, "not a PointerType"); - return false; + if (offset == 1) { + return IncompatibleThisType(cx, "PointerType.prototype.increment", + "non-PointerType CData", args.thisv()); + } + return IncompatibleThisType(cx, "PointerType.prototype.decrement", + "non-PointerType CData", args.thisv()); } RootedObject baseType(cx, PointerType::GetBaseType(typeObj)); if (!CType::IsSizeDefined(baseType)) { - JS_ReportError(cx, "cannot modify pointer of undefined size"); - return false; + return UndefinedSizePointerError(cx, "modify", obj); } size_t elementSize = CType::GetSize(baseType); @@ -4895,14 +5294,12 @@ PointerType::ContentsGetter(JSContext* cx, const JS::CallArgs& args) RootedObject obj(cx, &args.thisv().toObject()); RootedObject baseType(cx, GetBaseType(CData::GetCType(obj))); if (!CType::IsSizeDefined(baseType)) { - JS_ReportError(cx, "cannot get contents of undefined size"); - return false; + return UndefinedSizePointerError(cx, "get contents of", obj); } void* data = *static_cast(CData::GetData(obj)); if (data == nullptr) { - JS_ReportError(cx, "cannot read contents of null pointer"); - return false; + return NullPointerError(cx, "read contents of", obj); } RootedValue result(cx); @@ -4919,14 +5316,12 @@ PointerType::ContentsSetter(JSContext* cx, const JS::CallArgs& args) RootedObject obj(cx, &args.thisv().toObject()); RootedObject baseType(cx, GetBaseType(CData::GetCType(obj))); if (!CType::IsSizeDefined(baseType)) { - JS_ReportError(cx, "cannot set contents of undefined size"); - return false; + return UndefinedSizePointerError(cx, "set contents of", obj); } void* data = *static_cast(CData::GetData(obj)); if (data == nullptr) { - JS_ReportError(cx, "cannot write contents to null pointer"); - return false; + return NullPointerError(cx, "write contents to", obj); } args.rval().setUndefined(); @@ -5035,8 +5430,7 @@ ArrayType::ConstructData(JSContext* cx, RootedObject obj(cx, obj_); // Make a mutable version if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_array) { - JS_ReportError(cx, "not an ArrayType"); - return false; + return IncompatibleCallee(cx, "ArrayType constructor", obj); } // Decide whether we have an object to initialize from. We'll override this @@ -5280,8 +5674,8 @@ ArrayType::Getter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandle { // This should never happen, but we'll check to be safe. if (!CData::IsCData(obj)) { - JS_ReportError(cx, "not a CData"); - return false; + RootedValue objVal(cx, ObjectValue(*obj)); + return IncompatibleThisProto(cx, "ArrayType property getter", objVal); } // Bail early if we're not an ArrayType. (This setter is present for all @@ -5304,9 +5698,11 @@ ArrayType::Getter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandle // Chances are it's a regular property lookup, so return. return true; } - if (!ok || index >= length) { - JS_ReportError(cx, "invalid index"); - return false; + if (!ok) { + return InvalidIndexError(cx, idval); + } + if (index >= length) { + return InvalidIndexRangeError(cx, index, length); } RootedObject baseType(cx, GetBaseType(typeObj)); @@ -5321,8 +5717,8 @@ ArrayType::Setter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandle { // This should never happen, but we'll check to be safe. if (!CData::IsCData(obj)) { - JS_ReportError(cx, "not a CData"); - return false; + RootedValue objVal(cx, ObjectValue(*obj)); + return IncompatibleThisProto(cx, "ArrayType property setter", objVal); } // Bail early if we're not an ArrayType. (This setter is present for all @@ -5345,9 +5741,11 @@ ArrayType::Setter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandle // Chances are it's a regular property lookup, so return. return result.succeed(); } - if (!ok || index >= length) { - JS_ReportError(cx, "invalid index"); - return false; + if (!ok) { + return InvalidIndexError(cx, idval); + } + if (index >= length) { + return InvalidIndexRangeError(cx, index, length); } RootedObject baseType(cx, GetBaseType(typeObj)); @@ -5367,14 +5765,14 @@ ArrayType::AddressOfElement(JSContext* cx, unsigned argc, Value* vp) if (!obj) return false; if (!CData::IsCData(obj)) { - JS_ReportError(cx, "not a CData"); - return false; + return IncompatibleThisProto(cx, "ArrayType.prototype.addressOfElement", + args.thisv()); } RootedObject typeObj(cx, CData::GetCType(obj)); if (CType::GetTypeCode(typeObj) != TYPE_array) { - JS_ReportError(cx, "not an ArrayType"); - return false; + return IncompatibleThisType(cx, "ArrayType.prototype.addressOfElement", + "non-ArrayType CData", args.thisv()); } if (args.length() != 1) { @@ -5397,10 +5795,11 @@ ArrayType::AddressOfElement(JSContext* cx, unsigned argc, Value* vp) // Convert the index to a size_t and bounds-check it. size_t index; size_t length = GetLength(typeObj); - if (!jsvalToSize(cx, args[0], false, &index) || - index >= length) { - JS_ReportError(cx, "invalid index"); - return false; + if (!jsvalToSize(cx, args[0], false, &index)) { + return InvalidIndexError(cx, args[0]); + } + if (index >= length) { + return InvalidIndexRangeError(cx, index, length); } // Manually set the pointer inside the object, so we skip the conversion step. @@ -5417,10 +5816,10 @@ ArrayType::AddressOfElement(JSContext* cx, unsigned argc, Value* vp) // For a struct field descriptor 'val' of the form { name : type }, extract // 'name' and 'type'. static JSFlatString* -ExtractStructField(JSContext* cx, Value val, MutableHandleObject typeObj) +ExtractStructField(JSContext* cx, HandleValue val, MutableHandleObject typeObj) { if (val.isPrimitive()) { - JS_ReportError(cx, "struct field descriptors require a valid name and type"); + FieldDescriptorNameTypeError(cx, val); return nullptr; } @@ -5431,13 +5830,13 @@ ExtractStructField(JSContext* cx, Value val, MutableHandleObject typeObj) // make sure we have one, and only one, property if (props.length() != 1) { - JS_ReportError(cx, "struct field descriptors must contain one property"); + FieldDescriptorCountError(cx, val, props.length()); return nullptr; } RootedId nameid(cx, props[0]); if (!JSID_IS_STRING(nameid)) { - JS_ReportError(cx, "struct field descriptors require a valid name and type"); + FieldDescriptorNameError(cx, nameid); return nullptr; } @@ -5446,7 +5845,7 @@ ExtractStructField(JSContext* cx, Value val, MutableHandleObject typeObj) return nullptr; if (propVal.isPrimitive() || !CType::IsCType(&propVal.toObject())) { - JS_ReportError(cx, "struct field descriptors require a valid name and type"); + FieldDescriptorTypeError(cx, propVal, nameid); return nullptr; } @@ -5456,7 +5855,7 @@ ExtractStructField(JSContext* cx, Value val, MutableHandleObject typeObj) typeObj.set(&propVal.toObject()); size_t size; if (!CType::GetSafeSize(typeObj, &size) || size == 0) { - JS_ReportError(cx, "struct field types must have defined and nonzero size"); + FieldDescriptorSizeError(cx, typeObj, nameid); return nullptr; } @@ -5540,20 +5939,6 @@ StructType::Create(JSContext* cx, unsigned argc, Value* vp) return true; } -static void -PostBarrierCallback(JSTracer* trc, JSString* key, void* data) -{ - typedef HashMap UnbarrieredFieldInfoHash; - - UnbarrieredFieldInfoHash* table = reinterpret_cast(data); - JSString* prior = key; - js::UnsafeTraceManuallyBarrieredEdge(trc, &key, "CType fieldName"); - table->rekeyIfMoved(JS_ASSERT_STRING_IS_FLAT(prior), JS_ASSERT_STRING_IS_FLAT(key)); -} - bool StructType::DefineInternal(JSContext* cx, JSObject* typeObj_, JSObject* fieldsObj_) { @@ -5606,8 +5991,7 @@ StructType::DefineInternal(JSContext* cx, JSObject* typeObj_, JSObject* fieldsOb // Make sure each field name is unique FieldInfoHash::AddPtr entryPtr = fields.lookupForAdd(name); if (entryPtr) { - JS_ReportError(cx, "struct fields must have unique names"); - return false; + return DuplicateFieldError(cx, name); } // Add the field to the StructType's 'prototype' property. @@ -5654,8 +6038,10 @@ StructType::DefineInternal(JSContext* cx, JSObject* typeObj_, JSObject* fieldsOb info.mType = fieldType; info.mIndex = i; info.mOffset = fieldOffset; - ASSERT_OK(fields.add(entryPtr, name, info)); - JS_StoreStringPostBarrierCallback(cx, PostBarrierCallback, name, fields.address()); + if (!fields.add(entryPtr, name, info)) { + JS_ReportOutOfMemory(cx); + return false; + } structSize = fieldOffset + fieldSize; @@ -5780,10 +6166,13 @@ StructType::Define(JSContext* cx, unsigned argc, Value* vp) RootedObject obj(cx, JS_THIS_OBJECT(cx, vp)); if (!obj) return false; - if (!CType::IsCType(obj) || - CType::GetTypeCode(obj) != TYPE_struct) { - JS_ReportError(cx, "not a StructType"); - return false; + if (!CType::IsCType(obj)) { + return IncompatibleThisProto(cx, "StructType.prototype.define", + args.thisv()); + } + if (CType::GetTypeCode(obj) != TYPE_struct) { + return IncompatibleThisType(cx, "StructType.prototype.define", + "non-StructType", args.thisv()); } if (CType::IsSizeDefined(obj)) { @@ -5824,8 +6213,7 @@ StructType::ConstructData(JSContext* cx, const CallArgs& args) { if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_struct) { - JS_ReportError(cx, "not a StructType"); - return false; + return IncompatibleCallee(cx, "StructType constructor", obj); } if (!CType::IsSizeDefined(obj)) { @@ -5920,11 +6308,7 @@ StructType::LookupField(JSContext* cx, JSObject* obj, JSFlatString* name) if (ptr) return &ptr->value(); - JSAutoByteString bytes(cx, name); - if (!bytes) - return nullptr; - - JS_ReportError(cx, "%s does not name a field", bytes.ptr()); + FieldMissingError(cx, obj, name); return nullptr; } @@ -6003,20 +6387,18 @@ StructType::FieldGetter(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (!args.thisv().isObject()) { - JS_ReportError(cx, "not a CData"); - return false; + return IncompatibleThisProto(cx, "StructType property getter", args.thisv()); } RootedObject obj(cx, &args.thisv().toObject()); if (!CData::IsCData(obj)) { - JS_ReportError(cx, "not a CData"); - return false; + return IncompatibleThisProto(cx, "StructType property getter", args.thisv()); } JSObject* typeObj = CData::GetCType(obj); if (CType::GetTypeCode(typeObj) != TYPE_struct) { - JS_ReportError(cx, "not a StructType"); - return false; + return IncompatibleThisType(cx, "StructType property getter", + "non-StructType CData", args.thisv()); } RootedValue nameVal(cx, GetFunctionNativeReserved(&args.callee(), SLOT_FIELDNAME)); @@ -6039,20 +6421,18 @@ StructType::FieldSetter(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (!args.thisv().isObject()) { - JS_ReportError(cx, "not a CData"); - return false; + return IncompatibleThisProto(cx, "StructType property setter", args.thisv()); } RootedObject obj(cx, &args.thisv().toObject()); if (!CData::IsCData(obj)) { - JS_ReportError(cx, "not a CData"); - return false; + return IncompatibleThisProto(cx, "StructType property setter", args.thisv()); } RootedObject typeObj(cx, CData::GetCType(obj)); if (CType::GetTypeCode(typeObj) != TYPE_struct) { - JS_ReportError(cx, "not a StructType"); - return false; + return IncompatibleThisType(cx, "StructType property setter", + "non-StructType CData", args.thisv()); } RootedValue nameVal(cx, GetFunctionNativeReserved(&args.callee(), SLOT_FIELDNAME)); @@ -6078,15 +6458,15 @@ StructType::AddressOfField(JSContext* cx, unsigned argc, Value* vp) RootedObject obj(cx, JS_THIS_OBJECT(cx, vp)); if (!obj) return false; - if (!CData::IsCData(obj)) { - JS_ReportError(cx, "not a CData"); - return false; + if (!CData::IsCData(obj)) { + return IncompatibleThisProto(cx, "StructType.prototype.addressOfField", + args.thisv()); } JSObject* typeObj = CData::GetCType(obj); if (CType::GetTypeCode(typeObj) != TYPE_struct) { - JS_ReportError(cx, "not a StructType"); - return false; + return IncompatibleThisType(cx, "StructType.prototype.addressOfField", + "non-StructType CData", args.thisv()); } if (args.length() != 1) { @@ -6185,10 +6565,10 @@ GetABI(JSContext* cx, Value abiType, ffi_abi* result) } static JSObject* -PrepareType(JSContext* cx, Value type) +PrepareType(JSContext* cx, uint32_t index, HandleValue type) { if (type.isPrimitive() || !CType::IsCType(type.toObjectOrNull())) { - JS_ReportError(cx, "not a ctypes type"); + FunctionArgumentTypeError(cx, index, type, "is not a ctypes type"); return nullptr; } @@ -6205,12 +6585,12 @@ PrepareType(JSContext* cx, Value type) } else if (typeCode == TYPE_void_t || typeCode == TYPE_function) { // disallow void or function argument types - JS_ReportError(cx, "Cannot have void or function argument type"); + FunctionArgumentTypeError(cx, index, type, "cannot be void or function"); return nullptr; } if (!CType::IsSizeDefined(result)) { - JS_ReportError(cx, "Argument type must have defined size"); + FunctionArgumentTypeError(cx, index, type, "must have defined size"); return nullptr; } @@ -6224,7 +6604,7 @@ static JSObject* PrepareReturnType(JSContext* cx, Value type) { if (type.isPrimitive() || !CType::IsCType(type.toObjectOrNull())) { - JS_ReportError(cx, "not a ctypes type"); + FunctionReturnTypeError(cx, type, "is not a ctypes type"); return nullptr; } @@ -6233,12 +6613,12 @@ PrepareReturnType(JSContext* cx, Value type) // Arrays and functions can never be return types. if (typeCode == TYPE_array || typeCode == TYPE_function) { - JS_ReportError(cx, "Return type cannot be an array or function"); + FunctionReturnTypeError(cx, type, "cannot be an array or function"); return nullptr; } if (typeCode != TYPE_void_t && !CType::IsSizeDefined(result)) { - JS_ReportError(cx, "Return type must have defined size"); + FunctionReturnTypeError(cx, type, "must have defined size"); return nullptr; } @@ -6406,7 +6786,7 @@ CreateFunctionInfo(JSContext* cx, break; } - JSObject* argType = PrepareType(cx, args[i]); + JSObject* argType = PrepareType(cx, i, args[i]); if (!argType) return false; @@ -6600,20 +6980,20 @@ FunctionType::Call(JSContext* cx, // get the callee object... RootedObject obj(cx, &args.callee()); if (!CData::IsCData(obj)) { - JS_ReportError(cx, "not a CData"); - return false; + return IncompatibleThisProto(cx, "FunctionType.prototype.call", + args.calleev()); } RootedObject typeObj(cx, CData::GetCType(obj)); if (CType::GetTypeCode(typeObj) != TYPE_pointer) { - JS_ReportError(cx, "not a FunctionType.ptr"); - return false; + return IncompatibleThisType(cx, "FunctionType.prototype.call", + "non-PointerType CData", args.calleev()); } typeObj = PointerType::GetBaseType(typeObj); if (CType::GetTypeCode(typeObj) != TYPE_function) { - JS_ReportError(cx, "not a FunctionType.ptr"); - return false; + return IncompatibleThisType(cx, "FunctionType.prototype.call", + "non-FunctionType pointer", args.calleev()); } FunctionInfo* fninfo = GetFunctionInfo(typeObj); @@ -6621,8 +7001,8 @@ FunctionType::Call(JSContext* cx, if ((!fninfo->mIsVariadic && args.length() != argcFixed) || (fninfo->mIsVariadic && args.length() < argcFixed)) { - JS_ReportError(cx, "Number of arguments does not match declaration"); - return false; + return FunctionArgumentLengthMismatch(cx, argcFixed, args.length(), + obj, typeObj, fninfo->mIsVariadic); } // Check if we have a Library object. If we do, make sure it's open. @@ -6662,17 +7042,25 @@ FunctionType::Call(JSContext* cx, !CData::IsCData(obj = &args[i].toObject())) { // Since we know nothing about the CTypes of the ... arguments, // they absolutely must be CData objects already. - JS_ReportError(cx, "argument %d of type %s is not a CData object", - i, InformalValueTypeName(args[i])); + return VariadicArgumentTypeError(cx, i, args[i]); + } + type = CData::GetCType(obj); + if (!type) { + // These functions report their own errors. return false; } - if (!(type = CData::GetCType(obj)) || - !(type = PrepareType(cx, ObjectValue(*type))) || - // Relying on ImplicitConvert only for the limited purpose of - // converting one CType to another (e.g., T[] to T*). - !ConvertArgument(cx, obj, i, args[i], type, &values[i], &strings) || - !(fninfo->mFFITypes[i] = CType::GetFFIType(cx, type))) { - // These functions report their own errors. + RootedValue typeVal(cx, ObjectValue(*type)); + type = PrepareType(cx, i, typeVal); + if (!type) { + return false; + } + // Relying on ImplicitConvert only for the limited purpose of + // converting one CType to another (e.g., T[] to T*). + if (!ConvertArgument(cx, obj, i, args[i], type, &values[i], &strings)) { + return false; + } + fninfo->mFFITypes[i] = CType::GetFFIType(cx, type); + if (!fninfo->mFFITypes[i]) { return false; } } @@ -7295,8 +7683,7 @@ CData::Address(JSContext* cx, unsigned argc, Value* vp) if (!obj) return false; if (!IsCData(obj)) { - JS_ReportError(cx, "not a CData"); - return false; + return IncompatibleThisProto(cx, "CData.prototype.address", args.thisv()); } RootedObject typeObj(cx, CData::GetCType(obj)); @@ -7329,7 +7716,7 @@ CData::Cast(JSContext* cx, unsigned argc, Value* vp) return ArgumentTypeMismatch(cx, "first ", "ctypes.cast", "a CData"); } RootedObject sourceData(cx, &args[0].toObject()); - JSObject* sourceType = CData::GetCType(sourceData); + RootedObject sourceType(cx, CData::GetCType(sourceData)); if (args[1].isPrimitive() || !CType::IsCType(&args[1].toObject())) { return ArgumentTypeMismatch(cx, "second ", "ctypes.cast", "a CType"); @@ -7337,11 +7724,12 @@ CData::Cast(JSContext* cx, unsigned argc, Value* vp) RootedObject targetType(cx, &args[1].toObject()); size_t targetSize; - if (!CType::GetSafeSize(targetType, &targetSize) || - targetSize > CType::GetSize(sourceType)) { - JS_ReportError(cx, - "target CType has undefined or larger size than source CType"); - return false; + if (!CType::GetSafeSize(targetType, &targetSize)) { + return UndefinedSizeCastError(cx, targetType); + } + if (targetSize > CType::GetSize(sourceType)) { + return SizeMismatchCastError(cx, sourceType, targetType, + CType::GetSize(sourceType), targetSize); } // Construct a new CData object with a type of 'targetType' and a referent @@ -7387,21 +7775,42 @@ CData::GetRuntime(JSContext* cx, unsigned argc, Value* vp) typedef JS::TwoByteCharsZ (*InflateUTF8Method)(JSContext*, const JS::UTF8Chars, size_t*); static bool -ReadStringCommon(JSContext* cx, InflateUTF8Method inflateUTF8, unsigned argc, Value* vp) +ReadStringCommon(JSContext* cx, InflateUTF8Method inflateUTF8, unsigned argc, + Value* vp, const char* funName) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() != 0) { - if (inflateUTF8 == JS::UTF8CharsToNewTwoByteCharsZ) { - return ArgumentLengthError(cx, "CData.prototype.readString", "no", "s"); - } - return ArgumentLengthError(cx, "CData.prototype.readStringReplaceMalformed", - "no", "s"); + return ArgumentLengthError(cx, funName, "no", "s"); } - JSObject* obj = CDataFinalizer::GetCData(cx, JS_THIS_OBJECT(cx, vp)); - if (!obj || !CData::IsCData(obj)) { - JS_ReportError(cx, "not a CData"); - return false; + RootedObject obj(cx, JS_THIS_OBJECT(cx, vp)); + if (!obj) { + return IncompatibleThisProto(cx, funName, args.thisv()); + } + if (!CData::IsCData(obj)) { + if (!CDataFinalizer::IsCDataFinalizer(obj)) { + return IncompatibleThisProto(cx, funName, args.thisv()); + } + + CDataFinalizer::Private* p = (CDataFinalizer::Private*) + JS_GetPrivate(obj); + if (!p) { + return EmptyFinalizerCallError(cx, funName); + } + + RootedValue dataVal(cx); + if (!CDataFinalizer::GetValue(cx, obj, &dataVal)) { + return IncompatibleThisProto(cx, funName, args.thisv()); + } + + if (dataVal.isPrimitive()) { + return IncompatibleThisProto(cx, funName, args.thisv()); + } + + obj = dataVal.toObjectOrNull(); + if (!obj || !CData::IsCData(obj)) { + return IncompatibleThisProto(cx, funName, args.thisv()); + } } // Make sure we are a pointer to, or an array of, an 8-bit or 16-bit @@ -7416,8 +7825,7 @@ ReadStringCommon(JSContext* cx, InflateUTF8Method inflateUTF8, unsigned argc, Va baseType = PointerType::GetBaseType(typeObj); data = *static_cast(CData::GetData(obj)); if (data == nullptr) { - JS_ReportError(cx, "cannot read contents of null pointer"); - return false; + return NullPointerError(cx, "read contents of", obj); } break; case TYPE_array: @@ -7426,8 +7834,7 @@ ReadStringCommon(JSContext* cx, InflateUTF8Method inflateUTF8, unsigned argc, Va maxLength = ArrayType::GetLength(typeObj); break; default: - JS_ReportError(cx, "not a PointerType or ArrayType"); - return false; + return TypeError(cx, "PointerType or ArrayType", args.thisv()); } // Convert the string buffer, taking care to determine the correct string @@ -7461,9 +7868,7 @@ ReadStringCommon(JSContext* cx, InflateUTF8Method inflateUTF8, unsigned argc, Va break; } default: - JS_ReportError(cx, - "base type is not an 8-bit or 16-bit integer or character type"); - return false; + return NonStringBaseError(cx, args.thisv()); } if (!result) @@ -7476,13 +7881,22 @@ ReadStringCommon(JSContext* cx, InflateUTF8Method inflateUTF8, unsigned argc, Va bool CData::ReadString(JSContext* cx, unsigned argc, Value* vp) { - return ReadStringCommon(cx, JS::UTF8CharsToNewTwoByteCharsZ, argc, vp); + return ReadStringCommon(cx, JS::UTF8CharsToNewTwoByteCharsZ, argc, vp, + "CData.prototype.readString"); +} + +bool +CDataFinalizer::Methods::ReadString(JSContext* cx, unsigned argc, Value* vp) +{ + return ReadStringCommon(cx, JS::UTF8CharsToNewTwoByteCharsZ, argc, vp, + "CDataFinalizer.prototype.readString"); } bool CData::ReadStringReplaceMalformed(JSContext* cx, unsigned argc, Value* vp) { - return ReadStringCommon(cx, JS::LossyUTF8CharsToNewTwoByteCharsZ, argc, vp); + return ReadStringCommon(cx, JS::LossyUTF8CharsToNewTwoByteCharsZ, argc, vp, + "CData.prototype.readStringReplaceMalformed"); } JSString* @@ -7517,8 +7931,8 @@ CData::ToSource(JSContext* cx, unsigned argc, Value* vp) if (!obj) return false; if (!CData::IsCData(obj) && !CData::IsCDataProto(obj)) { - JS_ReportError(cx, "not a CData"); - return false; + return IncompatibleThisProto(cx, "CData.prototype.toSource", + InformalValueTypeName(args.thisv())); } JSString* result; @@ -7562,8 +7976,8 @@ CDataFinalizer::Methods::ToSource(JSContext* cx, unsigned argc, Value* vp) if (!objThis) return false; if (!CDataFinalizer::IsCDataFinalizer(objThis)) { - JS_ReportError(cx, "not a CDataFinalizer"); - return false; + return IncompatibleThisProto(cx, "CDataFinalizer.prototype.toSource", + InformalValueTypeName(args.thisv())); } CDataFinalizer::Private* p = (CDataFinalizer::Private*) @@ -7621,8 +8035,8 @@ CDataFinalizer::Methods::ToString(JSContext* cx, unsigned argc, Value* vp) if (!objThis) return false; if (!CDataFinalizer::IsCDataFinalizer(objThis)) { - JS_ReportError(cx, "not a CDataFinalizer"); - return false; + return IncompatibleThisProto(cx, "CDataFinalizer.prototype.toString", + InformalValueTypeName(args.thisv())); } JSString* strMessage; @@ -7667,30 +8081,9 @@ CDataFinalizer::GetCType(JSContext* cx, JSObject* obj) return valData.toObjectOrNull(); } -JSObject* -CDataFinalizer::GetCData(JSContext* cx, JSObject* obj) -{ - if (!obj) { - JS_ReportError(cx, "No C data"); - return nullptr; - } - if (CData::IsCData(obj)) { - return obj; - } - if (!CDataFinalizer::IsCDataFinalizer(obj)) { - JS_ReportError(cx, "Not C data"); - return nullptr; - } - RootedValue val(cx); - if (!CDataFinalizer::GetValue(cx, obj, &val) || val.isPrimitive()) { - JS_ReportError(cx, "Empty CDataFinalizer"); - return nullptr; - } - return val.toObjectOrNull(); -} - bool -CDataFinalizer::GetValue(JSContext* cx, JSObject* obj, MutableHandleValue aResult) +CDataFinalizer::GetValue(JSContext* cx, JSObject* obj, + MutableHandleValue aResult) { MOZ_ASSERT(IsCDataFinalizer(obj)); @@ -7698,8 +8091,9 @@ CDataFinalizer::GetValue(JSContext* cx, JSObject* obj, MutableHandleValue aResul JS_GetPrivate(obj); if (!p) { + // We have called |dispose| or |forget| already. JS_ReportError(cx, "Attempting to get the value of an empty CDataFinalizer"); - return false; // We have called |dispose| or |forget| already. + return false; } RootedObject ctype(cx, GetCType(cx, obj)); @@ -7956,20 +8350,19 @@ CDataFinalizer::Methods::Forget(JSContext* cx, unsigned argc, Value* vp) "s"); } - JS::Rooted obj(cx, args.thisv().toObjectOrNull()); + RootedObject obj(cx, JS_THIS_OBJECT(cx, vp)); if (!obj) return false; if (!CDataFinalizer::IsCDataFinalizer(obj)) { - JS_ReportError(cx, "not a CDataFinalizer"); - return false; + return IncompatibleThisProto(cx, "CDataFinalizer.prototype.forget", + args.thisv()); } CDataFinalizer::Private* p = (CDataFinalizer::Private*) JS_GetPrivate(obj); if (!p) { - JS_ReportError(cx, "forget called on an empty CDataFinalizer"); - return false; + return EmptyFinalizerCallError(cx, "CDataFinalizer.prototype.forget"); } RootedValue valJSData(cx); @@ -8008,16 +8401,15 @@ CDataFinalizer::Methods::Dispose(JSContext* cx, unsigned argc, Value* vp) if (!obj) return false; if (!CDataFinalizer::IsCDataFinalizer(obj)) { - JS_ReportError(cx, "not a CDataFinalizer"); - return false; + return IncompatibleThisProto(cx, "CDataFinalizer.prototype.dispose", + args.thisv()); } CDataFinalizer::Private* p = (CDataFinalizer::Private*) JS_GetPrivate(obj); if (!p) { - JS_ReportError(cx, "dispose called on an empty CDataFinalizer."); - return false; + return EmptyFinalizerCallError(cx, "CDataFinalizer.prototype.dispose"); } Value valType = JS_GetReservedSlot(obj, SLOT_DATAFINALIZER_VALTYPE); @@ -8292,8 +8684,12 @@ Int64::ToString(JSContext* cx, unsigned argc, Value* vp) if (!obj) return false; if (!Int64::IsInt64(obj)) { - JS_ReportError(cx, "not an Int64"); - return false; + if (!CData::IsCData(obj)) { + return IncompatibleThisProto(cx, "Int64.prototype.toString", + InformalValueTypeName(args.thisv())); + } + return IncompatibleThisType(cx, "Int64.prototype.toString", + "non-Int64 CData"); } return Int64Base::ToString(cx, obj, args, false); @@ -8307,8 +8703,12 @@ Int64::ToSource(JSContext* cx, unsigned argc, Value* vp) if (!obj) return false; if (!Int64::IsInt64(obj)) { - JS_ReportError(cx, "not an Int64"); - return false; + if (!CData::IsCData(obj)) { + return IncompatibleThisProto(cx, "Int64.prototype.toSource", + InformalValueTypeName(args.thisv())); + } + return IncompatibleThisType(cx, "Int64.prototype.toSource", + "non-Int64 CData"); } return Int64Base::ToSource(cx, obj, args, false); @@ -8468,8 +8868,12 @@ UInt64::ToString(JSContext* cx, unsigned argc, Value* vp) if (!obj) return false; if (!UInt64::IsUInt64(obj)) { - JS_ReportError(cx, "not a UInt64"); - return false; + if (!CData::IsCData(obj)) { + return IncompatibleThisProto(cx, "UInt64.prototype.toString", + InformalValueTypeName(args.thisv())); + } + return IncompatibleThisType(cx, "UInt64.prototype.toString", + "non-UInt64 CData"); } return Int64Base::ToString(cx, obj, args, true); @@ -8483,8 +8887,12 @@ UInt64::ToSource(JSContext* cx, unsigned argc, Value* vp) if (!obj) return false; if (!UInt64::IsUInt64(obj)) { - JS_ReportError(cx, "not a UInt64"); - return false; + if (!CData::IsCData(obj)) { + return IncompatibleThisProto(cx, "UInt64.prototype.toSource", + InformalValueTypeName(args.thisv())); + } + return IncompatibleThisType(cx, "UInt64.prototype.toSource", + "non-UInt64 CData"); } return Int64Base::ToSource(cx, obj, args, true); diff --git a/js/src/ctypes/CTypes.h b/js/src/ctypes/CTypes.h index 3e98015f78..6e44fa6f03 100644 --- a/js/src/ctypes/CTypes.h +++ b/js/src/ctypes/CTypes.h @@ -280,10 +280,8 @@ struct FieldHashPolicy : DefaultHasher } }; -using FieldInfoHash = GCHashMap; - -void -TraceFieldInfoHash(JSTracer* trc, FieldInfoHash* fields); +using FieldInfoHash = GCHashMap, + FieldInfo, FieldHashPolicy, SystemAllocPolicy>; // Descriptor of ABI, return type, argument types, and variadicity for a // FunctionType. diff --git a/js/src/ctypes/ctypes.msg b/js/src/ctypes/ctypes.msg index 11bf8d4303..f455f2166f 100644 --- a/js/src/ctypes/ctypes.msg +++ b/js/src/ctypes/ctypes.msg @@ -24,20 +24,53 @@ MSG_DEF(CTYPESMSG_TYPE_ERROR, 2, JSEXN_TYPEERR, "expected {0}, got {1}") /* array */ MSG_DEF(CTYPESMSG_ARRAY_MISMATCH,4, JSEXN_TYPEERR, "length of {0} does not match to the length of the type {1} (expected {2}, got {3})") MSG_DEF(CTYPESMSG_ARRAY_OVERFLOW,4, JSEXN_TYPEERR, "length of {0} does not fit in the length of the type {1} (expected {2} or lower, got {3})") +MSG_DEF(CTYPESMSG_INVALID_INDEX, 1, JSEXN_TYPEERR, "{0} is not a valid array index") +MSG_DEF(CTYPESMSG_INVALID_RANGE, 2, JSEXN_RANGEERR, "array index {0} is out of bounds for array of length {1}") /* struct */ +MSG_DEF(CTYPESMSG_DUPLICATE_FIELD, 1, JSEXN_TYPEERR, "struct fields must have unique names, '{0}' field appears twice") +MSG_DEF(CTYPESMSG_FIELD_DESC_COUNT,2, JSEXN_TYPEERR, "struct field descriptors must contain one property (got {0} with {1} properties)") +MSG_DEF(CTYPESMSG_FIELD_DESC_NAME,1, JSEXN_TYPEERR, "{0} is not a valid name of struct field descriptors") +MSG_DEF(CTYPESMSG_FIELD_DESC_SIZE,2, JSEXN_TYPEERR, "struct field type must have defined and nonzero size (got {0} for '{1}' field)") +MSG_DEF(CTYPESMSG_FIELD_DESC_NAMETYPE,1, JSEXN_TYPEERR, "struct field descriptors require a valid name and type (got {0})") +MSG_DEF(CTYPESMSG_FIELD_DESC_TYPE,2, JSEXN_TYPEERR, "{0} is not a valid type of struct field descriptors for '{1}' field") MSG_DEF(CTYPESMSG_FIELD_MISMATCH,5, JSEXN_TYPEERR, "property count of {0} does not match to field count of the type {1} (expected {2}, got {3}){4}") +MSG_DEF(CTYPESMSG_FIELD_MISSING, 2, JSEXN_TYPEERR, "{0} does not have a field named '{1}'") MSG_DEF(CTYPESMSG_PROP_NONSTRING,3, JSEXN_TYPEERR, "property name {0} of {1} is not a string{2}") /* data finalizer */ MSG_DEF(CTYPESMSG_EMPTY_FIN, 1, JSEXN_TYPEERR, "attempting to convert an empty CDataFinalizer{0}") +MSG_DEF(CTYPESMSG_EMPTY_FIN_CALL,1, JSEXN_TYPEERR, "{0} called on empty CDataFinalizer") MSG_DEF(CTYPESMSG_FIN_SIZE_ERROR,2, JSEXN_TYPEERR, "expected an object with the same size as argument 1 of {0}, got {1}") /* native function */ MSG_DEF(CTYPESMSG_ARG_RANGE_MISMATCH,3, JSEXN_RANGEERR, "{0}argument of {1} must be {2}") MSG_DEF(CTYPESMSG_ARG_TYPE_MISMATCH,3, JSEXN_TYPEERR, "{0}argument of {1} must be {2}") +MSG_DEF(CTYPESMSG_INCOMPATIBLE_CALLEE,2, JSEXN_TYPEERR, "callee is not correct in {0}, got {1}") +MSG_DEF(CTYPESMSG_INCOMPATIBLE_THIS,2, JSEXN_TYPEERR, "{0} called on incompatible {1}") +MSG_DEF(CTYPESMSG_INCOMPATIBLE_THIS_TYPE,2, JSEXN_TYPEERR, "{0} called on {1}") +MSG_DEF(CTYPESMSG_INCOMPATIBLE_THIS_VAL,3, JSEXN_TYPEERR, "{0} called on {1}, got {2}") MSG_DEF(CTYPESMSG_WRONG_ARG_LENGTH,3, JSEXN_TYPEERR, "{0} takes {1} argument{2}") /* overflow */ MSG_DEF(CTYPESMSG_SIZE_OVERFLOW, 2, JSEXN_RANGEERR, "{0} does not fit in {1}") MSG_DEF(CTYPESMSG_TYPE_OVERFLOW, 2, JSEXN_RANGEERR, "{0} does not fit in the type {1}") + +/* function */ +MSG_DEF(CTYPESMSG_ARG_COUNT_MISMATCH,4, JSEXN_RANGEERR, "number of arguments does not match declaration of {0} (expected {1}{2}, got {3})") +MSG_DEF(CTYPESMSG_ARG_TYPE_ERROR,3, JSEXN_TYPEERR, "the type of argument {0} {1} (got {2})") +MSG_DEF(CTYPESMSG_FUNCTION_CONSTRUCT,0, JSEXN_TYPEERR, "cannot construct from FunctionType; use FunctionType.ptr instead") +MSG_DEF(CTYPESMSG_RET_TYPE_ERROR,2, JSEXN_TYPEERR, "return type {0} (got {1})") +MSG_DEF(CTYPESMSG_VARG_TYPE_ERROR,2, JSEXN_TYPEERR, "variadic argument {0} must be a CData object (got {1})") + +/* ctype */ +MSG_DEF(CTYPESMSG_CANNOT_CONSTRUCT,1, JSEXN_TYPEERR, "cannot construct from {0}") + +/* pointer */ +MSG_DEF(CTYPESMSG_UNDEFINED_SIZE,2, JSEXN_TYPEERR, "cannot {0} pointer of undefined size {1}") +MSG_DEF(CTYPESMSG_NULL_POINTER, 2, JSEXN_TYPEERR, "cannot {0} null pointer {1}") +MSG_DEF(CTYPESMSG_NON_STRING_BASE,1, JSEXN_TYPEERR, "base type {0} is not an 8-bit or 16-bit integer or character type") + +/* cast */ +MSG_DEF(CTYPESMSG_UNDEFINED_SIZE_CAST,1, JSEXN_TYPEERR, "target type {0} has undefined size") +MSG_DEF(CTYPESMSG_SIZE_MISMATCH_CAST,4, JSEXN_TYPEERR, "target type {0} has larger size than source type {1} ({2} > {3})") diff --git a/js/src/ctypes/libffi/configure b/js/src/ctypes/libffi/configure index f3372f417d..9f8c208c8f 100755 --- a/js/src/ctypes/libffi/configure +++ b/js/src/ctypes/libffi/configure @@ -16690,10 +16690,10 @@ fi echo "********************************************************" echo "* WARNING: Don't know the best CFLAGS for this system *" echo "* Use ./configure CFLAGS=... to specify your own flags *" - echo "* (otherwise, a default of CFLAGS=-O2 will be used) *" + echo "* (otherwise, a default of CFLAGS=-O3 will be used) *" echo "********************************************************" echo "" - CFLAGS="-O2" + CFLAGS="-O3" fi as_CACHEVAR=`$as_echo "ax_cv_check_cflags__$CFLAGS" | $as_tr_sh` diff --git a/js/src/ctypes/libffi/msvcc.sh b/js/src/ctypes/libffi/msvcc.sh index 65fbfef7e3..1621e5f0e8 100755 --- a/js/src/ctypes/libffi/msvcc.sh +++ b/js/src/ctypes/libffi/msvcc.sh @@ -70,7 +70,6 @@ do ;; -clang-cl) cl="clang-cl" - safeseh= shift 1 ;; -O0) diff --git a/js/src/devtools/automation/variants/arm-sim b/js/src/devtools/automation/variants/arm-sim index 42e7915504..26dcaeb589 100644 --- a/js/src/devtools/automation/variants/arm-sim +++ b/js/src/devtools/automation/variants/arm-sim @@ -1,7 +1,6 @@ --enable-optimize --enable-debug --enable-stdcxx-compat ---disable-shared-js --enable-simulator=arm --target=i686-pc-linux --host=i686-pc-linux diff --git a/js/src/devtools/automation/variants/arm-sim-osx b/js/src/devtools/automation/variants/arm-sim-osx index 3063d8bdfc..f24aa3ad5b 100644 --- a/js/src/devtools/automation/variants/arm-sim-osx +++ b/js/src/devtools/automation/variants/arm-sim-osx @@ -1,7 +1,6 @@ --enable-optimize --enable-debug --enable-stdcxx-compat ---disable-shared-js --enable-simulator=arm --target=i686-apple-darwin10.0.0 --host=i686-apple-darwin10.0.0 diff --git a/js/src/devtools/automation/variants/arm64-sim b/js/src/devtools/automation/variants/arm64-sim index 28928707e4..f946b2228f 100644 --- a/js/src/devtools/automation/variants/arm64-sim +++ b/js/src/devtools/automation/variants/arm64-sim @@ -1,5 +1,4 @@ --enable-optimize --enable-debug --enable-stdcxx-compat ---disable-shared-js --enable-simulator=arm64 diff --git a/js/src/devtools/automation/variants/compacting b/js/src/devtools/automation/variants/compacting index 3504e523fc..2ffdd31ab5 100644 --- a/js/src/devtools/automation/variants/compacting +++ b/js/src/devtools/automation/variants/compacting @@ -2,4 +2,3 @@ --enable-debug --enable-stdcxx-compat --enable-ctypes ---disable-shared-js diff --git a/js/src/devtools/automation/variants/dtrace b/js/src/devtools/automation/variants/dtrace index 2c601a4ca7..281b6412a5 100644 --- a/js/src/devtools/automation/variants/dtrace +++ b/js/src/devtools/automation/variants/dtrace @@ -1,4 +1,3 @@ ---enable-threadsafe --enable-optimize --enable-debug --enable-dtrace diff --git a/js/src/devtools/automation/variants/exactrooting b/js/src/devtools/automation/variants/exactrooting deleted file mode 100644 index dd4fd88f80..0000000000 --- a/js/src/devtools/automation/variants/exactrooting +++ /dev/null @@ -1,3 +0,0 @@ ---enable-optimize ---enable-debug ---enable-exact-rooting diff --git a/js/src/devtools/automation/variants/generational b/js/src/devtools/automation/variants/generational index 36187614bc..2ffdd31ab5 100644 --- a/js/src/devtools/automation/variants/generational +++ b/js/src/devtools/automation/variants/generational @@ -2,7 +2,3 @@ --enable-debug --enable-stdcxx-compat --enable-ctypes ---disable-shared-js ---enable-exact-rooting ---enable-gccompacting ---enable-threadsafe diff --git a/js/src/devtools/automation/variants/nomethodjit b/js/src/devtools/automation/variants/nomethodjit deleted file mode 100644 index d79e788968..0000000000 --- a/js/src/devtools/automation/variants/nomethodjit +++ /dev/null @@ -1,4 +0,0 @@ ---enable-threadsafe ---enable-optimize ---enable-debug ---disable-methodjit diff --git a/js/src/devtools/automation/variants/rootanalysis b/js/src/devtools/automation/variants/rootanalysis index 36ad6771ac..2ffdd31ab5 100644 --- a/js/src/devtools/automation/variants/rootanalysis +++ b/js/src/devtools/automation/variants/rootanalysis @@ -2,7 +2,3 @@ --enable-debug --enable-stdcxx-compat --enable-ctypes ---disable-shared-js ---enable-exact-rooting ---enable-gcgenerational ---enable-threadsafe diff --git a/js/src/devtools/automation/variants/warnaserr b/js/src/devtools/automation/variants/warnaserr index a74c31b332..b212363675 100644 --- a/js/src/devtools/automation/variants/warnaserr +++ b/js/src/devtools/automation/variants/warnaserr @@ -1,4 +1,3 @@ ---enable-threadsafe --enable-optimize --enable-warnings-as-errors diff --git a/js/src/devtools/automation/variants/warnaserrdebug b/js/src/devtools/automation/variants/warnaserrdebug index b9149b8074..02947f7606 100644 --- a/js/src/devtools/automation/variants/warnaserrdebug +++ b/js/src/devtools/automation/variants/warnaserrdebug @@ -1,3 +1,2 @@ ---enable-threadsafe --enable-debug --enable-warnings-as-errors diff --git a/js/src/jit-test/manual-tests/TypedObject-TypeDescrIsArrayType-unknown.js b/js/src/jit-test/manual-tests/TypedObject-TypeDescrIsArrayType-unknown.js new file mode 100644 index 0000000000..17de9af69c --- /dev/null +++ b/js/src/jit-test/manual-tests/TypedObject-TypeDescrIsArrayType-unknown.js @@ -0,0 +1,77 @@ +/* -*- tab-width: 8; indent-tabs-mode: nil; js-indent-level: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Susceptible to timeouts on some systems, see bug 1203595, if run + * with --ion-eager --ion-offthread-compile=off. + * + * Probably only meaningful to run this with default flags. + */ + +/* This test is intended to test Ion code generation for the internal + * primitive TypeDescrIsArrayType(), available to self-hosted code. + * + * This test differs from the one in TypedObject-TypeDescrIsArrayType.js + * in that it tries to hide type information from the JIT. Sadly, + * it turns out to be hard to write a test that causes a run-time test + * to be inserted at the right spot. This is my best effort, + * but the test was still specialized as "true" in the generated code + * last I looked. + * + * To do that, it must trigger enough uses of that primitive as well + * as enough uses of a caller of the primitive to trigger inlining of + * the primitive into its compiled caller. + * + * It turns out that TypeDescrIsArrayType() is used early in the map() + * method on TypedObject arrays, so code that heavily uses the latter + * method will usually be good enough. + * + * In practice this test just asserts that map() works, and thus that + * the code for TypeDescrIsArrayType() is at least not completely + * broken. + * + * The test is only meaningful if inlining actually happens. Here is + * how to verify that (manually): + * + * Run this with IONFLAGS=logs, generate pdfs with iongraph, and then + * try running "pdfgrep TypeDescrIsArrayType func*pass00*.pdf", this + * might net a function that is a likely candidate for manual inspection. + * + * (It is sometimes useful to comment out the assert() macro in the + * self-hosted code.) + */ + +if (!this.TypedObject) { + print("No TypedObject, skipping"); + quit(); +} + +var T = TypedObject; +var AT = new T.ArrayType(T.int32, 100); + +function check(v) { + return v.map(x => x+1); +} + +function Array_build(n, f) { + var a = new Array(n); + for ( var i=0 ; i < n ; i++ ) + a[i] = f(i); + return a; +} + +function test() { + var w1 = AT.build(x => x+1); + var w2 = Array_build(100, x => x+1); + w2.map = w1.map; + var a = [ w1, w2 ]; + for ( var i=0 ; i < 2000 ; i++ ) + try { a[i%2] = check(a[i%2]); } catch (e) { assertEq( i%2, 1 ); } + return a[0]; +} + +var w = test(); +assertEq(w.length, 100); +assertEq(w[99], 1100); +print("Done"); diff --git a/js/src/jit-test/manual-tests/TypedObject-TypeDescrIsArrayType.js b/js/src/jit-test/manual-tests/TypedObject-TypeDescrIsArrayType.js new file mode 100644 index 0000000000..5600da1c9f --- /dev/null +++ b/js/src/jit-test/manual-tests/TypedObject-TypeDescrIsArrayType.js @@ -0,0 +1,62 @@ +/* -*- tab-width: 8; indent-tabs-mode: nil; js-indent-level: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Susceptible to timeouts on some systems, see bug 1203595, if run + * with --ion-eager --ion-offthread-compile=off. + * + * Probably only meaningful to run this with default flags. + */ + +/* This test is intended to test Ion code generation for the internal + * primitive TypeDescrIsArrayType(), available to self-hosted code. + * + * To do that, it must trigger enough uses of that primitive as well + * as enough uses of a caller of the primitive to trigger inlining of + * the primitive into its compiled caller. + * + * It turns out that TypeDescrIsArrayType() is used early in the map() + * method on TypedObject arrays, so code that heavily uses the latter + * method will usually be good enough. + * + * In practice this test just asserts that map() works, and thus that + * the code for TypeDescrIsArrayType() is at least not completely + * broken. + * + * The test is only meaningful if inlining actually happens. Here is + * how to verify that (manually): + * + * Run this test with IONFLAGS=logs, generate pdfs with iongraph, and + * then try running "pdfgrep TypeDescrIsArrayType func*pass00*.pdf", + * this might net a function that is a likely candidate for further + * manual inspection. + * + * (It is sometimes useful to comment out the assert() macro in the + * self-hosted code.) + */ + +if (!this.TypedObject) { + print("No TypedObject, skipping"); + quit(); +} + +var T = TypedObject; +var AT = new T.ArrayType(T.int32, 100); + +function check(v) { + return v.map(x => x+1); +} + +function test() { + var w = new AT(); + for ( var i=0 ; i < 1000 ; i++ ) + w = check(w); + return w; +} + +var w = test(); +assertEq(w.length, 100); +assertEq(w[99], 1000); +print("Done"); + diff --git a/js/src/jit-test/tests/TypedObject/aggregate-set-neutered.js b/js/src/jit-test/tests/TypedObject/aggregate-set-neutered.js index 3e9697202d..b17abe7f6c 100644 --- a/js/src/jit-test/tests/TypedObject/aggregate-set-neutered.js +++ b/js/src/jit-test/tests/TypedObject/aggregate-set-neutered.js @@ -1,5 +1,5 @@ // Bug 991981. Check for various quirks when setting a field of a typed object -// during which set operation the underlying buffer is neutered. +// during which set operation the underlying buffer is detached. if (typeof TypedObject === "undefined") quit(); @@ -19,8 +19,9 @@ function main(variant) assertThrowsInstanceOf(function() { - line.to = { x: 22, get y() { neuter(buf, variant); return 44; } }; - }, TypeError, "setting into a neutered buffer is bad mojo"); + line.to = { x: 22, + get y() { detachArrayBuffer(buf, variant); return 44; } }; + }, TypeError, "setting into a detached buffer is bad mojo"); } main("same-data"); diff --git a/js/src/jit-test/tests/TypedObject/atopneuteredbuffer.js b/js/src/jit-test/tests/TypedObject/atopneuteredbuffer.js index b1221163f9..5d9257de4b 100644 --- a/js/src/jit-test/tests/TypedObject/atopneuteredbuffer.js +++ b/js/src/jit-test/tests/TypedObject/atopneuteredbuffer.js @@ -1,5 +1,5 @@ // Bug 976697. Check for various quirks when instantiating a typed -// object atop an already neutered buffer. +// object atop a detached buffer. if (typeof TypedObject === "undefined") quit(); @@ -13,11 +13,11 @@ function main(variant) { // once a C programmer, always a C programmer. var Unit = new StructType({}); // Empty struct type var buffer = new ArrayBuffer(0); // Empty buffer var p = new Unit(buffer); // OK - neuter(buffer, variant); + detachArrayBuffer(buffer, variant); assertThrowsInstanceOf(() => new Unit(buffer), TypeError, - "Able to instantiate atop neutered buffer"); + "Able to instantiate atop detached buffer"); assertThrowsInstanceOf(() => new Uints(buffer), TypeError, - "Able to instantiate atop neutered buffer"); + "Able to instantiate atop detached buffer"); } main("same-data"); diff --git a/js/src/jit-test/tests/TypedObject/bug1082649.js b/js/src/jit-test/tests/TypedObject/bug1082649.js index dbaf946c28..a999cb90d4 100644 --- a/js/src/jit-test/tests/TypedObject/bug1082649.js +++ b/js/src/jit-test/tests/TypedObject/bug1082649.js @@ -5,7 +5,7 @@ var {StructType, uint32, storage} = TypedObject; var S = new StructType({f: uint32, g: uint32}); function main(variant) { var s = new S({f: 22, g: 44}); - neuter(storage(s).buffer, variant); + detachArrayBuffer(storage(s).buffer, variant); print(storage(s).byteOffset); } try { diff --git a/js/src/jit-test/tests/TypedObject/neutertypedobj.js b/js/src/jit-test/tests/TypedObject/neutertypedobj.js index 0d8f5e0563..9eac882922 100644 --- a/js/src/jit-test/tests/TypedObject/neutertypedobj.js +++ b/js/src/jit-test/tests/TypedObject/neutertypedobj.js @@ -14,7 +14,7 @@ function main(variant) { for (var i = 0; i < 10; i++) assertEq(readFromS(s), 66); - neuter(storage(s).buffer, variant); + detachArrayBuffer(storage(s).buffer, variant); for (var i = 0; i < 10; i++) { var ok = false; diff --git a/js/src/jit-test/tests/TypedObject/neutertypedobjsizedarray.js b/js/src/jit-test/tests/TypedObject/neutertypedobjsizedarray.js index 5f90c759ea..0af86ceb45 100644 --- a/js/src/jit-test/tests/TypedObject/neutertypedobjsizedarray.js +++ b/js/src/jit-test/tests/TypedObject/neutertypedobjsizedarray.js @@ -1,6 +1,6 @@ -// Test the case where we neuter an instance of a fixed-sized array. +// Test the case where we detach the buffer underlying a fixed-sized array. // This is a bit of a tricky case because we cannot (necessarily) fold -// the neuter check into the bounds check, as we obtain the bounds +// the detached check into the bounds check, as we obtain the bounds // directly from the type. if (!this.hasOwnProperty("TypedObject")) @@ -22,7 +22,7 @@ function main(variant) { for (var i = 0; i < 10; i++) assertEq(readFrom(a), 66); - neuter(storage(a).buffer, variant); + detachArrayBuffer(storage(a).buffer, variant); for (var i = 0; i < 10; i++) { var ok = false; diff --git a/js/src/jit-test/tests/TypedObject/neutertypedobjunsizedarray.js b/js/src/jit-test/tests/TypedObject/neutertypedobjunsizedarray.js index 480073e7ef..14894b5ae2 100644 --- a/js/src/jit-test/tests/TypedObject/neutertypedobjunsizedarray.js +++ b/js/src/jit-test/tests/TypedObject/neutertypedobjunsizedarray.js @@ -1,5 +1,5 @@ -// Test the case where we neuter an instance of a variable-length array. -// Here we can fold the neuter check into the bounds check. +// Test the case where we detach the buffer underlying a variable-length array. +// Here we can fold the detached check into the bounds check. if (!this.hasOwnProperty("TypedObject")) quit(); @@ -20,7 +20,7 @@ function main(variant) { for (var i = 0; i < 10; i++) assertEq(readFrom(a), 66); - neuter(storage(a).buffer, variant); + detachArrayBuffer(storage(a).buffer, variant); for (var i = 0; i < 10; i++) { var ok = false; diff --git a/js/src/jit-test/tests/asm.js/neuter-during-arguments-coercion.js b/js/src/jit-test/tests/asm.js/neuter-during-arguments-coercion.js index 122cff61f4..c088668c5a 100644 --- a/js/src/jit-test/tests/asm.js/neuter-during-arguments-coercion.js +++ b/js/src/jit-test/tests/asm.js/neuter-during-arguments-coercion.js @@ -23,6 +23,6 @@ if (isAsmJSCompilationAvailable()) try { - set({ valueOf: function() { neuter(buffer, "same-data"); return 17; } }); + set({ valueOf() { detachArrayBuffer(buffer, "same-data"); return 17; } }); } catch (e) { /* if an exception thrown, swallow */ } diff --git a/js/src/jit-test/tests/asm.js/testCloning.js b/js/src/jit-test/tests/asm.js/testCloning.js index 494acbe455..b8b7f7f9c5 100644 --- a/js/src/jit-test/tests/asm.js/testCloning.js +++ b/js/src/jit-test/tests/asm.js/testCloning.js @@ -1,10 +1,16 @@ // |jit-test| test-also-noasmjs load(libdir + "asm.js"); +setCachingEnabled(true); + var code = asmCompile(USE_ASM + "function g() { return 42 } return g"); assertEq(asmLink(code)(), 42); assertEq(asmLink(code)(), 42); +var code = evaluate("(function() { " + USE_ASM + " function g() { return 43 } return g})", {fileName: null}); +assertEq(asmLink(code)(), 43); +assertEq(asmLink(code)(), 43); + var code = asmCompile('glob', 'ffis', 'buf', USE_ASM + 'var i32=new glob.Int32Array(buf); function g() { return i32[0]|0 } return g'); var i32_1 = new Int32Array(BUF_MIN/4); i32_1[0] = 42; diff --git a/js/src/jit-test/tests/asm.js/testNeuter.js b/js/src/jit-test/tests/asm.js/testNeuter.js index 4000adab71..ecd85b03de 100644 --- a/js/src/jit-test/tests/asm.js/testNeuter.js +++ b/js/src/jit-test/tests/asm.js/testNeuter.js @@ -23,8 +23,10 @@ var buffer = new ArrayBuffer(BUF_MIN); var {get, set} = asmLink(m, this, null, buffer); set(4, 42); assertEq(get(4), 42); -assertThrowsInstanceOf(() => neuter(buffer, "change-data"), InternalError); -assertThrowsInstanceOf(() => neuter(buffer, "same-data"), InternalError); +assertThrowsInstanceOf(() => detachArrayBuffer(buffer, "change-data"), + InternalError); +assertThrowsInstanceOf(() => detachArrayBuffer(buffer, "same-data"), + InternalError); var m = asmCompile('stdlib', 'foreign', 'buffer', `"use asm"; @@ -38,5 +40,10 @@ var m = asmCompile('stdlib', 'foreign', 'buffer', return inner`); var buffer = new ArrayBuffer(BUF_MIN); -function ffi1() { assertThrowsInstanceOf(() => neuter(buffer, "change-data"), InternalError) } -var inner = asmLink(m, this, {ffi:ffi1}, buffer); +function ffi1() +{ + assertThrowsInstanceOf(() => detachArrayBuffer(buffer, "change-data"), + InternalError); +} + +var inner = asmLink(m, this, {ffi: ffi1}, buffer); diff --git a/js/src/jit-test/tests/basic/testNeutering.js b/js/src/jit-test/tests/basic/testNeutering.js index 446fc13eda..c5c16af0aa 100644 --- a/js/src/jit-test/tests/basic/testNeutering.js +++ b/js/src/jit-test/tests/basic/testNeutering.js @@ -2,7 +2,7 @@ for (var variant of ["same-data", "change-data"]) { var ab = new ArrayBuffer(4); var i32 = new Int32Array(ab); i32[0] = 42; - neuter(ab, variant); + detachArrayBuffer(ab, variant); assertEq(i32.length, 0); assertEq(ab.byteLength, 0); assertEq(i32[0], undefined); @@ -10,7 +10,7 @@ for (var variant of ["same-data", "change-data"]) { var ab = new ArrayBuffer(12); var i32 = new Int32Array(ab); i32[0] = 42; - neuter(ab, variant); + detachArrayBuffer(ab, variant); assertEq(i32.length, 0); assertEq(ab.byteLength, 0); assertEq(i32[0], undefined); @@ -18,7 +18,7 @@ for (var variant of ["same-data", "change-data"]) { var ab = new ArrayBuffer(4096); var i32 = new Int32Array(ab); i32[0] = 42; - neuter(ab, variant); + detachArrayBuffer(ab, variant); assertEq(i32.length, 0); assertEq(ab.byteLength, 0); assertEq(i32[0], undefined); diff --git a/js/src/jit-test/tests/basic/typed-array-copyWithin.js b/js/src/jit-test/tests/basic/typed-array-copyWithin.js index 1449ca1ae0..e6462dd405 100644 --- a/js/src/jit-test/tests/basic/typed-array-copyWithin.js +++ b/js/src/jit-test/tests/basic/typed-array-copyWithin.js @@ -172,26 +172,29 @@ for (var constructor of constructors) { assertEq(e, 42, "should have failed converting target to index"); } - function neuterAndConvertTo(x) { - return { valueOf() { neuter(tarray.buffer, "change-data"); return x; } }; + function detachAndConvertTo(x) { + return { valueOf() { + detachArrayBuffer(tarray.buffer, "change-data"); + return x; + } }; } - // Neutering during argument processing triggers a TypeError. + // Detaching during argument processing triggers a TypeError. tarray = new constructor([1, 2, 3, 4, 5]); try { - tarray.copyWithin(0, 3, neuterAndConvertTo(4)); + tarray.copyWithin(0, 3, detachAndConvertTo(4)); throw new Error("expected to throw"); } catch (e) { assertEq(e instanceof TypeError, true, - "expected throw with neutered array during set"); + "expected throw with detached buffer during set"); } // ...unless no elements are to be copied. tarray = new constructor([1, 2, 3, 4, 5]); - assertDeepEq(tarray.copyWithin(0, 3, neuterAndConvertTo(3)), + assertDeepEq(tarray.copyWithin(0, 3, detachAndConvertTo(3)), new constructor([])); /* // fails, unclear whether it should, disabling for now diff --git a/js/src/jit-test/tests/ctypes/array-index.js b/js/src/jit-test/tests/ctypes/array-index.js new file mode 100644 index 0000000000..e70add1a06 --- /dev/null +++ b/js/src/jit-test/tests/ctypes/array-index.js @@ -0,0 +1,29 @@ +load(libdir + 'asserts.js'); + +function test() { + let a = ctypes.int32_t.array(10)(); + assertTypeErrorMessage(() => { let x = a[-1]; }, + "the string \"-1\" is not a valid array index"); + assertTypeErrorMessage(() => { a[-1] = 1; }, + "the string \"-1\" is not a valid array index"); + assertTypeErrorMessage(() => { a.addressOfElement(-1); }, + "the number -1 is not a valid array index"); + + assertRangeErrorMessage(() => { let x = a[10]; }, + "array index 10 is out of bounds for array of length 10"); + assertRangeErrorMessage(() => { a[10] = 1; }, + "array index 10 is out of bounds for array of length 10"); + assertRangeErrorMessage(() => { a.addressOfElement(10); }, + "array index 10 is out of bounds for array of length 10"); + + let obj = { + toSource() { + throw 1; + } + }; + assertTypeErrorMessage(() => { a.addressOfElement(obj); }, + "<> is not a valid array index"); +} + +if (typeof ctypes === "object") + test(); diff --git a/js/src/jit-test/tests/ctypes/cast.js b/js/src/jit-test/tests/ctypes/cast.js new file mode 100644 index 0000000000..c483d3793f --- /dev/null +++ b/js/src/jit-test/tests/ctypes/cast.js @@ -0,0 +1,12 @@ +load(libdir + 'asserts.js'); + +function test() { + assertTypeErrorMessage(() => { ctypes.cast(ctypes.int32_t(0), ctypes.StructType("foo")); }, + "target type foo has undefined size"); + + assertTypeErrorMessage(() => { ctypes.cast(ctypes.int32_t(0), ctypes.StructType("foo", [ { x: ctypes.int32_t }, { y: ctypes.int32_t } ])); }, + "target type foo has larger size than source type ctypes.int32_t (8 > 4)"); +} + +if (typeof ctypes === "object") + test(); diff --git a/js/src/jit-test/tests/ctypes/construct.js b/js/src/jit-test/tests/ctypes/construct.js new file mode 100644 index 0000000000..cfabdf24dc --- /dev/null +++ b/js/src/jit-test/tests/ctypes/construct.js @@ -0,0 +1,11 @@ +load(libdir + 'asserts.js'); + +function test() { + assertTypeErrorMessage(() => { ctypes.void_t(); }, + "cannot construct from void_t"); + assertTypeErrorMessage(() => { ctypes.CType(); }, + "cannot construct from abstract type"); +} + +if (typeof ctypes === "object") + test(); diff --git a/js/src/jit-test/tests/ctypes/function-definition.js b/js/src/jit-test/tests/ctypes/function-definition.js new file mode 100644 index 0000000000..4df317a09d --- /dev/null +++ b/js/src/jit-test/tests/ctypes/function-definition.js @@ -0,0 +1,47 @@ +load(libdir + 'asserts.js'); + +function test() { + assertRangeErrorMessage(() => { ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t, []).ptr(x=>1)(1); }, + "number of arguments does not match declaration of ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t) (expected 0, got 1)"); + + assertTypeErrorMessage(() => { ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t, [1]); }, + "the type of argument 1 is not a ctypes type (got the number 1)"); + assertTypeErrorMessage(() => { ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t, [ctypes.void_t]); }, + "the type of argument 1 cannot be void or function (got ctypes.void)"); + assertTypeErrorMessage(() => { ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t, [ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t, [])]); }, + "the type of argument 1 cannot be void or function (got ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t))"); + assertTypeErrorMessage(() => { ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t, [ctypes.StructType("a")]); }, + "the type of argument 1 must have defined size (got ctypes.StructType(\"a\"))"); + + assertTypeErrorMessage(() => { ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t, [])(); }, + "cannot construct from FunctionType; use FunctionType.ptr instead"); + + assertTypeErrorMessage(() => { ctypes.FunctionType(ctypes.default_abi, 1, []); }, + "return type is not a ctypes type (got the number 1)"); + assertTypeErrorMessage(() => { ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t.array(), []); }, + "return type cannot be an array or function (got ctypes.int32_t.array())"); + assertTypeErrorMessage(() => { ctypes.FunctionType(ctypes.default_abi, ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t, []), []); }, + "return type cannot be an array or function (got ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t))"); + assertTypeErrorMessage(() => { ctypes.FunctionType(ctypes.default_abi, ctypes.StructType("a"), []); }, + "return type must have defined size (got ctypes.StructType(\"a\"))"); + + let lib; + try { + lib = ctypes.open(ctypes.libraryName("c")); + } catch (e) { + } + if (!lib) + return; + + let func = lib.declare("hypot", + ctypes.default_abi, + ctypes.double, + ctypes.double, "..."); + assertRangeErrorMessage(() => { func(); }, + "number of arguments does not match declaration of double hypot(double, ...) (expected 1 or more, got 0)"); + assertTypeErrorMessage(() => { func(1, 2); }, + "variadic argument 2 must be a CData object (got the number 2)"); +} + +if (typeof ctypes === "object") + test(); diff --git a/js/src/jit-test/tests/ctypes/incompatible-abi.js b/js/src/jit-test/tests/ctypes/incompatible-abi.js new file mode 100644 index 0000000000..2d9cc0ce79 --- /dev/null +++ b/js/src/jit-test/tests/ctypes/incompatible-abi.js @@ -0,0 +1,9 @@ +load(libdir + 'asserts.js'); + +function test() { + assertTypeErrorMessage(() => { ctypes.default_abi.toSource.call(1); }, + "ABI.prototype.toSource called on incompatible Number"); +} + +if (typeof ctypes === "object") + test(); diff --git a/js/src/jit-test/tests/ctypes/incompatible-array.js b/js/src/jit-test/tests/ctypes/incompatible-array.js new file mode 100644 index 0000000000..a066a424c6 --- /dev/null +++ b/js/src/jit-test/tests/ctypes/incompatible-array.js @@ -0,0 +1,13 @@ +load(libdir + 'asserts.js'); + +function test() { + assertTypeErrorMessage(() => { ctypes.int32_t.array.call(1); }, + "CType.prototype.array called on incompatible object, got the object (new Number(1))"); + assertTypeErrorMessage(() => { ctypes.int32_t.array(10)().addressOfElement.call(1); }, + "ArrayType.prototype.addressOfElement called on incompatible object, got the object (new Number(1))"); + assertTypeErrorMessage(() => { ctypes.int32_t.array(10)().addressOfElement.call(ctypes.int32_t(0)); }, + "ArrayType.prototype.addressOfElement called on non-ArrayType CData, got ctypes.int32_t(0)"); +} + +if (typeof ctypes === "object") + test(); diff --git a/js/src/jit-test/tests/ctypes/incompatible-cdata.js b/js/src/jit-test/tests/ctypes/incompatible-cdata.js new file mode 100644 index 0000000000..c94fdfa88e --- /dev/null +++ b/js/src/jit-test/tests/ctypes/incompatible-cdata.js @@ -0,0 +1,24 @@ +load(libdir + 'asserts.js'); + +function test() { + assertTypeErrorMessage(() => { ctypes.int32_t(0).address.call(1); }, + "CData.prototype.address called on incompatible object, got the object (new Number(1))"); + assertTypeErrorMessage(() => { ctypes.char.array(10)("abc").readString.call(1); }, + "CData.prototype.readString called on incompatible object, got the object (new Number(1))"); + + assertTypeErrorMessage(() => { ctypes.char.array(10)("abc").readStringReplaceMalformed.call(1); }, + "CData.prototype.readStringReplaceMalformed called on incompatible object, got the object (new Number(1))"); + assertTypeErrorMessage(() => { ctypes.int32_t(0).toSource.call(1); }, + "CData.prototype.toSource called on incompatible Number"); + + let p = Object.getPrototypeOf(ctypes.int32_t()); + let o = {}; + Object.setPrototypeOf(o, p); + assertTypeErrorMessage(() => { o.readString(); }, + "CData.prototype.readString called on incompatible object, got <>"); + assertTypeErrorMessage(() => { o.readStringReplaceMalformed(); }, + "CData.prototype.readStringReplaceMalformed called on incompatible object, got <>"); +} + +if (typeof ctypes === "object") + test(); diff --git a/js/src/jit-test/tests/ctypes/incompatible-ctype.js b/js/src/jit-test/tests/ctypes/incompatible-ctype.js new file mode 100644 index 0000000000..ad75167148 --- /dev/null +++ b/js/src/jit-test/tests/ctypes/incompatible-ctype.js @@ -0,0 +1,11 @@ +load(libdir + 'asserts.js'); + +function test() { + assertTypeErrorMessage(() => { ctypes.int32_t.toString.call(1); }, + "CType.prototype.toString called on incompatible Number"); + assertTypeErrorMessage(() => { ctypes.int32_t.toSource.call(1); }, + "CType.prototype.toSource called on incompatible Number"); +} + +if (typeof ctypes === "object") + test(); diff --git a/js/src/jit-test/tests/ctypes/incompatible-finalizer.js b/js/src/jit-test/tests/ctypes/incompatible-finalizer.js new file mode 100644 index 0000000000..11e95886a9 --- /dev/null +++ b/js/src/jit-test/tests/ctypes/incompatible-finalizer.js @@ -0,0 +1,24 @@ +load(libdir + 'asserts.js'); + +function test() { + let fin = ctypes.CDataFinalizer(ctypes.int32_t(0), ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t, [ctypes.int32_t]).ptr(x => x)); + assertTypeErrorMessage(() => { fin.toSource.call(1); }, + "CDataFinalizer.prototype.toSource called on incompatible Number"); + assertTypeErrorMessage(() => { fin.toString.call(1); }, + "CDataFinalizer.prototype.toString called on incompatible Number"); + assertTypeErrorMessage(() => { fin.forget.call(1); }, + "CDataFinalizer.prototype.forget called on incompatible object, got the object (new Number(1))"); + assertTypeErrorMessage(() => { fin.dispose.call(1); }, + "CDataFinalizer.prototype.dispose called on incompatible object, got the object (new Number(1))"); + fin.forget(); + + assertTypeErrorMessage(() => { fin.readString(); }, + "CDataFinalizer.prototype.readString called on empty CDataFinalizer"); + assertTypeErrorMessage(() => { fin.dispose(); }, + "CDataFinalizer.prototype.dispose called on empty CDataFinalizer"); + assertTypeErrorMessage(() => { fin.forget(); }, + "CDataFinalizer.prototype.forget called on empty CDataFinalizer"); +} + +if (typeof ctypes === "object") + test(); diff --git a/js/src/jit-test/tests/ctypes/incompatible-function.js b/js/src/jit-test/tests/ctypes/incompatible-function.js new file mode 100644 index 0000000000..cd31cc5e70 --- /dev/null +++ b/js/src/jit-test/tests/ctypes/incompatible-function.js @@ -0,0 +1,13 @@ +load(libdir + 'asserts.js'); + +function test() { + assertTypeErrorMessage(() => { ctypes.FunctionType(ctypes.default_abi, ctypes.void_t).call.call(1); }, + "Function.prototype.call called on incompatible number"); + assertTypeErrorMessage(() => { ctypes.FunctionType(ctypes.default_abi, ctypes.void_t).call.call(ctypes.int32_t(0)); }, + "FunctionType.prototype.call called on non-PointerType CData, got ctypes.int32_t(0)"); + assertTypeErrorMessage(() => { ctypes.FunctionType(ctypes.default_abi, ctypes.void_t).call.call(ctypes.int32_t.ptr(0)); }, + "FunctionType.prototype.call called on non-FunctionType pointer, got ctypes.int32_t.ptr(ctypes.UInt64(\"0x0\"))"); +} + +if (typeof ctypes === "object") + test(); diff --git a/js/src/jit-test/tests/ctypes/incompatible-int64.js b/js/src/jit-test/tests/ctypes/incompatible-int64.js new file mode 100644 index 0000000000..3d53efba63 --- /dev/null +++ b/js/src/jit-test/tests/ctypes/incompatible-int64.js @@ -0,0 +1,24 @@ +load(libdir + 'asserts.js'); + +function test() { + assertTypeErrorMessage(() => { ctypes.Int64(0).toString.call(1); }, + "Int64.prototype.toString called on incompatible Number"); + assertTypeErrorMessage(() => { ctypes.Int64(0).toString.call(ctypes.int32_t(0)); }, + "Int64.prototype.toString called on non-Int64 CData"); + assertTypeErrorMessage(() => { ctypes.Int64(0).toSource.call(1); }, + "Int64.prototype.toSource called on incompatible Number"); + assertTypeErrorMessage(() => { ctypes.Int64(0).toSource.call(ctypes.int32_t(0)); }, + "Int64.prototype.toSource called on non-Int64 CData"); + + assertTypeErrorMessage(() => { ctypes.UInt64(0).toString.call(1); }, + "UInt64.prototype.toString called on incompatible Number"); + assertTypeErrorMessage(() => { ctypes.UInt64(0).toString.call(ctypes.int32_t(0)); }, + "UInt64.prototype.toString called on non-UInt64 CData"); + assertTypeErrorMessage(() => { ctypes.UInt64(0).toSource.call(1); }, + "UInt64.prototype.toSource called on incompatible Number"); + assertTypeErrorMessage(() => { ctypes.UInt64(0).toSource.call(ctypes.int32_t(0)); }, + "UInt64.prototype.toSource called on non-UInt64 CData"); +} + +if (typeof ctypes === "object") + test(); diff --git a/js/src/jit-test/tests/ctypes/incompatible-pointer.js b/js/src/jit-test/tests/ctypes/incompatible-pointer.js new file mode 100644 index 0000000000..bfacbd8527 --- /dev/null +++ b/js/src/jit-test/tests/ctypes/incompatible-pointer.js @@ -0,0 +1,19 @@ +load(libdir + 'asserts.js'); + +function test() { + assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).isNull.call(1); }, + "PointerType.prototype.isNull called on incompatible object, got the object (new Number(1))"); + assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).isNull.call({}); }, + "PointerType.prototype.isNull called on incompatible object, got the object ({})"); + assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).increment.call(1); }, + "PointerType.prototype.increment called on incompatible object, got the object (new Number(1))"); + assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).increment.call(ctypes.int32_t(0)); }, + "PointerType.prototype.increment called on non-PointerType CData, got ctypes.int32_t(0)"); + assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).decrement.call(1); }, + "PointerType.prototype.decrement called on incompatible object, got the object (new Number(1))"); + assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).decrement.call(ctypes.int32_t(0)); }, + "PointerType.prototype.decrement called on non-PointerType CData, got ctypes.int32_t(0)"); +} + +if (typeof ctypes === "object") + test(); diff --git a/js/src/jit-test/tests/ctypes/incompatible-struct.js b/js/src/jit-test/tests/ctypes/incompatible-struct.js new file mode 100644 index 0000000000..8bb0a2cd60 --- /dev/null +++ b/js/src/jit-test/tests/ctypes/incompatible-struct.js @@ -0,0 +1,31 @@ +load(libdir + 'asserts.js'); + +function test() { + assertTypeErrorMessage(() => { ctypes.StructType("a").define.call(1); }, + "StructType.prototype.define called on incompatible object, got the object (new Number(1))"); + assertTypeErrorMessage(() => { ctypes.StructType("a").define.call(ctypes.int32_t); }, + "StructType.prototype.define called on non-StructType, got ctypes.int32_t"); + + let p = Object.getPrototypeOf(ctypes.StructType("a", [ { "x": ctypes.int32_t, } ])()); + let o = {}; + Object.setPrototypeOf(o, p); + assertTypeErrorMessage(() => { let a = o.x; }, + "StructType property getter called on incompatible object, got <>"); + assertTypeErrorMessage(() => { o.x = 1; }, + "StructType property setter called on incompatible object, got <>"); + + o = ctypes.int32_t(0); + Object.setPrototypeOf(o, p); + assertTypeErrorMessage(() => { let a = o.x; }, + "StructType property getter called on non-StructType CData, got ctypes.int32_t(0)"); + assertTypeErrorMessage(() => { o.x = 1; }, + "StructType property setter called on non-StructType CData, got ctypes.int32_t(0)"); + + assertTypeErrorMessage(() => { ctypes.StructType("a", [])().addressOfField.call(1); }, + "StructType.prototype.addressOfField called on incompatible object, got the object (new Number(1))"); + assertTypeErrorMessage(() => { ctypes.StructType("a", [])().addressOfField.call(ctypes.int32_t(0)); }, + "StructType.prototype.addressOfField called on non-StructType CData, got ctypes.int32_t(0)"); +} + +if (typeof ctypes === "object") + test(); diff --git a/js/src/jit-test/tests/ctypes/pointer.js b/js/src/jit-test/tests/ctypes/pointer.js new file mode 100644 index 0000000000..da0685f07b --- /dev/null +++ b/js/src/jit-test/tests/ctypes/pointer.js @@ -0,0 +1,31 @@ +load(libdir + 'asserts.js'); + +function test() { + let p = ctypes.StructType("foo").ptr(0); + + assertTypeErrorMessage(() => { p.increment(); }, + "cannot modify pointer of undefined size foo.ptr(ctypes.UInt64(\"0x0\"))"); + assertTypeErrorMessage(() => { p.decrement(); }, + "cannot modify pointer of undefined size foo.ptr(ctypes.UInt64(\"0x0\"))"); + + assertTypeErrorMessage(() => { let a = p.contents; }, + "cannot get contents of pointer of undefined size foo.ptr(ctypes.UInt64(\"0x0\"))"); + assertTypeErrorMessage(() => { p.contents = 1; }, + "cannot set contents of pointer of undefined size foo.ptr(ctypes.UInt64(\"0x0\"))"); + + let p2 = ctypes.int32_t.ptr(0); + assertTypeErrorMessage(() => { let a = p2.contents; }, + "cannot read contents of null pointer ctypes.int32_t.ptr(ctypes.UInt64(\"0x0\"))"); + assertTypeErrorMessage(() => { p2.contents = 1; }, + "cannot write contents to null pointer ctypes.int32_t.ptr(ctypes.UInt64(\"0x0\"))"); + assertTypeErrorMessage(() => { p2.readString(); }, + "cannot read contents of null pointer ctypes.int32_t.ptr(ctypes.UInt64(\"0x0\"))"); + + assertTypeErrorMessage(() => { ctypes.int32_t(0).readString(); }, + "expected PointerType or ArrayType, got ctypes.int32_t(0)"); + assertTypeErrorMessage(() => { ctypes.int32_t(0).address().readString(); }, + /base type ctypes\.int32_t\.ptr\(ctypes\.UInt64\(\"[x0-9A-Fa-f]+\"\)\) is not an 8-bit or 16-bit integer or character type/); +} + +if (typeof ctypes === "object") + test(); diff --git a/js/src/jit-test/tests/ctypes/struct-field.js b/js/src/jit-test/tests/ctypes/struct-field.js new file mode 100644 index 0000000000..2b2089e430 --- /dev/null +++ b/js/src/jit-test/tests/ctypes/struct-field.js @@ -0,0 +1,21 @@ +load(libdir + 'asserts.js'); + +function test() { + assertTypeErrorMessage(() => { ctypes.StructType("a", [ 1 ]); }, + "struct field descriptors require a valid name and type (got the number 1)"); + assertTypeErrorMessage(() => { ctypes.StructType("a", [ { x: 1, y: 2 } ]); }, + "struct field descriptors must contain one property (got the object ({x:1, y:2}) with 2 properties)"); + assertTypeErrorMessage(() => { ctypes.StructType("a", [ { 1: 1 } ]); }, + "the number 1 is not a valid name of struct field descriptors"); + assertTypeErrorMessage(() => { ctypes.StructType("a", [ { "x": 1 } ]); }, + "the number 1 is not a valid type of struct field descriptors for 'x' field"); + assertTypeErrorMessage(() => { ctypes.StructType("a", [ { "x": ctypes.StructType("b") } ]); }, + "struct field type must have defined and nonzero size (got ctypes.StructType(\"b\") for 'x' field)"); + assertTypeErrorMessage(() => { ctypes.StructType("a", [ { "x": ctypes.int32_t, }, { "x": ctypes.int32_t } ]); }, + "struct fields must have unique names, 'x' field appears twice"); + assertTypeErrorMessage(() => { ctypes.StructType("a", [ { "x": ctypes.int32_t, } ])().addressOfField("z"); }, + "ctypes.StructType(\"a\", [{ \"x\": ctypes.int32_t }]) does not have a field named 'z'"); +} + +if (typeof ctypes === "object") + test(); diff --git a/js/src/jit-test/tests/debug/bug1219905.js b/js/src/jit-test/tests/debug/bug1219905.js index fa9d59d307..d7bc83527a 100644 --- a/js/src/jit-test/tests/debug/bug1219905.js +++ b/js/src/jit-test/tests/debug/bug1219905.js @@ -11,4 +11,4 @@ var g = newGlobal(); g.parent = this; g.eval("new Debugger(parent).onExceptionUnwind = function() {}"); let finished = false; -oomTest(() => l); +oomTest(() => l, false); diff --git a/js/src/jit-test/tests/ion/inlining/TypedObject-TypeDescrIsArrayType-unknown.js b/js/src/jit-test/tests/ion/inlining/TypedObject-TypeDescrIsArrayType-unknown.js deleted file mode 100644 index 06ea3d9d82..0000000000 --- a/js/src/jit-test/tests/ion/inlining/TypedObject-TypeDescrIsArrayType-unknown.js +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- tab-width: 8; indent-tabs-mode: nil; js-indent-level: 2 -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Testing TypeDescrIsArrayType() is somewhat straightforward: it's - * used early in the map() method on TypedObject arrays. - * - * This basically asserts that map() works, and thus that the code is - * at least not broken. - * - * To verify that inlining happens: - * - * Run this with IONFLAGS=logs, generate pdfs with iongraph, and then - * try running "pdfgrep TypeDescrIsArrayType func*pass00*.pdf", this - * might net a function that is a likely candidate for manual inspection. - * - * It turns out to be hard to write a test that causes a run-time test - * to be inserted at the right spot, however. This is my best effort, - * but the test is still specialized as "true" in the generated code. - * - * (It is sometimes useful to neuter the assert() macro in the - * self-hosted code.) - */ - -if (!this.TypedObject) { - print("No TypedObject, skipping"); - quit(); -} - -var T = TypedObject; -var AT = new T.ArrayType(T.int32, 100); - -function check(v) { - return v.map(x => x+1); -} - -function Array_build(n, f) { - var a = new Array(n); - for ( var i=0 ; i < n ; i++ ) - a[i] = f(i); - return a; -} - -function test() { - var w1 = AT.build(x => x+1); - var w2 = Array_build(100, x => x+1); - w2.map = w1.map; - var a = [ w1, w2 ]; - for ( var i=0 ; i < 2000 ; i++ ) - try { a[i%2] = check(a[i%2]); } catch (e) { assertEq( i%2, 1 ); } - return a[0]; -} - -var w = test(); -assertEq(w.length, 100); -assertEq(w[99], 1100); -print("Done"); diff --git a/js/src/jit-test/tests/ion/inlining/TypedObject-TypeDescrIsArrayType.js b/js/src/jit-test/tests/ion/inlining/TypedObject-TypeDescrIsArrayType.js deleted file mode 100644 index 538422a1c8..0000000000 --- a/js/src/jit-test/tests/ion/inlining/TypedObject-TypeDescrIsArrayType.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- tab-width: 8; indent-tabs-mode: nil; js-indent-level: 2 -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Testing TypeDescrIsArrayType() is somewhat straightforward: it's - * used early in the map() method on TypedObject arrays. - * - * This basically asserts that map() works, and thus that the code is - * at least not broken. - * - * To verify that inlining happens: - * - * Run this with IONFLAGS=logs, generate pdfs with iongraph, and then - * try running "pdfgrep TypeDescrIsArrayType func*pass00*.pdf", this - * might net a function that is a likely candidate for manual inspection. - * - * (It is sometimes useful to neuter the assert() macro in the - * self-hosted code.) - */ - -if (!this.TypedObject) { - print("No TypedObject, skipping"); - quit(); -} - -var T = TypedObject; -var AT = new T.ArrayType(T.int32, 100); - -function check(v) { - return v.map(x => x+1); -} - -function test() { - var w = new AT(); - for ( var i=0 ; i < 1000 ; i++ ) - w = check(w); - return w; -} - -var w = test(); -assertEq(w.length, 100); -assertEq(w[99], 1000); -print("Done"); - diff --git a/js/src/jit-test/tests/ion/inlining/typedarray-data-inlining-neuter-samedata.js b/js/src/jit-test/tests/ion/inlining/typedarray-data-inlining-neuter-samedata.js index 59b9f7f214..5fbfade9a5 100644 --- a/js/src/jit-test/tests/ion/inlining/typedarray-data-inlining-neuter-samedata.js +++ b/js/src/jit-test/tests/ion/inlining/typedarray-data-inlining-neuter-samedata.js @@ -5,7 +5,7 @@ var INLINABLE_INT8_AMOUNT = 4; // Large arrays with non-inline data -// Neutering and replacing data. +// Detaching and replacing data. var ab1 = new ArrayBuffer(NONINLINABLE_AMOUNT * SIZEOF_INT32); var ta1 = new Int32Array(ab1); for (var i = 0; i < ta1.length; i++) @@ -13,10 +13,10 @@ for (var i = 0; i < ta1.length; i++) function q1() { return ta1[NONINLINABLE_AMOUNT - 1]; } assertEq(q1(), NONINLINABLE_AMOUNT - 1 + 43); assertEq(q1(), NONINLINABLE_AMOUNT - 1 + 43); -neuter(ab1, "change-data"); +detachArrayBuffer(ab1, "change-data"); assertEq(q1(), undefined); -// Neutering preserving data pointer. +// Detaching preserving data pointer. var ab2 = new ArrayBuffer(NONINLINABLE_AMOUNT * SIZEOF_INT32); var ta2 = new Int32Array(ab2); for (var i = 0; i < ta2.length; i++) @@ -24,12 +24,12 @@ for (var i = 0; i < ta2.length; i++) function q2() { return ta2[NONINLINABLE_AMOUNT - 1]; } assertEq(q2(), NONINLINABLE_AMOUNT - 1 + 77); assertEq(q2(), NONINLINABLE_AMOUNT - 1 + 77); -neuter(ab2, "same-data"); +detachArrayBuffer(ab2, "same-data"); assertEq(q2(), undefined); // Small arrays with inline data -// Neutering and replacing data. +// Detaching and replacing data. var ab3 = new ArrayBuffer(INLINABLE_INT8_AMOUNT); var ta3 = new Int8Array(ab3); for (var i = 0; i < ta3.length; i++) @@ -37,10 +37,10 @@ for (var i = 0; i < ta3.length; i++) function q3() { return ta3[INLINABLE_INT8_AMOUNT - 1]; } assertEq(q3(), INLINABLE_INT8_AMOUNT - 1 + 13); assertEq(q3(), INLINABLE_INT8_AMOUNT - 1 + 13); -neuter(ab3, "change-data"); +detachArrayBuffer(ab3, "change-data"); assertEq(q3(), undefined); -// Neutering preserving data pointer. +// Detaching preserving data pointer. var ab4 = new ArrayBuffer(4); var ta4 = new Int8Array(ab4); for (var i = 0; i < ta4.length; i++) @@ -48,5 +48,5 @@ for (var i = 0; i < ta4.length; i++) function q4() { return ta4[INLINABLE_INT8_AMOUNT - 1]; } assertEq(q4(), INLINABLE_INT8_AMOUNT - 1 + 17); assertEq(q4(), INLINABLE_INT8_AMOUNT - 1 + 17); -neuter(ab4, "same-data"); +detachArrayBuffer(ab4, "same-data"); assertEq(q4(), undefined); diff --git a/js/src/jit-test/tests/ion/inlining/typedarray-length-inlining-neuter.js b/js/src/jit-test/tests/ion/inlining/typedarray-length-inlining-neuter.js index d5a2e917ea..73b0e815f4 100644 --- a/js/src/jit-test/tests/ion/inlining/typedarray-length-inlining-neuter.js +++ b/js/src/jit-test/tests/ion/inlining/typedarray-length-inlining-neuter.js @@ -3,40 +3,40 @@ var OUT_OF_LINE_INT8_AMOUNT = 237; // Small and inline -// Neutering and replacing data. +// Detaching and replacing data. var ab1 = new ArrayBuffer(INLINE_INT8_AMOUNT); var ta1 = new Int8Array(ab1); function q1() { return ta1.length; } q1(); q1(); -neuter(ab1, "change-data"); +detachArrayBuffer(ab1, "change-data"); assertEq(q1(), 0); -// Neutering preserving data pointer. +// Detaching preserving data pointer. var ab2 = new ArrayBuffer(INLINE_INT8_AMOUNT); var ta2 = new Int8Array(ab2); function q2() { return ta2.length; } q2(); q2(); -neuter(ab2, "same-data"); +detachArrayBuffer(ab2, "same-data"); assertEq(q2(), 0); // Large and out-of-line -// Neutering and replacing data. +// Detaching and replacing data. var ab3 = new ArrayBuffer(OUT_OF_LINE_INT8_AMOUNT); var ta3 = new Int8Array(ab3); function q3() { return ta3.length; } q3(); q3(); -neuter(ab3, "change-data"); +detachArrayBuffer(ab3, "change-data"); assertEq(q3(), 0); -// Neutering preserving data pointer. +// Detaching preserving data pointer. var ab4 = new ArrayBuffer(OUT_OF_LINE_INT8_AMOUNT); var ta4 = new Int8Array(ab4); function q4() { return ta4.length; } q4(); q4(); -neuter(ab4, "same-data"); +detachArrayBuffer(ab4, "same-data"); assertEq(q4(), 0); diff --git a/js/src/jit-test/tests/ion/typedarray-length.js b/js/src/jit-test/tests/ion/typedarray-length.js index 56ad2f7eca..2ba13a8ce7 100644 --- a/js/src/jit-test/tests/ion/typedarray-length.js +++ b/js/src/jit-test/tests/ion/typedarray-length.js @@ -1,4 +1,4 @@ -function neuterEventually(arr, i, variant) +function detachArrayBufferEventually(arr, i, variant) { with (arr) { @@ -6,7 +6,7 @@ function neuterEventually(arr, i, variant) } if (i === 2000) - neuter(arr.buffer, variant); + detachArrayBuffer(arr.buffer, variant); } function test(variant) @@ -16,7 +16,7 @@ function test(variant) for (var i = 0; i < 2500; i++) { - neuterEventually(ta, i, variant); + detachArrayBufferEventually(ta, i, variant); assertEq(ta.length, i >= 2000 ? 0 : 1000); } } diff --git a/js/src/jit-test/tests/ion/typedarray-static-load.js b/js/src/jit-test/tests/ion/typedarray-static-load.js index 59c7c96adf..f051ed11ec 100644 --- a/js/src/jit-test/tests/ion/typedarray-static-load.js +++ b/js/src/jit-test/tests/ion/typedarray-static-load.js @@ -7,6 +7,6 @@ load(); load(); load(); -neuter(buffer, "change-data"); +detachArrayBuffer(buffer, "change-data"); load(); diff --git a/js/src/jit-test/tests/ion/typedarray-static-store.js b/js/src/jit-test/tests/ion/typedarray-static-store.js index 5d48b0c554..ce631f7cca 100644 --- a/js/src/jit-test/tests/ion/typedarray-static-store.js +++ b/js/src/jit-test/tests/ion/typedarray-static-store.js @@ -7,6 +7,6 @@ store(); store(); store(); -neuter(buffer, "change-data"); +detachArrayBuffer(buffer, "change-data"); store(); diff --git a/js/src/jit-test/tests/self-test/findPath-bug1234428.js b/js/src/jit-test/tests/self-test/findPath-bug1234428.js new file mode 100644 index 0000000000..06788e508b --- /dev/null +++ b/js/src/jit-test/tests/self-test/findPath-bug1234428.js @@ -0,0 +1,23 @@ +// 1. --ion-eager causes all functions to be compiled with IonMonkey before +// executing them. +// 2. Registering the onIonCompilation hook on the Debugger causes +// the JSScript of the function C to be wrapped in the Debugger compartment. +// 3. The JSScript hold a pointer to its function C. +// 4. The function C, hold its environment. +// 5. The environment holds the Object o. +g = newGlobal(); +g.parent = this; +g.eval(` + dbg = Debugger(parent); + dbg.onIonCompilation = function () {}; +`); + +function foo() { + eval(` + var o = {}; + function C() {}; + new C; + findPath(o, o); + `); +} +foo(); diff --git a/js/src/jit-test/tests/wasm/basic-memory.js b/js/src/jit-test/tests/wasm/basic-memory.js index b81ed766b5..6293d40b49 100644 --- a/js/src/jit-test/tests/wasm/basic-memory.js +++ b/js/src/jit-test/tests/wasm/basic-memory.js @@ -1,7 +1,5 @@ load(libdir + "wasm.js"); -quit(); // TODO: Loads and stores are NYI. - if (!wasmIsSupported()) quit(); @@ -11,18 +9,6 @@ function mismatchError(actual, expect) { } function testLoad(type, ext, base, offset, align, expect) { - print('(module' + - ' (memory 0x10000' + - ' (segment 0 "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f")' + - ' (segment 16 "\\f0\\f1\\f2\\f3\\f4\\f5\\f6\\f7\\f8\\f9\\fa\\fb\\fc\\fd\\fe\\ff")' + - ' )' + - ' (func (param i32) (result ' + type + ')' + - ' (' + type + '.load' + ext + - ' offset=' + offset + - ' ' + (align != 0 ? 'align=' + align : '') + - ' (get_local 0)' + - ' )' + - ' ) (export "" 0))'); assertEq(wasmEvalText( '(module' + ' (memory 0x10000' + @@ -42,7 +28,7 @@ function testLoad(type, ext, base, offset, align, expect) { function testStore(type, ext, base, offset, align, value) { assertEq(wasmEvalText( '(module' + - ' (memory 0x10000)' + + ' (memory 0x10000' + ' (segment 0 "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f")' + ' (segment 16 "\\f0\\f1\\f2\\f3\\f4\\f5\\f6\\f7\\f8\\f9\\fa\\fb\\fc\\fd\\fe\\ff")' + ' )' + @@ -57,58 +43,91 @@ function testStore(type, ext, base, offset, align, value) { )(base, value), value); } -function testConstError(type, str) { - // For now at least, we don't distinguish between parse errors and OOMs. - assertErrorMessage(() => wasmEvalText('(module (func (result ' + type + ') (' + type + '.const ' + str + ')) (export "" 0))')(), Error, /out of memory/); +function testLoadError(type, ext, base, offset, align, errorMsg) { + assertErrorMessage(() => wasmEvalText( + '(module' + + ' (memory 0x10000' + + ' (segment 0 "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f")' + + ' (segment 16 "\\f0\\f1\\f2\\f3\\f4\\f5\\f6\\f7\\f8\\f9\\fa\\fb\\fc\\fd\\fe\\ff")' + + ' )' + + ' (func (param i32) (result ' + type + ')' + + ' (' + type + '.load' + ext + + ' offset=' + offset + + ' ' + (align != 0 ? 'align=' + align : '') + + ' (get_local 0)' + + ' )' + + ' ) (export "" 0))' + ), Error, errorMsg); } -testLoad('i32', '', 0, 0, 0, 0x00010203); -testLoad('i32', '', 1, 0, 0, 0x01020304); -//testLoad('i32', '', 0, 1, 0, 0x01020304); // TODO: NYI -//testLoad('i32', '', 1, 1, 4, 0x02030405); // TODO: NYI -//testLoad('i64', '', 0, 0, 0, 0x0001020304050607); // TODO: NYI -//testLoad('i64', '', 1, 0, 0, 0x0102030405060708); // TODO: NYI -//testLoad('i64', '', 0, 1, 0, 0x0102030405060708); // TODO: NYI -//testLoad('i64', '', 1, 1, 4, 0x0203040506070809); // TODO: NYI -testLoad('f32', '', 0, 0, 0, 0x00010203); -testLoad('f32', '', 1, 0, 0, 0x01020304); -//testLoad('f32', '', 0, 1, 0, 0x01020304); // TODO: NYI -//testLoad('f32', '', 1, 1, 4, 0x02030405); // TODO: NYI -testLoad('f64', '', 0, 0, 0, 0x00010203); -testLoad('f64', '', 1, 0, 0, 0x01020304); -//testLoad('f64', '', 0, 1, 0, 0x01020304); // TODO: NYI -//testLoad('f64', '', 1, 1, 4, 0x02030405); // TODO: NYI +function testStoreError(type, ext, base, offset, align, errorMsg) { + assertErrorMessage(() => wasmEvalText( + '(module' + + ' (memory 0x10000' + + ' (segment 0 "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f")' + + ' (segment 16 "\\f0\\f1\\f2\\f3\\f4\\f5\\f6\\f7\\f8\\f9\\fa\\fb\\fc\\fd\\fe\\ff")' + + ' )' + + ' (func (param i32) (param ' + type + ') (result ' + type + ')' + + ' (' + type + '.store' + ext + + ' offset=' + offset + + ' ' + (align != 0 ? 'align=' + align : '') + + ' (get_local 0)' + + ' (get_local 1)' + + ' )' + + ' ) (export "" 0))' + ), Error, errorMsg); +} -testLoad('i32', '8_s', 16, 0, 0, -0x8); -testLoad('i32', '8_u', 16, 0, 0, 0x8); -testLoad('i32', '16_s', 16, 0, 0, -0x707); -testLoad('i32', '16_u', 16, 0, 0, 0x8f9); -testLoad('i64', '8_s', 16, 0, 0, -0x8); -testLoad('i64', '8_u', 16, 0, 0, 0x8); -//testLoad('i64', '16_s', 16, 0, 0, -0x707); // TODO: NYI -//testLoad('i64', '16_u', 16, 0, 0, 0x8f9); // TODO: NYI -//testLoad('i64', '32_s', 16, 0, 0, -0x7060505); // TODO: NYI -//testLoad('i64', '32_u', 16, 0, 0, 0x8f9fafb); // TODO: NYI +testLoad('i32', '', 0, 0, 0, 0x03020100); +//testLoad('i32', '', 1, 0, 0, 0x04030201); // TODO: unaligned NYI +//testLoad('i32', '', 0, 1, 0, 0x01020304); // TODO: offsets NYI +//testLoad('i32', '', 1, 1, 4, 0x02030405); // TODO: offsets NYI +//testLoad('i64', '', 0, 0, 0, 0x0001020304050607); // TODO: i64 NYI +//testLoad('i64', '', 1, 0, 0, 0x0102030405060708); // TODO: i64 NYI +//testLoad('i64', '', 0, 1, 0, 0x0102030405060708); // TODO: i64 NYI +//testLoad('i64', '', 1, 1, 4, 0x0203040506070809); // TODO: i64 NYI +testLoad('f32', '', 0, 0, 0, 3.820471434542632e-37); +//testLoad('f32', '', 1, 0, 0, 1.539989614439558e-36); // TODO: unaligned NYI +//testLoad('f32', '', 0, 1, 0, 0x01020304); // TODO: offsets NYI +//testLoad('f32', '', 1, 1, 4, 0x02030405); // TODO: offsets NYI +testLoad('f64', '', 0, 0, 0, 7.949928895127363e-275); +//testLoad('f64', '', 1, 0, 0, 5.447603722011605e-270); // TODO: unaligned NYI +//testLoad('f64', '', 0, 1, 0, 0x01020304); // TODO: offsets NYI +//testLoad('f64', '', 1, 1, 4, 0x02030405); // TODO: offsets NYI -testStore('i32', '', 0, 0, 0, 0xc0c1d3d4); -testStore('i32', '', 1, 0, 0, 0xc0c1d3d4); -//testStore('i32', '', 0, 1, 0, 0xc0c1d3d4); // TODO: NYI -//testStore('i32', '', 1, 1, 4, 0xc0c1d3d4); // TODO: NYI -//testStore('i64', '', 0, 0, 0, 0xc0c1d3d4e6e7090a); // TODO: NYI -//testStore('i64', '', 1, 0, 0, 0xc0c1d3d4e6e7090a); // TODO: NYI -//testStore('i64', '', 0, 1, 0, 0xc0c1d3d4e6e7090a); // TODO: NYI -//testStore('i64', '', 1, 1, 4, 0xc0c1d3d4e6e7090a); // TODO: NYI -testStore('f32', '', 0, 0, 0, 0.01234567); -testStore('f32', '', 1, 0, 0, 0.01234567); -//testStore('f32', '', 0, 1, 0, 0.01234567); // TODO: NYI -//testStore('f32', '', 1, 1, 4, 0.01234567); // TODO: NYI +testLoad('i32', '8_s', 16, 0, 0, -0x10); +testLoad('i32', '8_u', 16, 0, 0, 0xf0); +testLoad('i32', '16_s', 16, 0, 0, -0xe10); +testLoad('i32', '16_u', 16, 0, 0, 0xf1f0); +//testLoad('i64', '8_s', 16, 0, 0, -0x8); // TODO: i64 NYI +//testLoad('i64', '8_u', 16, 0, 0, 0x8); // TODO: i64 NYI +//testLoad('i64', '16_s', 16, 0, 0, -0x707); // TODO: i64 NYI +//testLoad('i64', '16_u', 16, 0, 0, 0x8f9); // TODO: i64 NYI +//testLoad('i64', '32_s', 16, 0, 0, -0x7060505); // TODO: i64 NYI +//testLoad('i64', '32_u', 16, 0, 0, 0x8f9fafb); // TODO: i64 NYI + +testStore('i32', '', 0, 0, 0, -0x3f3e2c2c); +//testStore('i32', '', 1, 0, 0, -0x3f3e2c2c); // TODO: unaligned NYI +//testStore('i32', '', 0, 1, 0, 0xc0c1d3d4); // TODO: offset NYI +//testStore('i32', '', 1, 1, 4, 0xc0c1d3d4); // TODO: offset NYI +//testStore('i64', '', 0, 0, 0, 0xc0c1d3d4e6e7090a); // TODO: i64 NYI +//testStore('i64', '', 1, 0, 0, 0xc0c1d3d4e6e7090a); // TODO: i64 NYI +//testStore('i64', '', 0, 1, 0, 0xc0c1d3d4e6e7090a); // TODO: i64 NYI +//testStore('i64', '', 1, 1, 4, 0xc0c1d3d4e6e7090a); // TODO: i64 NYI +testStore('f32', '', 0, 0, 0, 0.01234566979110241); +//testStore('f32', '', 1, 0, 0, 0.01234566979110241); // TODO: unaligned NYI +//testStore('f32', '', 0, 1, 0, 0.01234567); // TODO: offsets NYI +//testStore('f32', '', 1, 1, 4, 0.01234567); // TODO: offsets NYI testStore('f64', '', 0, 0, 0, 0.89012345); -testStore('f64', '', 1, 0, 0, 0.89012345); -//testStore('f64', '', 0, 1, 0, 0.89012345); // TODO: NYI -//testStore('f64', '', 1, 1, 4, 0.89012345); // TODO: NYI +//testStore('f64', '', 1, 0, 0, 0.89012345); // TODO: unaligned NYI +//testStore('f64', '', 0, 1, 0, 0.89012345); // TODO: offsets NYI +//testStore('f64', '', 1, 1, 4, 0.89012345); // TODO: offsets NYI testStore('i32', '8', 0, 0, 0, 0x23); testStore('i32', '16', 0, 0, 0, 0x2345); -//testStore('i64', '8', 0, 0, 0, 0x23); // TODO: NYI -//testStore('i64', '16', 0, 0, 0, 0x23); // TODO: NYI -//testStore('i64', '32', 0, 0, 0, 0x23); // TODO: NYI +//testStore('i64', '8', 0, 0, 0, 0x23); // TODO: i64 NYI +//testStore('i64', '16', 0, 0, 0, 0x23); // TODO: i64 NYI +//testStore('i64', '32', 0, 0, 0, 0x23); // TODO: i64 NYI + +testLoadError('i32', '', 0, 0, 3, /memory access alignment must be a power of two/); +testStoreError('i32', '', 0, 0, 3, /memory access alignment must be a power of two/); diff --git a/js/src/tests/ecma_6/DataView/detach-after-construction.js b/js/src/tests/ecma_6/DataView/detach-after-construction.js index 6185b2a1d0..a2c66a5808 100644 --- a/js/src/tests/ecma_6/DataView/detach-after-construction.js +++ b/js/src/tests/ecma_6/DataView/detach-after-construction.js @@ -1,13 +1,13 @@ -// |reftest| skip-if(!xulRuntime.shell) +// |reftest| skip-if(!xulRuntime.shell) -- needs detachArrayBuffer -for (var neuterArg of ['change-data', 'same-data']) { +for (var detachArg of ['change-data', 'same-data']) { var buf = new ArrayBuffer([1,2]); var bufView = new DataView(buf); - neuter(buf, neuterArg); + detachArrayBuffer(buf, detachArg); - assertThrowsInstanceOf(()=>bufView.getInt8(0), TypeError); + assertThrowsInstanceOf(() => bufView.getInt8(0), TypeError); } if (typeof reportCompare === 'function') - reportCompare(0,0,"OK"); + reportCompare(0, 0, "OK"); diff --git a/js/src/tests/ecma_6/Function/bound-length-and-name.js b/js/src/tests/ecma_6/Function/bound-length-and-name.js index b4fefc7208..ef2f1ffbcd 100644 --- a/js/src/tests/ecma_6/Function/bound-length-and-name.js +++ b/js/src/tests/ecma_6/Function/bound-length-and-name.js @@ -14,16 +14,14 @@ var proxy = new Proxy(function() {}, { }) var bound = Function.prototype.bind.call(proxy); -//assertEq(bound.name, "bound hello world"); -assertEq(bound.name, "hello world"); +assertEq(bound.name, "bound hello world"); assertEq(bound.length, 3); var fun = function() {}; Object.defineProperty(fun, "name", {value: 1337}); Object.defineProperty(fun, "length", {value: "15"}); bound = fun.bind(); -// assertEq(bound.name, "bound "); -assertEq(bound.name, ""); +assertEq(bound.name, "bound "); assertEq(bound.length, 0); Object.defineProperty(fun, "length", {value: Number.MAX_SAFE_INTEGER}); diff --git a/js/src/tests/ecma_6/TypedArray/constructor-non-detached.js b/js/src/tests/ecma_6/TypedArray/constructor-non-detached.js index c3054256de..aec6022e04 100644 --- a/js/src/tests/ecma_6/TypedArray/constructor-non-detached.js +++ b/js/src/tests/ecma_6/TypedArray/constructor-non-detached.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!xulRuntime.shell) +// |reftest| skip-if(!xulRuntime.shell) -- needs detachArrayBuffer const constructors = [ Int8Array, @@ -13,14 +13,14 @@ const constructors = [ ]; for (var constructor of constructors) { - for (var neuterType of ["change-data", "same-data"]) { + for (var detachType of ["change-data", "same-data"]) { var buf = new constructor(); - neuter(buf.buffer, neuterType); - assertThrowsInstanceOf(()=> new constructor(buf), TypeError); + detachArrayBuffer(buf.buffer, detachType); + assertThrowsInstanceOf(() => new constructor(buf), TypeError); var buffer = new ArrayBuffer(); - neuter(buffer, neuterType); - assertThrowsInstanceOf(()=> new constructor(buffer), TypeError); + detachArrayBuffer(buffer, detachType); + assertThrowsInstanceOf(() => new constructor(buffer), TypeError); } } diff --git a/js/src/tests/ecma_6/TypedArray/detached-array-buffer-checks.js b/js/src/tests/ecma_6/TypedArray/detached-array-buffer-checks.js index 713a21c2a5..6f49c954b6 100644 --- a/js/src/tests/ecma_6/TypedArray/detached-array-buffer-checks.js +++ b/js/src/tests/ecma_6/TypedArray/detached-array-buffer-checks.js @@ -1,11 +1,11 @@ -// |reftest| skip-if(!xulRuntime.shell) +// |reftest| skip-if(!xulRuntime.shell) -- needs detachArrayBuffer // Nearly every %TypedArray%.prototype method should throw a TypeError when called // atop a detached array buffer. Here we check verify that this holds true for // all relevant functions. let buffer = new ArrayBuffer(32); let array = new Int32Array(buffer); -neuter(buffer, "change-data"); +detachArrayBuffer(buffer, "change-data"); // A nice poisoned callable to ensure that we fail on a detached buffer check // before a method attempts to do anything with its arguments. @@ -34,7 +34,7 @@ assertThrowsInstanceOf(() => { }, TypeError); assertThrowsInstanceOf(() => { - array.filter((x) => x); + array.filter(POISON); }, TypeError); assertThrowsInstanceOf(() => { @@ -58,7 +58,7 @@ assertThrowsInstanceOf(() => { }, TypeError); assertThrowsInstanceOf(() => { - array.join(); + array.join(POISON); }, TypeError); assertThrowsInstanceOf(() => { diff --git a/js/src/tests/ecma_6/TypedArray/sort_errors.js b/js/src/tests/ecma_6/TypedArray/sort_errors.js index e0069230e3..0dfa12324b 100644 --- a/js/src/tests/ecma_6/TypedArray/sort_errors.js +++ b/js/src/tests/ecma_6/TypedArray/sort_errors.js @@ -1,10 +1,10 @@ -// |reftest| skip-if(!xulRuntime.shell) +// |reftest| skip-if(!xulRuntime.shell) -- needs detachArrayBuffer // Ensure that TypedArrays throw when attempting to sort a detached ArrayBuffer assertThrowsInstanceOf(() => { let buffer = new ArrayBuffer(32); let array = new Int32Array(buffer); - neuter(buffer, "change-data"); + detachArrayBuffer(buffer, "change-data"); array.sort(); }, TypeError); diff --git a/js/src/tests/ecma_6/extensions/ArrayBuffer-slice-arguments-neutering.js b/js/src/tests/ecma_6/extensions/ArrayBuffer-slice-arguments-neutering.js index 0651df6241..7d49c99350 100644 --- a/js/src/tests/ecma_6/extensions/ArrayBuffer-slice-arguments-neutering.js +++ b/js/src/tests/ecma_6/extensions/ArrayBuffer-slice-arguments-neutering.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!xulRuntime.shell) -- needs neuter() +// |reftest| skip-if(!xulRuntime.shell) -- needs detachArrayBuffer() /* * Any copyright is dedicated to the Public Domain. * http://creativecommons.org/licenses/publicdomain/ @@ -9,7 +9,7 @@ var gTestfile = "ArrayBuffer-slice-arguments-neutering.js"; var BUGNUMBER = 991981; var summary = "ArrayBuffer.prototype.slice shouldn't misbehave horribly if " + - "index-argument conversion neuters the ArrayBuffer being sliced"; + "index-argument conversion detaches the ArrayBuffer being sliced"; print(BUGNUMBER + ": " + summary); @@ -25,7 +25,7 @@ function testStart(dataType) { valueOf: function() { - neuter(ab, dataType); + detachArrayBuffer(ab, dataType); gc(); return 0x800; } @@ -41,7 +41,7 @@ function testStart(dataType) ok = true; } assertEq(ok, true, "start weirdness should have thrown"); - assertEq(ab.byteLength, 0, "neutering should work for start weirdness"); + assertEq(ab.byteLength, 0, "detaching should work for start weirdness"); } testStart("change-data"); testStart("same-data"); @@ -54,7 +54,7 @@ function testEnd(dataType) { valueOf: function() { - neuter(ab, dataType); + detachArrayBuffer(ab, dataType); gc(); return 0x1000; } @@ -70,7 +70,7 @@ function testEnd(dataType) ok = true; } assertEq(ok, true, "byteLength weirdness should have thrown"); - assertEq(ab.byteLength, 0, "neutering should work for byteLength weirdness"); + assertEq(ab.byteLength, 0, "detaching should work for byteLength weirdness"); } testEnd("change-data"); testEnd("same-data"); diff --git a/js/src/tests/ecma_6/extensions/DataView-construct-arguments-neutering.js b/js/src/tests/ecma_6/extensions/DataView-construct-arguments-neutering.js index 7bd55f1ffc..182f06e93b 100644 --- a/js/src/tests/ecma_6/extensions/DataView-construct-arguments-neutering.js +++ b/js/src/tests/ecma_6/extensions/DataView-construct-arguments-neutering.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!xulRuntime.shell) -- needs neuter() +// |reftest| skip-if(!xulRuntime.shell) -- needs detachArrayBuffer() /* * Any copyright is dedicated to the Public Domain. * http://creativecommons.org/licenses/publicdomain/ @@ -9,7 +9,7 @@ var gTestfile = "DataView-construct-arguments-neutering.js"; var BUGNUMBER = 991981; var summary = "new DataView(...) shouldn't misbehave horribly if index-argument " + - "conversion neuters the ArrayBuffer to be viewed"; + "conversion detaches the ArrayBuffer to be viewed"; print(BUGNUMBER + ": " + summary); @@ -25,7 +25,7 @@ function testByteOffset(dataType) { valueOf: function() { - neuter(ab, dataType); + detachArrayBuffer(ab, dataType); gc(); return 0x800; } @@ -41,7 +41,7 @@ function testByteOffset(dataType) ok = true; } assertEq(ok, true, "byteOffset weirdness should have thrown"); - assertEq(ab.byteLength, 0, "neutering should work for byteOffset weirdness"); + assertEq(ab.byteLength, 0, "detaching should work for byteOffset weirdness"); } testByteOffset("change-data"); testByteOffset("same-data"); @@ -54,7 +54,7 @@ function testByteLength(dataType) { valueOf: function() { - neuter(ab, dataType); + detachArrayBuffer(ab, dataType); gc(); return 0x800; } @@ -70,7 +70,7 @@ function testByteLength(dataType) ok = true; } assertEq(ok, true, "byteLength weirdness should have thrown"); - assertEq(ab.byteLength, 0, "neutering should work for byteLength weirdness"); + assertEq(ab.byteLength, 0, "detaching should work for byteLength weirdness"); } testByteLength("change-data"); testByteLength("same-data"); diff --git a/js/src/tests/ecma_6/extensions/DataView-set-arguments-neutering.js b/js/src/tests/ecma_6/extensions/DataView-set-arguments-neutering.js index fe7f9511ad..2eeb666857 100644 --- a/js/src/tests/ecma_6/extensions/DataView-set-arguments-neutering.js +++ b/js/src/tests/ecma_6/extensions/DataView-set-arguments-neutering.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!xulRuntime.shell) -- needs neuter() +// |reftest| skip-if(!xulRuntime.shell) -- needs detachArrayBuffer() /* * Any copyright is dedicated to the Public Domain. * http://creativecommons.org/licenses/publicdomain/ @@ -9,7 +9,7 @@ var gTestfile = "DataView-set-arguments-neutering.js"; var BUGNUMBER = 991981; var summary = "DataView.prototype.set* methods shouldn't misbehave horribly if " + - "index-argument conversion neuters the ArrayBuffer being modified"; + "index-argument conversion detaches the ArrayBuffer being modified"; print(BUGNUMBER + ": " + summary); @@ -27,7 +27,7 @@ function testIndex(dataType) { valueOf: function() { - neuter(ab, dataType); + detachArrayBuffer(ab, dataType); gc(); return 0xFFF; } @@ -43,7 +43,7 @@ function testIndex(dataType) ok = true; } assertEq(ok, true, "should have thrown"); - assertEq(ab.byteLength, 0, "should have been neutered correctly"); + assertEq(ab.byteLength, 0, "should have been detached correctly"); } testIndex("change-data"); testIndex("same-data"); @@ -58,7 +58,7 @@ function testValue(dataType) { valueOf: function() { - neuter(ab, dataType); + detachArrayBuffer(ab, dataType); gc(); return 0x42; } @@ -74,7 +74,7 @@ function testValue(dataType) ok = true; } assertEq(ok, true, "should have thrown"); - assertEq(ab.byteLength, 0, "should have been neutered correctly"); + assertEq(ab.byteLength, 0, "should have been detached correctly"); } testValue("change-data"); testValue("same-data"); diff --git a/js/src/tests/ecma_6/extensions/TypedArray-set-object-funky-length-neuters.js b/js/src/tests/ecma_6/extensions/TypedArray-set-object-funky-length-neuters.js index 768a1e7094..45d0e26fa7 100644 --- a/js/src/tests/ecma_6/extensions/TypedArray-set-object-funky-length-neuters.js +++ b/js/src/tests/ecma_6/extensions/TypedArray-set-object-funky-length-neuters.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!xulRuntime.shell) -- needs neuter() +// |reftest| skip-if(!xulRuntime.shell) -- needs detachArrayBuffer() /* * Any copyright is dedicated to the Public Domain. * http://creativecommons.org/licenses/publicdomain/ @@ -8,8 +8,9 @@ var gTestfile = "set-object-funky-length-neuters.js"; //----------------------------------------------------------------------------- var BUGNUMBER = 991981; var summary = - "%TypedArray.set(object with funky length property, numeric offset) " + - "shouldn't misbehave if the funky length property neuters this typed array"; + "%TypedArray%.prototype.set(object w/funky length property, offset) " + + "shouldn't misbehave if the funky length property detaches this typed " + + "array's buffer"; print(BUGNUMBER + ": " + summary); @@ -40,7 +41,7 @@ ctors.forEach(function(TypedArray) { 9: 0, get length() { - neuter(buf, dataHandling); + detachArrayBuffer(buf, dataHandling); return 10; } }; diff --git a/js/src/tests/ecma_6/extensions/TypedArray-subarray-arguments-neutering.js b/js/src/tests/ecma_6/extensions/TypedArray-subarray-arguments-neutering.js index faff6f1339..367c722177 100644 --- a/js/src/tests/ecma_6/extensions/TypedArray-subarray-arguments-neutering.js +++ b/js/src/tests/ecma_6/extensions/TypedArray-subarray-arguments-neutering.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!xulRuntime.shell) -- needs neuter() +// |reftest| skip-if(!xulRuntime.shell) -- needs detachArrayBuffer() /* * Any copyright is dedicated to the Public Domain. * http://creativecommons.org/licenses/publicdomain/ @@ -9,7 +9,7 @@ var gTestfile = "TypedArray-subarray-arguments-neutering.js"; var BUGNUMBER = 991981; var summary = "%TypedArray.prototype.subarray shouldn't misbehave horribly if " + - "index-argument conversion neuters the underlying ArrayBuffer"; + "index-argument conversion detaches the underlying ArrayBuffer"; print(BUGNUMBER + ": " + summary); @@ -25,7 +25,7 @@ function testBegin(dataType) { valueOf: function() { - neuter(ab, dataType); + detachArrayBuffer(ab, dataType); return 0x800; } }; @@ -42,7 +42,7 @@ function testBegin(dataType) ok = true; } assertEq(ok, true, "start weirdness should have thrown"); - assertEq(ab.byteLength, 0, "neutering should work for start weirdness"); + assertEq(ab.byteLength, 0, "detaching should work for start weirdness"); } testBegin("change-data"); testBegin("same-data"); @@ -55,7 +55,7 @@ function testBeginWithEnd(dataType) { valueOf: function() { - neuter(ab, dataType); + detachArrayBuffer(ab, dataType); return 0x800; } }; @@ -72,7 +72,7 @@ function testBeginWithEnd(dataType) ok = true; } assertEq(ok, true, "start weirdness should have thrown"); - assertEq(ab.byteLength, 0, "neutering should work for start weirdness"); + assertEq(ab.byteLength, 0, "detaching should work for start weirdness"); } testBeginWithEnd("change-data"); testBeginWithEnd("same-data"); @@ -85,7 +85,7 @@ function testEnd(dataType) { valueOf: function() { - neuter(ab, dataType); + detachArrayBuffer(ab, dataType); return 0x1000; } }; @@ -102,7 +102,7 @@ function testEnd(dataType) ok = true; } assertEq(ok, true, "start weirdness should have thrown"); - assertEq(ab.byteLength, 0, "neutering should work for start weirdness"); + assertEq(ab.byteLength, 0, "detaching should work for start weirdness"); } testEnd("change-data"); testEnd("same-data"); diff --git a/js/src/tests/ecma_6/extensions/element-setting-ToNumber-neuters.js b/js/src/tests/ecma_6/extensions/element-setting-ToNumber-neuters.js index fe6198ea5f..63a95a7025 100644 --- a/js/src/tests/ecma_6/extensions/element-setting-ToNumber-neuters.js +++ b/js/src/tests/ecma_6/extensions/element-setting-ToNumber-neuters.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!xulRuntime.shell) -- needs neuter() +// |reftest| skip-if(!xulRuntime.shell) -- needs detachArrayBuffer() /* * Any copyright is dedicated to the Public Domain. * http://creativecommons.org/licenses/publicdomain/ @@ -9,7 +9,7 @@ var gTestfile = 'element-setting-ToNumber-neuters.js'; //----------------------------------------------------------------------------- var BUGNUMBER = 1001547; var summary = - "Don't assert assigning into memory neutered while converting the value to " + + "Don't assert assigning into memory detached while converting the value to " + "assign into a number"; print(BUGNUMBER + ": " + summary); @@ -26,11 +26,11 @@ print(BUGNUMBER + ": " + summary); var ab1 = new ArrayBuffer(64); var ta1 = new Uint32Array(ab1); -ta1[4] = { valueOf: function() { neuter(ab1, "change-data"); return 5; } }; +ta1[4] = { valueOf() { detachArrayBuffer(ab1, "change-data"); return 5; } }; var ab2 = new ArrayBuffer(64); var ta2 = new Uint32Array(ab2); -ta2[4] = { valueOf: function() { neuter(ab2, "same-data"); return 5; } }; +ta2[4] = { valueOf() { detachArrayBuffer(ab2, "same-data"); return 5; } }; /******************************************************************************/ diff --git a/js/src/tests/ecma_7/TypedObject/map-neutered-midway.js b/js/src/tests/ecma_7/TypedObject/map-neutered-midway.js index b5b8e0a729..ab4c0f6171 100644 --- a/js/src/tests/ecma_7/TypedObject/map-neutered-midway.js +++ b/js/src/tests/ecma_7/TypedObject/map-neutered-midway.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty("TypedObject")||!xulRuntime.shell) -- needs TypedObject, neuter() +// |reftest| skip-if(!this.hasOwnProperty("TypedObject")||!xulRuntime.shell) -- needs TypedObject, detachArrayBuffer() /* * Any copyright is dedicated to the Public Domain. * http://creativecommons.org/licenses/publicdomain/ @@ -6,7 +6,8 @@ var BUGNUMBER = 991981; var summary = - "Behavior of mapping from an array neutered midway through mapping"; + "Behavior of mapping from an array whose buffer is detached midway through " + + "mapping"; function mapOneDimArrayOfUint8(dataHandling) { @@ -22,10 +23,10 @@ function mapOneDimArrayOfUint8(dataHandling) arr.map(function(v) { if (count++ > 0) - neuter(buf, dataHandling); + detachArrayBuffer(buf, dataHandling); return new FourByteArray(); }); - }, TypeError, "mapping of a neutered object worked?"); + }, TypeError, "mapping of a detached object worked?"); } function runTests() diff --git a/js/src/tests/js1_8_5/extensions/clone-transferables.js b/js/src/tests/js1_8_5/extensions/clone-transferables.js index 38cf84daee..56ebf15204 100644 --- a/js/src/tests/js1_8_5/extensions/clone-transferables.js +++ b/js/src/tests/js1_8_5/extensions/clone-transferables.js @@ -33,9 +33,12 @@ function test() { assertEq(old_arr.length, size / old_arr.BYTES_PER_ELEMENT); var copy_arr = deserialize(serialize(old_arr, [ buf ])); - assertEq(buf.byteLength, 0, "donor array buffer should be neutered"); - if (!dataview) - assertEq(old_arr.length, 0, "donor typed array should be neutered"); + assertEq(buf.byteLength, 0, + "donor array buffer should be detached"); + if (!dataview) { + assertEq(old_arr.length, 0, + "donor typed array should be detached"); + } assertEq(copy_arr.buffer.byteLength == size, true); if (!dataview) assertEq(copy_arr.length, size / old_arr.BYTES_PER_ELEMENT); @@ -52,11 +55,17 @@ function test() { var old_arr = new ctor(buf); var dv = new DataView(buf); // Second view var copy_arr = deserialize(serialize(old_arr, [ buf ])); - assertEq(buf.byteLength, 0, "donor array buffer should be neutered"); - assertEq(old_arr.byteLength, 0, "donor typed array should be neutered"); - if (!dataview) - assertEq(old_arr.length, 0, "donor typed array should be neutered"); - assertEq(dv.byteLength, 0, "all views of donor array buffer should be neutered"); + assertEq(buf.byteLength, 0, + "donor array buffer should be detached"); + assertEq(old_arr.byteLength, 0, + "donor typed array should be detached"); + if (!dataview) { + assertEq(old_arr.length, 0, + "donor typed array should be detached"); + } + assertEq(dv.byteLength, 0, + "all views of donor array buffer should have zero " + + "length because their underlying buffer is detached"); buf = null; old_arr = null; @@ -71,11 +80,12 @@ function test() { var mutator = { get foo() { view[0] = 2; } }; var copy = deserialize(serialize([ old, mutator ], [old])); var viewCopy = new Int32Array(copy[0]); - assertEq(view.length, 0); // Neutered + assertEq(view.length, 0); // Underlying buffer now detached. assertEq(viewCopy[0], 2); } - // Neuter the buffer during the clone operation. Should throw an exception. + // Detach the buffer during the clone operation. Should throw an + // exception. if (size >= 4) { old = new ArrayBuffer(size); var mutator = { diff --git a/js/src/tests/js1_8_5/extensions/typedarray-copyWithin-arguments-neutering.js b/js/src/tests/js1_8_5/extensions/typedarray-copyWithin-arguments-neutering.js index 2749c03bde..9923a653ac 100644 --- a/js/src/tests/js1_8_5/extensions/typedarray-copyWithin-arguments-neutering.js +++ b/js/src/tests/js1_8_5/extensions/typedarray-copyWithin-arguments-neutering.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!xulRuntime.shell) -- needs neuter() +// |reftest| skip-if(!xulRuntime.shell) -- needs detachArrayBuffer() /* * Any copyright is dedicated to the Public Domain. * http://creativecommons.org/licenses/publicdomain/ @@ -9,7 +9,7 @@ var gTestfile = "typedarray-copyWithin-arguments-neutering.js"; var BUGNUMBER = 991981; var summary = "%TypedArray.prototype.copyWithin shouldn't misbehave horribly if " + - "index-argument conversion neuters the underlying ArrayBuffer"; + "index-argument conversion detaches the underlying ArrayBuffer"; print(BUGNUMBER + ": " + summary); @@ -25,7 +25,7 @@ function testBegin(dataType) { valueOf: function() { - neuter(ab, dataType); + detachArrayBuffer(ab, dataType); return 0x800; } }; @@ -42,7 +42,7 @@ function testBegin(dataType) ok = true; } assertEq(ok, true, "start weirdness should have thrown"); - assertEq(ab.byteLength, 0, "neutering should work for start weirdness"); + assertEq(ab.byteLength, 0, "detaching should work for start weirdness"); } testBegin("change-data"); testBegin("same-data"); @@ -55,7 +55,7 @@ function testEnd(dataType) { valueOf: function() { - neuter(ab, dataType); + detachArrayBuffer(ab, dataType); return 0x1000; } }; @@ -72,7 +72,7 @@ function testEnd(dataType) ok = true; } assertEq(ok, true, "start weirdness should have thrown"); - assertEq(ab.byteLength, 0, "neutering should work for start weirdness"); + assertEq(ab.byteLength, 0, "detaching should work for start weirdness"); } testEnd("change-data"); testEnd("same-data"); @@ -85,7 +85,7 @@ function testDest(dataType) { valueOf: function() { - neuter(ab, dataType); + detachArrayBuffer(ab, dataType); return 0; } }; @@ -102,7 +102,7 @@ function testDest(dataType) ok = true; } assertEq(ok, true, "start weirdness should have thrown"); - assertEq(ab.byteLength, 0, "neutering should work for start weirdness"); + assertEq(ab.byteLength, 0, "detaching should work for start weirdness"); } testDest("change-data"); testDest("same-data"); diff --git a/js/src/tests/js1_8_5/extensions/typedarray-set-neutering.js b/js/src/tests/js1_8_5/extensions/typedarray-set-neutering.js index 742b88cc14..2fc4fc5fc2 100644 --- a/js/src/tests/js1_8_5/extensions/typedarray-set-neutering.js +++ b/js/src/tests/js1_8_5/extensions/typedarray-set-neutering.js @@ -30,7 +30,7 @@ var src1 = [ 10, 20, 30, 40, ]; Object.defineProperty(src1, 4, { get: function () { - neuter(ab1, "change-data"); + detachArrayBuffer(ab1, "change-data"); gc(); return 200; } @@ -58,7 +58,7 @@ var src2 = [ 10, 20, 30, 40, ]; Object.defineProperty(src2, 4, { get: function () { - neuter(ab2, "same-data"); + detachArrayBuffer(ab2, "same-data"); gc(); return 200; } diff --git a/layout/style/nsCSSPseudoClassList.h b/layout/style/nsCSSPseudoClassList.h index 5a73f71b82..7dcc8e390f 100644 --- a/layout/style/nsCSSPseudoClassList.h +++ b/layout/style/nsCSSPseudoClassList.h @@ -192,9 +192,6 @@ CSS_STATE_PSEUDO_CLASS(mozTypeUnsupportedPlatform, ":-moz-type-unsupported-platf CSS_STATE_PSEUDO_CLASS(mozHandlerClickToPlay, ":-moz-handler-clicktoplay", CSS_PSEUDO_CLASS_UA_SHEET_AND_CHROME, "", NS_EVENT_STATE_TYPE_CLICK_TO_PLAY) -CSS_STATE_PSEUDO_CLASS(mozHandlerPlayPreview, ":-moz-handler-playpreview", - CSS_PSEUDO_CLASS_UA_SHEET_AND_CHROME, "", - NS_EVENT_STATE_TYPE_PLAY_PREVIEW) CSS_STATE_PSEUDO_CLASS(mozHandlerVulnerableUpdatable, ":-moz-handler-vulnerable-updatable", CSS_PSEUDO_CLASS_UA_SHEET_AND_CHROME, "", NS_EVENT_STATE_VULNERABLE_UPDATABLE) diff --git a/memory/mozalloc/throw_gcc.h b/memory/mozalloc/throw_gcc.h index d055a28593..9385185640 100644 --- a/memory/mozalloc/throw_gcc.h +++ b/memory/mozalloc/throw_gcc.h @@ -74,40 +74,52 @@ __throw_bad_typeid(void) } // used by +#if !defined(_LIBCPP_VERSION) MOZ_THROW_NORETURN MOZ_THROW_EXPORT MOZ_THROW_INLINE void __throw_bad_function_call(void) { mozalloc_abort("fatal: STL threw bad_function_call"); } +#endif +#if !defined(_LIBCPP_VERSION) MOZ_THROW_NORETURN MOZ_THROW_EXPORT MOZ_ALWAYS_INLINE void __throw_logic_error(const char* msg) { mozalloc_abort(msg); } +#endif +#if !defined(_LIBCPP_VERSION) MOZ_THROW_NORETURN MOZ_THROW_EXPORT MOZ_ALWAYS_INLINE void __throw_domain_error(const char* msg) { mozalloc_abort(msg); } +#endif +#if !defined(_LIBCPP_VERSION) MOZ_THROW_NORETURN MOZ_THROW_EXPORT MOZ_ALWAYS_INLINE void __throw_invalid_argument(const char* msg) { mozalloc_abort(msg); } +#endif +#if !defined(_LIBCPP_VERSION) MOZ_THROW_NORETURN MOZ_THROW_EXPORT MOZ_ALWAYS_INLINE void __throw_length_error(const char* msg) { mozalloc_abort(msg); } +#endif +#if !defined(_LIBCPP_VERSION) MOZ_THROW_NORETURN MOZ_THROW_EXPORT MOZ_ALWAYS_INLINE void __throw_out_of_range(const char* msg) { mozalloc_abort(msg); } +#endif MOZ_THROW_NORETURN MOZ_THROW_EXPORT MOZ_ALWAYS_INLINE void __throw_runtime_error(const char* msg) diff --git a/testing/mochitest/Makefile.in b/testing/mochitest/Makefile.in index de93645be9..b07c011482 100644 --- a/testing/mochitest/Makefile.in +++ b/testing/mochitest/Makefile.in @@ -74,12 +74,18 @@ ifeq (Darwin,$(OS_TARGET)) TEST_HARNESS_PLUGINS := \ Test.plugin/ \ SecondTest.plugin/ \ + ThirdTest.plugin/ \ + npswftest.plugin/ \ + npctrltest.plugin/ \ JavaTest.plugin/ else TEST_HARNESS_PLUGINS := \ $(DLL_PREFIX)nptest$(DLL_SUFFIX) \ $(DLL_PREFIX)npsecondtest$(DLL_SUFFIX) \ - $(DLL_PREFIX)nptestjava$(DLL_SUFFIX) + $(DLL_PREFIX)npthirdtest$(DLL_SUFFIX) \ + $(DLL_PREFIX)nptestjava$(DLL_SUFFIX) \ + $(DLL_PREFIX)npswftest$(DLL_SUFFIX) \ + $(DLL_PREFIX)npctrltest$(DLL_SUFFIX) endif # Rules for staging the necessary harness bits for a test package diff --git a/testing/mochitest/tests/SimpleTest/SimpleTest.js b/testing/mochitest/tests/SimpleTest/SimpleTest.js index 2fc8736a84..70b8e5e18a 100644 --- a/testing/mochitest/tests/SimpleTest/SimpleTest.js +++ b/testing/mochitest/tests/SimpleTest/SimpleTest.js @@ -207,16 +207,6 @@ if (typeof(computedStyle) == 'undefined') { }; } -/** - * Check for OOP test plugin -**/ -SimpleTest.testPluginIsOOP = function () { - var testPluginIsOOP = false; - var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"] - .getService(SpecialPowers.Ci.nsIPluginHost); - return ph.isPluginOOP("application/x-test"); -}; - SimpleTest._tests = []; SimpleTest._stopOnLoad = true; SimpleTest._cleanupFunctions = []; diff --git a/toolkit/components/ctypes/tests/unit/test_jsctypes.js b/toolkit/components/ctypes/tests/unit/test_jsctypes.js index 0303e33470..7c6c9fd902 100644 --- a/toolkit/components/ctypes/tests/unit/test_jsctypes.js +++ b/toolkit/components/ctypes/tests/unit/test_jsctypes.js @@ -228,16 +228,16 @@ function run_test() function run_abstract_class_tests() { // Test that ctypes.CType is an abstract constructor that throws. - do_check_throws(function() { ctypes.CType(); }, Error); - do_check_throws(function() { new ctypes.CType() }, Error); + do_check_throws(function() { ctypes.CType(); }, TypeError); + do_check_throws(function() { new ctypes.CType() }, TypeError); // Test that classes and prototypes are set up correctly. do_check_class(ctypes.CType, "Function"); do_check_class(ctypes.CType.prototype, "CType"); do_check_true(ctypes.CType.hasOwnProperty("prototype")); - do_check_throws(function() { ctypes.CType.prototype(); }, Error); - do_check_throws(function() { new ctypes.CType.prototype() }, Error); + do_check_throws(function() { ctypes.CType.prototype(); }, TypeError); + do_check_throws(function() { new ctypes.CType.prototype() }, TypeError); do_check_true(ctypes.CType.prototype.hasOwnProperty("constructor")); do_check_true(ctypes.CType.prototype.constructor === ctypes.CType); @@ -257,7 +257,7 @@ function run_abstract_class_tests() do_check_throws(function() { ctypes.CType.prototype.name; }, TypeError); do_check_throws(function() { ctypes.CType.prototype.size; }, TypeError); do_check_throws(function() { ctypes.CType.prototype.ptr; }, TypeError); - do_check_throws(function() { ctypes.CType.prototype.array(); }, Error); + do_check_throws(function() { ctypes.CType.prototype.array(); }, TypeError); // toString and toSource are called by the web console during inspection, @@ -266,8 +266,8 @@ function run_abstract_class_tests() do_check_eq(typeof ctypes.CType.prototype.toSource(), 'string'); // Test that ctypes.CData is an abstract constructor that throws. - do_check_throws(function() { ctypes.CData(); }, Error); - do_check_throws(function() { new ctypes.CData() }, Error); + do_check_throws(function() { ctypes.CData(); }, TypeError); + do_check_throws(function() { new ctypes.CData() }, TypeError); // Test that classes and prototypes are set up correctly. do_check_class(ctypes.CData, "Function"); @@ -290,8 +290,8 @@ function run_abstract_class_tests() // Check that the shared properties and functions on ctypes.CData.prototype throw. do_check_throws(function() { ctypes.CData.prototype.value; }, TypeError); do_check_throws(function() { ctypes.CData.prototype.value = null; }, TypeError); - do_check_throws(function() { ctypes.CData.prototype.address(); }, Error); - do_check_throws(function() { ctypes.CData.prototype.readString(); }, Error); + do_check_throws(function() { ctypes.CData.prototype.address(); }, TypeError); + do_check_throws(function() { ctypes.CData.prototype.readString(); }, TypeError); // toString and toSource are called by the web console during inspection, // so we don't want them to throw. @@ -320,8 +320,8 @@ function run_Int64_tests() { do_check_true(ctypes.Int64.prototype.hasOwnProperty("toSource")); // Check that the shared functions on ctypes.Int64.prototype throw. - do_check_throws(function() { ctypes.Int64.prototype.toString(); }, Error); - do_check_throws(function() { ctypes.Int64.prototype.toSource(); }, Error); + do_check_throws(function() { ctypes.Int64.prototype.toString(); }, TypeError); + do_check_throws(function() { ctypes.Int64.prototype.toSource(); }, TypeError); let i = ctypes.Int64(0); do_check_true(i.__proto__ === ctypes.Int64.prototype); @@ -494,8 +494,8 @@ function run_UInt64_tests() { do_check_true(ctypes.UInt64.prototype.hasOwnProperty("toSource")); // Check that the shared functions on ctypes.UInt64.prototype throw. - do_check_throws(function() { ctypes.UInt64.prototype.toString(); }, Error); - do_check_throws(function() { ctypes.UInt64.prototype.toSource(); }, Error); + do_check_throws(function() { ctypes.UInt64.prototype.toString(); }, TypeError); + do_check_throws(function() { ctypes.UInt64.prototype.toSource(); }, TypeError); let i = ctypes.UInt64(0); do_check_true(i.__proto__ === ctypes.UInt64.prototype); @@ -759,8 +759,8 @@ function run_basic_class_tests(t) // Check that the shared properties and functions on 't.prototype' throw. do_check_throws(function() { t.prototype.value; }, TypeError); do_check_throws(function() { t.prototype.value = null; }, TypeError); - do_check_throws(function() { t.prototype.address(); }, Error); - do_check_throws(function() { t.prototype.readString(); }, Error); + do_check_throws(function() { t.prototype.address(); }, TypeError); + do_check_throws(function() { t.prototype.readString(); }, TypeError); // toString and toSource are called by the web console during inspection, // so we don't want them to throw. @@ -1308,7 +1308,7 @@ function run_type_ctor_class_tests(c, t, t2, props=[], fns=[], instanceProps=[], for (let p of props) do_check_throws(function() { c.prototype[p]; }, TypeError); for (let f of fns) - do_check_throws(function() { c.prototype[f](); }, Error); + do_check_throws(function() { c.prototype[f](); }, TypeError); // Test that classes and prototypes are set up correctly on a constructed // type 't'. @@ -1345,8 +1345,8 @@ function run_type_ctor_class_tests(c, t, t2, props=[], fns=[], instanceProps=[], do_check_throws(function() { t.prototype[p]; }, TypeError); } for (let f of instanceFns) { - do_check_throws(function() { t.prototype.__proto__[f]() }, Error); - do_check_throws(function() { t.prototype[f]() }, Error); + do_check_throws(function() { t.prototype.__proto__[f]() }, TypeError); + do_check_throws(function() { t.prototype[f]() }, TypeError); } // Check that 't.prototype' has the correct special properties. @@ -1355,7 +1355,7 @@ function run_type_ctor_class_tests(c, t, t2, props=[], fns=[], instanceProps=[], // Check that the shared special properties on 't.prototype' throw. for (let p of specialProps) - do_check_throws(function() { t.prototype[p]; }, Error); + do_check_throws(function() { t.prototype[p]; }, TypeError); // Make sure we can access 'prototype' on a CTypeProto. if (t instanceof ctypes.FunctionType) @@ -1387,25 +1387,25 @@ function run_StructType_tests() { // Check that malformed descriptors are an error. do_check_throws(function() { ctypes.StructType("a", [{"x":ctypes.int32_t}, {"x":ctypes.int8_t}]); - }, Error); + }, TypeError); do_check_throws(function() { ctypes.StructType("a", [5]); - }, Error); + }, TypeError); do_check_throws(function() { ctypes.StructType("a", [{}]); - }, Error); + }, TypeError); do_check_throws(function() { ctypes.StructType("a", [{5:ctypes.int32_t}]); - }, Error); + }, TypeError); do_check_throws(function() { ctypes.StructType("a", [{"5":ctypes.int32_t}]); - }, Error); + }, TypeError); do_check_throws(function() { ctypes.StructType("a", [{"x":5}]); - }, Error); + }, TypeError); do_check_throws(function() { ctypes.StructType("a", [{"x":ctypes.int32_t()}]); - }, Error); + }, TypeError); // Check that opaque structs work. let opaque_t = ctypes.StructType("a"); @@ -1433,19 +1433,19 @@ function run_StructType_tests() { // Check that 'define' works. do_check_throws(function() { opaque_t.define(); }, TypeError); do_check_throws(function() { opaque_t.define([], 0); }, TypeError); - do_check_throws(function() { opaque_t.define([{}]); }, Error); - do_check_throws(function() { opaque_t.define([{ a: 0 }]); }, Error); + do_check_throws(function() { opaque_t.define([{}]); }, TypeError); + do_check_throws(function() { opaque_t.define([{ a: 0 }]); }, TypeError); do_check_throws(function() { opaque_t.define([{ a: ctypes.int32_t, b: ctypes.int64_t }]); - }, Error); + }, TypeError); do_check_throws(function() { opaque_t.define([{ a: ctypes.int32_t }, { b: 0 }]); - }, Error); + }, TypeError); do_check_false(opaque_t.hasOwnProperty("prototype")); // Check that circular references work with opaque structs... // but not crazy ones. - do_check_throws(function() { opaque_t.define([{ b: opaque_t }]); }, Error); + do_check_throws(function() { opaque_t.define([{ b: opaque_t }]); }, TypeError); let circular_t = ctypes.StructType("circular", [{ a: opaqueptr_t }]); opaque_t.define([{ b: circular_t }]); let opaque = opaque_t(); @@ -1584,7 +1584,7 @@ function run_StructType_tests() { do_check_true(g_a.constructor === g_t.ptr); do_check_eq(g_a.contents.a, s.b.a); do_check_throws(function() { s.addressOfField(); }, TypeError); - do_check_throws(function() { s.addressOfField("d"); }, Error); + do_check_throws(function() { s.addressOfField("d"); }, TypeError); do_check_throws(function() { s.addressOfField("a", 2); }, TypeError); do_check_eq(s.toSource(), "s_t(4, {\"a\": 7, \"b\": 2}, 10)"); @@ -1645,10 +1645,10 @@ function run_StructType_tests() { // are illegal, but arrays of defined length work. do_check_throws(function() { ctypes.StructType("z_t", [{ a: ctypes.int32_t.array() }]); - }, Error); + }, TypeError); do_check_throws(function() { ctypes.StructType("z_t", [{ a: ctypes.int32_t.array(0) }]); - }, Error); + }, TypeError); z_t = ctypes.StructType("z_t", [{ a: ctypes.int32_t.array(6) }]); do_check_eq(z_t.size, ctypes.int32_t.size * 6); let z = z_t([1, 2, 3, 4, 5, 6]); @@ -1691,8 +1691,8 @@ function run_PointerType_tests() { let p = p_t(); do_check_throws(function() { p.value; }, TypeError); do_check_eq(ptrValue(p), 0); - do_check_throws(function() { p.contents; }, Error); - do_check_throws(function() { p.contents = g; }, Error); + do_check_throws(function() { p.contents; }, TypeError); + do_check_throws(function() { p.contents = g; }, TypeError); p = p_t(5); do_check_eq(ptrValue(p), 5); p = p_t(ctypes.UInt64(10)); @@ -1708,10 +1708,10 @@ function run_PointerType_tests() { do_check_eq(f_t.name, "FILE*"); do_check_eq(f_t.toSource(), 'ctypes.StructType("FILE").ptr'); let f = new f_t(); - do_check_throws(function() { f.contents; }, Error); - do_check_throws(function() { f.contents = 0; }, Error); + do_check_throws(function() { f.contents; }, TypeError); + do_check_throws(function() { f.contents = 0; }, TypeError); f = f_t(5); - do_check_throws(function() { f.contents = 0; }, Error); + do_check_throws(function() { f.contents = 0; }, TypeError); do_check_eq(f.toSource(), 'FILE.ptr(ctypes.UInt64("0x5"))'); do_check_throws(function() { f_t(p); }, TypeError); @@ -1754,7 +1754,7 @@ function run_PointerType_tests() { // but that the former cannot be dereferenced. let z_t = ctypes.int32_t.array().ptr; do_check_eq(ptrValue(z_t()), 0); - do_check_throws(function() { z_t().contents }, Error); + do_check_throws(function() { z_t().contents }, TypeError); z_t = ctypes.int32_t.array(0).ptr; do_check_eq(ptrValue(z_t()), 0); let z = ctypes.int32_t.array(0)().address(); @@ -1866,7 +1866,7 @@ function run_FunctionType_tests() { do_check_throws(function() { ctypes.FunctionType(); }, TypeError); do_check_throws(function() { ctypes.FunctionType(ctypes.default_abi, ctypes.void_t, [ ctypes.void_t ]); - }, Error); + }, TypeError); do_check_throws(function() { ctypes.FunctionType(ctypes.default_abi, ctypes.void_t, [ ctypes.void_t ], 5); }, TypeError); @@ -1878,7 +1878,7 @@ function run_FunctionType_tests() { }, TypeError); do_check_throws(function() { ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t()); - }, Error); + }, TypeError); do_check_throws(function() { ctypes.FunctionType(ctypes.void_t, ctypes.void_t); }, Error); @@ -1908,7 +1908,7 @@ function run_FunctionType_tests() { "ctypes.FunctionType(ctypes.default_abi, g_t).ptr"); // Check that constructing a FunctionType CData directly throws. - do_check_throws(function() { f_t(); }, Error); + do_check_throws(function() { f_t(); }, TypeError); // Test ExplicitConvert. let f = fp_t(); @@ -2016,9 +2016,9 @@ function run_ArrayType_tests() { a[0] = g; do_check_eq(a[0].a, 1); do_check_eq(a[0].b, 2); - do_check_throws(function() { a[-1]; }, Error); + do_check_throws(function() { a[-1]; }, TypeError); do_check_eq(a[9].a, 0); - do_check_throws(function() { a[10]; }, Error); + do_check_throws(function() { a[10]; }, RangeError); do_check_eq(a[ctypes.Int64(0)].a, 1); do_check_eq(a[ctypes.UInt64(0)].b, 2); @@ -2204,9 +2204,9 @@ function run_cast_tests() { do_check_eq(i.value, k.value); // Test casting to a type of undefined or larger size. - do_check_throws(function() { ctypes.cast(i, ctypes.void_t); }, Error); - do_check_throws(function() { ctypes.cast(i, ctypes.int32_t.array()); }, Error); - do_check_throws(function() { ctypes.cast(i, ctypes.int64_t); }, Error); + do_check_throws(function() { ctypes.cast(i, ctypes.void_t); }, TypeError); + do_check_throws(function() { ctypes.cast(i, ctypes.int32_t.array()); }, TypeError); + do_check_throws(function() { ctypes.cast(i, ctypes.int64_t); }, TypeError); // Test casting between special types. let g_t = ctypes.StructType("g_t", [{ a: ctypes.int32_t }, { b: ctypes.double }]); @@ -2244,7 +2244,7 @@ function run_void_tests(library) { // Test that library.declare throws with void function args. do_check_throws(function() { library.declare("test_void_t_cdecl", ctypes.default_abi, ctypes.void_t, ctypes.void_t); - }, Error); + }, TypeError); if ("winLastError" in ctypes) { test_void_t = library.declare("test_void_t_stdcall", ctypes.stdcall_abi, ctypes.void_t); diff --git a/toolkit/components/jsdownloads/src/DownloadCore.jsm b/toolkit/components/jsdownloads/src/DownloadCore.jsm index 558d1300f0..279daf74c3 100644 --- a/toolkit/components/jsdownloads/src/DownloadCore.jsm +++ b/toolkit/components/jsdownloads/src/DownloadCore.jsm @@ -1984,7 +1984,7 @@ this.DownloadCopySaver.prototype = { // Open the channel, directing output to the background file saver. backgroundFileSaver.QueryInterface(Ci.nsIStreamListener); - channel.asyncOpen({ + channel.asyncOpen2({ onStartRequest: function (aRequest, aContext) { backgroundFileSaver.onStartRequest(aRequest, aContext); @@ -2086,7 +2086,7 @@ this.DownloadCopySaver.prototype = { aInputStream, aOffset, aCount); }.bind(copySaver), - }, null); + }); // We should check if we have been canceled in the meantime, after // all the previous asynchronous operations have been executed and diff --git a/toolkit/components/jsdownloads/test/browser/.eslintrc b/toolkit/components/jsdownloads/test/browser/.eslintrc new file mode 100644 index 0000000000..be7c552e0c --- /dev/null +++ b/toolkit/components/jsdownloads/test/browser/.eslintrc @@ -0,0 +1,5 @@ +{ + "extends": [ + "../../../../../testing/mochitest/browser.eslintrc" + ] +} diff --git a/toolkit/components/jsdownloads/test/browser/head.js b/toolkit/components/jsdownloads/test/browser/head.js index 80af5a20bc..73fb8e88d8 100644 --- a/toolkit/components/jsdownloads/test/browser/head.js +++ b/toolkit/components/jsdownloads/test/browser/head.js @@ -12,10 +12,10 @@ //////////////////////////////////////////////////////////////////////////////// //// Globals -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; -const Cr = Components.results; +var Cc = Components.classes; +var Ci = Components.interfaces; +var Cu = Components.utils; +var Cr = Components.results; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); @@ -41,7 +41,7 @@ const TEST_TARGET_FILE_NAME_PDF = "test-download.pdf"; // used, on Windows these might still be pending deletion on the physical file // system. Thus, start from a new base number every time, to make a collision // with a file that is still pending deletion highly unlikely. -let gFileCounter = Math.floor(Math.random() * 1000000); +var gFileCounter = Math.floor(Math.random() * 1000000); /** * Returns a reference to a temporary file, that is guaranteed not to exist, and diff --git a/toolkit/components/jsdownloads/test/data/.eslintrc b/toolkit/components/jsdownloads/test/data/.eslintrc new file mode 100644 index 0000000000..8a895f93bd --- /dev/null +++ b/toolkit/components/jsdownloads/test/data/.eslintrc @@ -0,0 +1,5 @@ +{ + "extends": [ + "../../../../../testing/xpcshell/xpcshell.eslintrc" + ] +} diff --git a/toolkit/components/jsdownloads/test/unit/.eslintrc b/toolkit/components/jsdownloads/test/unit/.eslintrc new file mode 100644 index 0000000000..8a895f93bd --- /dev/null +++ b/toolkit/components/jsdownloads/test/unit/.eslintrc @@ -0,0 +1,5 @@ +{ + "extends": [ + "../../../../../testing/xpcshell/xpcshell.eslintrc" + ] +} diff --git a/toolkit/components/jsdownloads/test/unit/common_test_Download.js b/toolkit/components/jsdownloads/test/unit/common_test_Download.js index d382f645c1..8bedc32a62 100644 --- a/toolkit/components/jsdownloads/test/unit/common_test_Download.js +++ b/toolkit/components/jsdownloads/test/unit/common_test_Download.js @@ -123,7 +123,7 @@ function promisePartFileReady(aDownload) { * @resolves When the properties have been verified. * @rejects JavaScript exception. */ -let promiseVerifyTarget = Task.async(function* (downloadTarget, +var promiseVerifyTarget = Task.async(function* (downloadTarget, expectedContents) { yield promiseVerifyContents(downloadTarget.path, expectedContents); do_check_true(downloadTarget.exists); @@ -1708,7 +1708,7 @@ add_task(function* test_getSha256Hash() * @resolves The reputation blocked download. * @rejects JavaScript exception. */ -let promiseBlockedDownload = Task.async(function* (options) { +var promiseBlockedDownload = Task.async(function* (options) { function cleanup() { DownloadIntegration.shouldBlockInTestForApplicationReputation = false; DownloadIntegration.shouldKeepBlockedDataInTest = false; diff --git a/toolkit/components/jsdownloads/test/unit/test_DownloadCore.js b/toolkit/components/jsdownloads/test/unit/test_DownloadCore.js index f2b2a06884..d0e93b7954 100644 --- a/toolkit/components/jsdownloads/test/unit/test_DownloadCore.js +++ b/toolkit/components/jsdownloads/test/unit/test_DownloadCore.js @@ -15,9 +15,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "DownloadError", //////////////////////////////////////////////////////////////////////////////// //// Execution of common tests -let gUseLegacySaver = false; +var gUseLegacySaver = false; -let scriptFile = do_get_file("common_test_Download.js"); +var scriptFile = do_get_file("common_test_Download.js"); Services.scriptloader.loadSubScript(NetUtil.newURI(scriptFile).spec); //////////////////////////////////////////////////////////////////////////////// diff --git a/toolkit/components/jsdownloads/test/unit/test_DownloadImport.js b/toolkit/components/jsdownloads/test/unit/test_DownloadImport.js index 5f93f09822..404eca1f51 100644 --- a/toolkit/components/jsdownloads/test/unit/test_DownloadImport.js +++ b/toolkit/components/jsdownloads/test/unit/test_DownloadImport.js @@ -49,8 +49,8 @@ const TEST_DATA_PARTIAL_LENGTH = TEST_DATA_REPLACEMENT.length; // is seen when expected. const MAXBYTES_IN_DB = TEST_DATA_LENGTH - 10; -let gDownloadsRowToImport; -let gDownloadsRowNonImportable; +var gDownloadsRowToImport; +var gDownloadsRowNonImportable; /** * Creates a database with an empty moz_downloads table and leaves an diff --git a/toolkit/components/jsdownloads/test/unit/test_DownloadLegacy.js b/toolkit/components/jsdownloads/test/unit/test_DownloadLegacy.js index d4fdf934cb..bbe9b6d3ba 100644 --- a/toolkit/components/jsdownloads/test/unit/test_DownloadLegacy.js +++ b/toolkit/components/jsdownloads/test/unit/test_DownloadLegacy.js @@ -12,9 +12,9 @@ //////////////////////////////////////////////////////////////////////////////// //// Execution of common tests -let gUseLegacySaver = true; +var gUseLegacySaver = true; -let scriptFile = do_get_file("common_test_Download.js"); +var scriptFile = do_get_file("common_test_Download.js"); Services.scriptloader.loadSubScript(NetUtil.newURI(scriptFile).spec); //////////////////////////////////////////////////////////////////////////////// diff --git a/toolkit/components/lz4/tests/xpcshell/.eslintrc b/toolkit/components/lz4/tests/xpcshell/.eslintrc new file mode 100644 index 0000000000..8a895f93bd --- /dev/null +++ b/toolkit/components/lz4/tests/xpcshell/.eslintrc @@ -0,0 +1,5 @@ +{ + "extends": [ + "../../../../../testing/xpcshell/xpcshell.eslintrc" + ] +} diff --git a/toolkit/components/lz4/tests/xpcshell/data/worker_lz4.js b/toolkit/components/lz4/tests/xpcshell/data/worker_lz4.js index d98a2b5e68..312cd69b3f 100644 --- a/toolkit/components/lz4/tests/xpcshell/data/worker_lz4.js +++ b/toolkit/components/lz4/tests/xpcshell/data/worker_lz4.js @@ -41,8 +41,8 @@ self.onmessage = function() { } }; -let Lz4; -let Internals; +var Lz4; +var Internals; function test_import() { Lz4 = require("resource://gre/modules/lz4.js"); Internals = require("resource://gre/modules/lz4_internal.js"); diff --git a/toolkit/components/lz4/tests/xpcshell/test_lz4.js b/toolkit/components/lz4/tests/xpcshell/test_lz4.js index bf08b0696d..8a8fc0b21a 100644 --- a/toolkit/components/lz4/tests/xpcshell/test_lz4.js +++ b/toolkit/components/lz4/tests/xpcshell/test_lz4.js @@ -3,7 +3,7 @@ Components.utils.import("resource://gre/modules/Promise.jsm"); -let WORKER_SOURCE_URI = "chrome://test_lz4/content/worker_lz4.js"; +var WORKER_SOURCE_URI = "chrome://test_lz4/content/worker_lz4.js"; do_load_manifest("data/chrome.manifest"); function run_test() { diff --git a/toolkit/components/mediasniffer/test/unit/.eslintrc b/toolkit/components/mediasniffer/test/unit/.eslintrc new file mode 100644 index 0000000000..8a895f93bd --- /dev/null +++ b/toolkit/components/mediasniffer/test/unit/.eslintrc @@ -0,0 +1,5 @@ +{ + "extends": [ + "../../../../../testing/xpcshell/xpcshell.eslintrc" + ] +} diff --git a/toolkit/components/mediasniffer/test/unit/test_mediasniffer.js b/toolkit/components/mediasniffer/test/unit/test_mediasniffer.js index 12f4f999c8..5c538859f1 100644 --- a/toolkit/components/mediasniffer/test/unit/test_mediasniffer.js +++ b/toolkit/components/mediasniffer/test/unit/test_mediasniffer.js @@ -2,8 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -const Ci = Components.interfaces; -const Cu = Components.utils; +var Ci = Components.interfaces; +var Cu = Components.utils; Cu.import("resource://testing-common/httpd.js"); Cu.import("resource://gre/modules/Services.jsm"); diff --git a/toolkit/components/mediasniffer/test/unit/test_mediasniffer_ext.js b/toolkit/components/mediasniffer/test/unit/test_mediasniffer_ext.js index 492d53acd2..2f2693d449 100644 --- a/toolkit/components/mediasniffer/test/unit/test_mediasniffer_ext.js +++ b/toolkit/components/mediasniffer/test/unit/test_mediasniffer_ext.js @@ -2,10 +2,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -const Ci = Components.interfaces; -const Cu = Components.utils; -const Cc = Components.classes; -const CC = Components.Constructor; +var Ci = Components.interfaces; +var Cu = Components.utils; +var Cc = Components.classes; +var CC = Components.Constructor; var BinaryOutputStream = CC("@mozilla.org/binaryoutputstream;1", "nsIBinaryOutputStream", diff --git a/toolkit/components/osfile/modules/osfile_async_front.jsm b/toolkit/components/osfile/modules/osfile_async_front.jsm index 29838b38aa..062d2fb0c3 100644 --- a/toolkit/components/osfile/modules/osfile_async_front.jsm +++ b/toolkit/components/osfile/modules/osfile_async_front.jsm @@ -1176,7 +1176,7 @@ File.writeAtomic = function writeAtomic(path, buffer, options = {}) { let promise = Scheduler.post("writeAtomic", [Type.path.toMsg(path), Type.void_t.in_ptr.toMsg(buffer), - options], [options, buffer]); + options], [options, buffer, path]); TelemetryStopwatch.finish("OSFILE_WRITEATOMIC_JANK_MS", refObj); return promise; }; @@ -1459,11 +1459,16 @@ Object.defineProperty(OS.File, "queue", { } }); +// `true` if this is a content process, `false` otherwise. +// It would be nicer to go through `Services.appInfo`, but some tests need to be +// able to replace that field with a custom implementation before it is first +// called. +const isContent = Components.classes["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT; + /** * Shutdown barriers, to let clients register to be informed during shutdown. */ var Barriers = { - profileBeforeChange: new AsyncShutdown.Barrier("OS.File: Waiting for clients before profile-before-shutdown"), shutdown: new AsyncShutdown.Barrier("OS.File: Waiting for clients before full shutdown"), /** * Return the shutdown state of OS.File @@ -1491,25 +1496,35 @@ var Barriers = { } }; -File.profileBeforeChange = Barriers.profileBeforeChange.client; +function setupShutdown(phaseName) { + Barriers[phaseName] = new AsyncShutdown.Barrier(`OS.File: Waiting for clients before ${phaseName}`), + File[phaseName] = Barriers[phaseName].client; + + // Auto-flush OS.File during `phaseName`. This ensures that any I/O + // that has been queued *before* `phaseName` is properly completed. + // To ensure that I/O queued *during* `phaseName` change is completed, + // clients should register using AsyncShutdown.addBlocker. + AsyncShutdown[phaseName].addBlocker( + `OS.File: flush I/O queued before ${phaseName}`, + Task.async(function*() { + // Give clients a last chance to enqueue requests. + yield Barriers[phaseName].wait({crashAfterMS: null}); + + // Wait until all currently enqueued requests are completed. + yield Scheduler.queue; + }), + () => { + let details = Barriers.getDetails(); + details.clients = Barriers[phaseName].state; + return details; + } + ); +} + + +if (isContent) { + setupShutdown("contentChildShutdown"); +} else { + setupShutdown("profileBeforeChange") +} File.shutdown = Barriers.shutdown.client; - -// Auto-flush OS.File during profile-before-change. This ensures that any I/O -// that has been queued *before* profile-before-change is properly completed. -// To ensure that I/O queued *during* profile-before-change is completed, -// clients should register using AsyncShutdown.addBlocker. -AsyncShutdown.profileBeforeChange.addBlocker( - "OS.File: flush I/O queued before profile-before-change", - Task.async(function*() { - // Give clients a last chance to enqueue requests. - yield Barriers.profileBeforeChange.wait({crashAfterMS: null}); - - // Wait until all currently enqueued requests are completed. - yield Scheduler.queue; - }), - () => { - let details = Barriers.getDetails(); - details.clients = Barriers.profileBeforeChange.state; - return details; - } -); diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 90eea15cfb..9f6f6c0215 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -7278,8 +7278,50 @@ "BROWSER_IS_USER_DEFAULT": { "expires_in_version": "never", "kind": "boolean", + "releaseChannelCollection": "opt-out", "description": "The result of the startup default desktop browser check." }, + "BROWSER_IS_USER_DEFAULT_ERROR": { + "expires_in_version": "never", + "kind": "boolean", + "releaseChannelCollection": "opt-out", + "description": "True if the browser was unable to determine if the browser was set as default." + }, + "BROWSER_SET_DEFAULT_DIALOG_PROMPT_RAWCOUNT": { + "expires_in_version": "never", + "kind": "exponential", + "high": "250", + "n_buckets": "15", + "releaseChannelCollection": "opt-out", + "description": "The number of times that a profile has seen the 'Set Default Browser' dialog." + }, + "BROWSER_SET_DEFAULT_ALWAYS_CHECK": { + "expires_in_version": "never", + "kind": "boolean", + "releaseChannelCollection": "opt-out", + "description": "True if the profile has `browser.shell.checkDefaultBrowser` set to true." + }, + "BROWSER_SET_DEFAULT_RESULT": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": "4", + "releaseChannelCollection": "opt-out", + "description": "Result of the Set Default Browser dialog (0=Use Firefox + 'Always perform check' unchecked, 1=Use Firefox + 'Always perform check' checked, 2=Not Now + 'Always perform check' unchecked, 3=Not Now + 'Always perform check' checked)" + }, + "BROWSER_SET_DEFAULT_ERROR": { + "expires_in_version": "never", + "kind": "boolean", + "releaseChannelCollection": "opt-out", + "description": "True if the browser was unable to set Firefox as the default browser" + }, + "BROWSER_SET_DEFAULT_TIME_TO_COMPLETION_SECONDS": { + "expires_in_version": "never", + "kind": "exponential", + "high": "500", + "n_buckets": "15", + "releaseChannelCollection": "opt-out", + "description": "Time to successfully set Firefox as the default browser after clicking 'Set Firefox as Default'. Should be near-instant in some environments, others require user interaction. Measured in seconds." + }, "BROWSER_IS_ASSIST_DEFAULT": { "expires_in_version": "never", "kind": "boolean", diff --git a/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js b/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js index b22b19e2c8..a7900b84cf 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js +++ b/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js @@ -27,6 +27,8 @@ const BACKOFF_MAX = 8 * 60 * 60 * 1000; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/NetUtil.jsm"); + // Log only if browser.safebrowsing.debug is true function log(...stuff) { @@ -236,13 +238,10 @@ HashCompleterRequest.prototype = { let loadFlags = Ci.nsIChannel.INHIBIT_CACHING | Ci.nsIChannel.LOAD_BYPASS_CACHE; - let uri = Services.io.newURI(this.gethashUrl, null, null); - let channel = Services.io.newChannelFromURI2(uri, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel = NetUtil.newChannel({ + uri: this.gethashUrl, + loadUsingSystemPrincipal: true + }); channel.loadFlags = loadFlags; // Disable keepalive. @@ -261,7 +260,7 @@ HashCompleterRequest.prototype = { let timeout = Services.prefs.getIntPref( "urlclassifier.gethash.timeout_ms"); this.timer_.initWithCallback(this, timeout, this.timer_.TYPE_ONE_SHOT); - channel.asyncOpen(this, null); + channel.asyncOpen2(this); }, // Returns a string for the request body based on the contents of diff --git a/toolkit/profile/nsIToolkitProfileService.idl b/toolkit/profile/nsIToolkitProfileService.idl index bc0606ca1f..46a5b3cbc1 100644 --- a/toolkit/profile/nsIToolkitProfileService.idl +++ b/toolkit/profile/nsIToolkitProfileService.idl @@ -10,7 +10,7 @@ interface nsIFile; interface nsIToolkitProfile; interface nsIProfileLock; -[scriptable, uuid(b81c33a6-1ce8-4695-856b-02b7f15cc114)] +[scriptable, uuid(1947899b-f369-48fa-89da-f7c37bb1e6bc)] interface nsIToolkitProfileService : nsISupports { attribute boolean startWithLastProfile; @@ -79,23 +79,17 @@ interface nsIToolkitProfileService : nsISupports * * @note Either aProfileName or aAppName must be non-empty * - * The contents of aProfileDefaultsDir will be copied to the - * new profile directory. - * * @param aProfileName * The name of the profile * @param aAppName * The name of the application * @param aVendorName * The name of the vendor - * @param aProfileDefaultsDir - * The location where the profile defaults are. * @return The created profile. */ nsIToolkitProfile createDefaultProfileForApp(in AUTF8String aProfileName, in AUTF8String aAppName, - in AUTF8String aVendorName, - [optional] in nsIFile aProfileDefaultsDir); + in AUTF8String aVendorName); /** * Returns the number of profiles. diff --git a/toolkit/profile/nsToolkitProfileService.cpp b/toolkit/profile/nsToolkitProfileService.cpp index 4bfc0dc204..f1ffdb5b2e 100644 --- a/toolkit/profile/nsToolkitProfileService.cpp +++ b/toolkit/profile/nsToolkitProfileService.cpp @@ -135,7 +135,6 @@ private: const nsACString* aProfileName, const nsACString* aAppName, const nsACString* aVendorName, - /*in*/ nsIFile** aProfileDefaultsDir, bool aForExternalApp, nsIToolkitProfile** aResult); @@ -709,7 +708,6 @@ NS_IMETHODIMP nsToolkitProfileService::CreateDefaultProfileForApp(const nsACString& aProfileName, const nsACString& aAppName, const nsACString& aVendorName, - nsIFile* aProfileDefaultsDir, nsIToolkitProfile** aResult) { NS_ENSURE_STATE(!aProfileName.IsEmpty() || !aAppName.IsEmpty()); @@ -731,11 +729,10 @@ nsToolkitProfileService::CreateDefaultProfileForApp(const nsACString& aProfileNa profilesini->Exists(&exists); NS_ENSURE_FALSE(exists, NS_ERROR_ALREADY_INITIALIZED); - nsIFile* profileDefaultsDir = aProfileDefaultsDir; rv = CreateProfileInternal(nullptr, NS_LITERAL_CSTRING("default"), &aProfileName, &aAppName, &aVendorName, - &profileDefaultsDir, true, aResult); + true, aResult); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_STATE(*aResult); @@ -778,7 +775,7 @@ nsToolkitProfileService::CreateProfile(nsIFile* aRootDir, nsIToolkitProfile** aResult) { return CreateProfileInternal(aRootDir, aName, - nullptr, nullptr, nullptr, nullptr, false, aResult); + nullptr, nullptr, nullptr, false, aResult); } nsresult @@ -787,7 +784,6 @@ nsToolkitProfileService::CreateProfileInternal(nsIFile* aRootDir, const nsACString* aProfileName, const nsACString* aAppName, const nsACString* aVendorName, - nsIFile** aProfileDefaultsDir, bool aForExternalApp, nsIToolkitProfile** aResult) { @@ -849,7 +845,6 @@ nsToolkitProfileService::CreateProfileInternal(nsIFile* aRootDir, return NS_ERROR_FILE_NOT_DIRECTORY; } else { - nsCOMPtr profileDefaultsDir; nsCOMPtr profileDirParent; nsAutoString profileDirName; @@ -859,22 +854,9 @@ nsToolkitProfileService::CreateProfileInternal(nsIFile* aRootDir, rv = rootDir->GetLeafName(profileDirName); NS_ENSURE_SUCCESS(rv, rv); - if (aProfileDefaultsDir) { - profileDefaultsDir = *aProfileDefaultsDir; - } else { - bool dummy; - rv = gDirServiceProvider->GetFile(NS_APP_PROFILE_DEFAULTS_50_DIR, &dummy, - getter_AddRefs(profileDefaultsDir)); - } - - if (NS_SUCCEEDED(rv) && profileDefaultsDir) - rv = profileDefaultsDir->CopyTo(profileDirParent, - profileDirName); - if (NS_FAILED(rv) || !profileDefaultsDir) { - // if copying failed, lets just ensure that the profile directory exists. - rv = rootDir->Create(nsIFile::DIRECTORY_TYPE, 0700); - NS_ENSURE_SUCCESS(rv, rv); - } + // let's ensure that the profile directory exists. + rv = rootDir->Create(nsIFile::DIRECTORY_TYPE, 0700); + NS_ENSURE_SUCCESS(rv, rv); rv = rootDir->SetPermissions(0700); #ifndef ANDROID // If the profile is on the sdcard, this will fail but its non-fatal