Bug 1295103 - Use MOZ_MUST_USE in OriginAttributes. r=allstars

MozReview-Commit-ID: PWUb81L8ya

--HG--
extra : rebase_source : 2bdc7adc7a6b5fd121a4621086fab6f87834dd20
This commit is contained in:
Kan-Ru Chen 2016-08-15 18:22:44 +08:00
parent f221acffb2
commit 29b9a17a92
3 changed files with 8 additions and 4 deletions

View File

@ -11,6 +11,7 @@
#include "nsIScriptSecurityManager.h"
#include "nsJSPrincipals.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/ChromeUtilsBinding.h"
class nsIContentSecurityPolicy;
@ -45,11 +46,11 @@ public:
// |!key1=value1&key2=value2|. If there are no non-default attributes, this
// returns an empty string.
void CreateSuffix(nsACString& aStr) const;
bool PopulateFromSuffix(const nsACString& aStr);
MOZ_MUST_USE bool PopulateFromSuffix(const nsACString& aStr);
// Populates the attributes from a string like
// |uri!key1=value1&key2=value2| and returns the uri without the suffix.
bool PopulateFromOrigin(const nsACString& aOrigin,
MOZ_MUST_USE bool PopulateFromOrigin(const nsACString& aOrigin,
nsACString& aOriginNoSuffix);
// Helper function to match mIsPrivateBrowsing to existing private browsing

View File

@ -139,7 +139,9 @@ ReadSuffixAndSpec(JSStructuredCloneReader* aReader,
return false;
}
aAttrs.PopulateFromSuffix(suffix);
if (!aAttrs.PopulateFromSuffix(suffix)) {
return false;
}
aSpec.SetLength(specLength);
if (!JS_ReadBytes(aReader, aSpec.BeginWriting(), specLength)) {

View File

@ -13,7 +13,8 @@ TestSuffix(const PrincipalOriginAttributes& attrs)
attrs.CreateSuffix(suffix);
PrincipalOriginAttributes attrsFromSuffix;
attrsFromSuffix.PopulateFromSuffix(suffix);
bool success = attrsFromSuffix.PopulateFromSuffix(suffix);
EXPECT_TRUE(success);
EXPECT_EQ(attrs, attrsFromSuffix);
}