MozReview-Commit-ID: IffTwuMbwmG
This commit is contained in:
Phil Ringnalda 2016-10-03 20:09:05 -07:00
Родитель 3ed3aaaf19 5739609d11
Коммит c1e745733c
160 изменённых файлов: 1827 добавлений и 1138 удалений

Просмотреть файл

@ -22,4 +22,4 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more.
Bug 1280590 - xpcshell failure in windows7
Bug 1302855 changed build system to fold browsercomps into xul

Просмотреть файл

@ -291,14 +291,20 @@ EventTree::FindOrInsert(Accessible* aContainer)
AccMutationEvent* ev = node->mDependentEvents[idx];
if (ev->GetAccessible() == parent) {
#ifdef A11Y_LOG
if (logging::IsEnabledAll(logging::eEventTree |
logging::eVerbose)) {
if (logging::IsEnabled(logging::eEventTree)) {
logging::MsgBegin("EVENTS_TREE",
"Rejecting node since contained by show/hide target");
logging::AccessibleInfo("Container", aContainer);
"Rejecting node contained by show/hide");
logging::AccessibleInfo("Node", aContainer);
logging::MsgEnd();
}
#endif
// If the node is rejected, then check if it has related hide event
// on stack, and if so, then connect it to the parent show event.
if (ev->IsShow()) {
AccShowEvent* showEv = downcast_accEvent(ev);
Controller(aContainer)->
WithdrawPrecedingEvents(&showEv->mPrecedingEvents);
}
return nullptr;
}
}

Просмотреть файл

@ -559,13 +559,14 @@
}
/**
* Move 't9_c2_moved' node by aria-owns, and then move 't9_c3_moved' node
* under 't9_c2_moved' (same as test9 but has different aria-owns
* ordering), the eventing looks same way as in test9:
* Move 't9_c3_moved' node under 't9_c2_moved', and then move 't9_c2_moved'
* node by aria-owns (same as test10 but has different aria-owns
* ordering), the eventing looks same way as in test10:
* reorder for 't9_c1'
* hide for 't9_c1_child'
* show for 't9_c2_moved'
* reorder for 't9_c2'
* hide for 't9_c2_child'
* hide for 't9_c2_moved'
* reorder for 't9_c3'
* hide for 't9_c3_moved'
@ -604,6 +605,51 @@
};
}
/**
* Move a node 't10_c3_moved' by aria-owns under a node 't10_c2_moved',
* moved by under 't10_1', so that the eventing looks this way:
* reorder for 't10_c1'
* hide for 't10_c1_child'
* show for 't10_c2_moved'
* reorder for 't10_c2'
* hide for 't10_c2_child'
* hide for 't10_c2_moved'
* reorder for 't10_c3'
* hide for 't10_c3_moved'
*
* The hide events for 't10_c2_moved' and 't10_c3_moved' should be delivered
* before the show event for 't10_c2_moved'.
*/
function test10()
{
this.eventSeq = [
new invokerChecker(EVENT_HIDE, getNode('t10_c1_child')),
new invokerChecker(EVENT_HIDE, getNode('t10_c2_moved')),
new invokerChecker(EVENT_HIDE, getNode('t10_c3_moved')),
new invokerChecker(EVENT_SHOW, getNode('t10_c2_moved')),
new invokerChecker(EVENT_REORDER, 't10_c1'),
new invokerChecker(EVENT_HIDE, getNode('t10_c2_child')),
new invokerChecker(EVENT_REORDER, 't10_c2'),
new invokerChecker(EVENT_REORDER, 't10_c3')
];
this.invoke = function test10_invoke()
{
// Remove child nodes from 't10_c1' and 't10_c2' containers to give
// the event tree a needed structure ('t10_c1' and 't10_c2' nodes go first
// in the event tree),
getNode('t10_c1_child').remove();
getNode('t10_c2_child').remove();
// then do aria-owns stuff.
getNode('t10_c1').setAttribute('aria-owns', 't10_c2_moved');
getNode('t10_c2_moved').setAttribute('aria-owns', 't10_c3_moved');
};
this.getID = function test10_getID() {
return "Move a node by aria-owns into a node moved by aria-owns to left within the tree";
};
}
////////////////////////////////////////////////////////////////////////////
// Do tests.
@ -639,6 +685,7 @@
gQueue.push(new test7());
gQueue.push(new test8());
gQueue.push(new test9());
gQueue.push(new test10());
gQueue.invoke(); // Will call SimpleTest.finish();
}
@ -757,5 +804,16 @@
<div id="t9_c3_moved"></div>
</div>
</div>
<div id="t10">
<div id="t10_c1"><div id="t10_c1_child"></div></div>
<div id="t10_c2">
<div id="t10_c2_child"></div>
<div id="t10_c2_moved"></div>
</div>
<div id="t10_c3">
<div id="t10_c3_moved"></div>
</div>
</div>
</body>
</html>

Просмотреть файл

@ -361,8 +361,8 @@
function showHiddenParentOfVisibleChild()
{
this.eventSeq = [
new invokerChecker(EVENT_SHOW, getNode("c4_middle")),
new invokerChecker(EVENT_HIDE, getNode("c4_child")),
new invokerChecker(EVENT_SHOW, getNode("c4_middle")),
new invokerChecker(EVENT_REORDER, getNode("c4"))
];

Просмотреть файл

@ -12,7 +12,8 @@ SOURCES += [
'nsModule.cpp',
]
XPCOMBinaryComponent('browsercomps')
Library('browsercomps')
FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [
'../about',
@ -21,22 +22,3 @@ LOCAL_INCLUDES += [
'../migration',
'../shell',
]
if CONFIG['OS_ARCH'] == 'WINNT':
OS_LIBS += [
'esent',
'netapi32',
'ole32',
'shell32',
'shlwapi',
'version',
]
DELAYLOAD_DLLS += [
'esent.dll',
'netapi32.dll',
]
# Mac: Need to link with CoreFoundation for Mac Migrators (PList reading code)
# GTK2: Need to link with glib for GNOME shell service
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'gtk2', 'gtk3'):
OS_LIBS += CONFIG['TK_LIBS']

Просмотреть файл

@ -20,7 +20,7 @@
#include "nsDirectoryServiceUtils.h"
#include "mozilla/ModuleUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsStringAPI.h"
#include "nsString.h"
#include "nsXULAppAPI.h"
#include "nsIPrefLocalizedString.h"

Просмотреть файл

@ -185,9 +185,15 @@ IsDocumentElement(const char *start, const char* end)
static bool
ContainsTopLevelSubstring(nsACString& dataString, const char *substring)
{
int32_t offset = dataString.Find(substring);
if (offset == -1)
nsACString::const_iterator start, end;
dataString.BeginReading(start);
dataString.EndReading(end);
if (!FindInReadable(nsCString(substring), start, end)){
return false;
}
auto offset = start.get() - dataString.Data();
const char *begin = dataString.BeginReading();
@ -312,9 +318,10 @@ nsFeedSniffer::GetMIMETypeFromContent(nsIRequest* request,
// RSS 1.0
if (!isFeed) {
bool foundNS_RDF = FindInReadable(NS_LITERAL_CSTRING(NS_RDF), dataString);
bool foundNS_RSS = FindInReadable(NS_LITERAL_CSTRING(NS_RSS), dataString);
isFeed = ContainsTopLevelSubstring(dataString, "<rdf:RDF") &&
dataString.Find(NS_RDF) != -1 &&
dataString.Find(NS_RSS) != -1;
foundNS_RDF && foundNS_RSS;
}
// If we sniffed a feed, coerce our internal type

Просмотреть файл

@ -6,7 +6,7 @@
#include "nsIContentSniffer.h"
#include "nsIStreamListener.h"
#include "nsStringAPI.h"
#include "nsString.h"
#include "mozilla/Attributes.h"
class nsFeedSniffer final : public nsIContentSniffer,

Просмотреть файл

@ -9,9 +9,10 @@
#include "nsArrayEnumerator.h"
#include "nsCOMArray.h"
#include "nsIURI.h"
#include "nsIVariant.h"
#include "nsNetUtil.h"
#include "nsStringAPI.h"
#include "nsString.h"
#include "nsWindowsMigrationUtils.h"
#include "prtime.h"
@ -22,7 +23,7 @@ NS_IMPL_ISUPPORTS(nsIEHistoryEnumerator, nsISimpleEnumerator)
nsIEHistoryEnumerator::nsIEHistoryEnumerator()
{
::CoInitialize(nullptr);
::CoInitialize(nullptr);
}
nsIEHistoryEnumerator::~nsIEHistoryEnumerator()

Просмотреть файл

@ -14,7 +14,7 @@
#include "nsDirectoryServiceDefs.h"
#include "nsIPrefService.h"
#include "prenv.h"
#include "nsStringAPI.h"
#include "nsString.h"
#include "nsIGConfService.h"
#include "nsIGIOService.h"
#include "nsIGSettingsService.h"
@ -70,16 +70,16 @@ static const MimeTypeAssociation appTypes[] = {
// GConf registry key constants
#define DG_BACKGROUND "/desktop/gnome/background"
static const char kDesktopImageKey[] = DG_BACKGROUND "/picture_filename";
static const char kDesktopOptionsKey[] = DG_BACKGROUND "/picture_options";
static const char kDesktopDrawBGKey[] = DG_BACKGROUND "/draw_background";
static const char kDesktopColorKey[] = DG_BACKGROUND "/primary_color";
#define kDesktopImageKey DG_BACKGROUND "/picture_filename"
#define kDesktopOptionsKey DG_BACKGROUND "/picture_options"
#define kDesktopDrawBGKey DG_BACKGROUND "/draw_background"
#define kDesktopColorKey DG_BACKGROUND "/primary_color"
static const char kDesktopBGSchema[] = "org.gnome.desktop.background";
static const char kDesktopImageGSKey[] = "picture-uri";
static const char kDesktopOptionGSKey[] = "picture-options";
static const char kDesktopDrawBGGSKey[] = "draw-background";
static const char kDesktopColorGSKey[] = "primary-color";
#define kDesktopBGSchema "org.gnome.desktop.background"
#define kDesktopImageGSKey "picture-uri"
#define kDesktopOptionGSKey "picture-options"
#define kDesktopDrawBGGSKey "draw-background"
#define kDesktopColorGSKey "primary-color"
nsresult
nsGNOMEShellService::Init()
@ -508,7 +508,8 @@ static void
ColorToCString(uint32_t aColor, nsCString& aResult)
{
// The #rrrrggggbbbb format is used to match gdk_color_to_string()
char *buf = aResult.BeginWriting(13);
aResult.SetLength(13);
char *buf = aResult.BeginWriting();
if (!buf)
return;

Просмотреть файл

@ -7,7 +7,7 @@
#define nsgnomeshellservice_h____
#include "nsIGNOMEShellService.h"
#include "nsStringAPI.h"
#include "nsString.h"
#include "mozilla/Attributes.h"
class nsGNOMEShellService final : public nsIGNOMEShellService

Просмотреть файл

@ -20,7 +20,7 @@
#include "nsIProperties.h"
#include "nsServiceManagerUtils.h"
#include "nsShellService.h"
#include "nsStringAPI.h"
#include "nsString.h"
#include "nsIDocShell.h"
#include "nsILoadContext.h"

Просмотреть файл

@ -12,6 +12,7 @@
#include "nsIDOMElement.h"
#include "nsIDOMHTMLImageElement.h"
#include "nsIImageLoadingContent.h"
#include "nsIOutputStream.h"
#include "nsIPrefService.h"
#include "nsIPrefLocalizedString.h"
#include "nsIServiceManager.h"
@ -465,7 +466,7 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
return NS_OK;
}
res = ::RegOpenKeyExW(HKEY_CLASSES_ROOT, PromiseFlatString(keyName).get(),
res = ::RegOpenKeyExW(HKEY_CLASSES_ROOT, keyName.get(),
0, KEY_SET_VALUE, &theKey);
if (REG_FAILED(res)) {
// If updating the open command fails try to update it using the helper
@ -474,10 +475,9 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
return NS_OK;
}
const nsString &flatValue = PromiseFlatString(valueData);
res = ::RegSetValueExW(theKey, L"", 0, REG_SZ,
(const BYTE *) flatValue.get(),
(flatValue.Length() + 1) * sizeof(char16_t));
(const BYTE *) valueData.get(),
(valueData.Length() + 1) * sizeof(char16_t));
// Close the key that was created.
::RegCloseKey(theKey);
if (REG_FAILED(res)) {
@ -529,9 +529,8 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
if (REG_FAILED(res) || char16_t('\0') != *currValue) {
// Key wasn't set or was set to something other than our registry entry.
// Delete the key along with all of its childrean and then recreate it.
const nsString &flatName = PromiseFlatString(keyName);
::SHDeleteKeyW(HKEY_CURRENT_USER, flatName.get());
res = ::RegCreateKeyExW(HKEY_CURRENT_USER, flatName.get(), 0, nullptr,
::SHDeleteKeyW(HKEY_CURRENT_USER, keyName.get());
res = ::RegCreateKeyExW(HKEY_CURRENT_USER, keyName.get(), 0, nullptr,
REG_OPTION_NON_VOLATILE, KEY_SET_VALUE,
nullptr, &theKey, nullptr);
if (REG_FAILED(res)) {
@ -583,10 +582,9 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
NS_ConvertUTF8toUTF16 valueData(VAL_OPEN);
valueData.Replace(offset, 9, appLongPath);
const nsString &flatValue = PromiseFlatString(valueData);
res = ::RegSetValueExW(theKey, L"", 0, REG_SZ,
(const BYTE *) flatValue.get(),
(flatValue.Length() + 1) * sizeof(char16_t));
(const BYTE *) valueData.get(),
(valueData.Length() + 1) * sizeof(char16_t));
// Close the key that was created.
::RegCloseKey(theKey);
// If updating the FTP protocol handlers shell open command fails try to

Просмотреть файл

@ -7,7 +7,7 @@
#define nswindowsshellservice_h____
#include "nscore.h"
#include "nsStringAPI.h"
#include "nsString.h"
#include "nsIWindowsShellService.h"
#include "nsITimer.h"

Просмотреть файл

@ -149,7 +149,6 @@
@RESPATH@/browser/components/prebuilt-interfaces.manifest
@RESPATH@/browser/components/interfaces.xpt
#endif
@RESPATH@/browser/components/components.manifest
@RESPATH@/components/alerts.xpt
#ifdef ACCESSIBILITY
#ifdef XP_WIN32
@ -445,7 +444,6 @@
@RESPATH@/browser/components/nsSessionStore.js
@RESPATH@/components/nsURLFormatter.manifest
@RESPATH@/components/nsURLFormatter.js
@RESPATH@/browser/components/@DLL_PREFIX@browsercomps@DLL_SUFFIX@
@RESPATH@/components/txEXSLTRegExFunctions.manifest
@RESPATH@/components/txEXSLTRegExFunctions.js
@RESPATH@/components/toolkitplaces.manifest

Просмотреть файл

@ -8,6 +8,7 @@ configobj.pth:python/configobj
jsmin.pth:python/jsmin
mach.pth:python/mach
mozbuild.pth:python/mozbuild
mozversioncontrol.pth:python/mozversioncontrol
mozlint.pth:python/mozlint
pymake.pth:build/pymake
optional:setup.py:python/psutil:build_ext:--inplace

Просмотреть файл

@ -923,8 +923,8 @@ nsScriptSecurityManager::CheckLoadURIFlags(nsIURI *aSourceURI,
if (hasFlags) {
// Allow domains that were whitelisted in the prefs. In 99.9% of cases,
// this array is empty.
for (size_t i = 0; i < mFileURIWhitelist.Length(); ++i) {
if (EqualOrSubdomain(aSourceURI, mFileURIWhitelist[i])) {
for (nsIURI* uri : EnsureFileURIWhitelist()) {
if (EqualOrSubdomain(aSourceURI, uri)) {
return NS_OK;
}
}
@ -1459,38 +1459,7 @@ nsScriptSecurityManager::ScriptSecurityPrefChanged()
Preferences::GetBool(sJSEnabledPrefName, mIsJavaScriptEnabled);
sStrictFileOriginPolicy =
Preferences::GetBool(sFileOriginPolicyPrefName, false);
//
// Rebuild the set of principals for which we allow file:// URI loads. This
// implements a small subset of an old pref-based CAPS people that people
// have come to depend on. See bug 995943.
//
mFileURIWhitelist.Clear();
auto policies = mozilla::Preferences::GetCString("capability.policy.policynames");
for (uint32_t base = SkipPast<IsWhitespaceOrComma>(policies, 0), bound = 0;
base < policies.Length();
base = SkipPast<IsWhitespaceOrComma>(policies, bound))
{
// Grab the current policy name.
bound = SkipUntil<IsWhitespaceOrComma>(policies, base);
auto policyName = Substring(policies, base, bound - base);
// Figure out if this policy allows loading file:// URIs. If not, we can skip it.
nsCString checkLoadURIPrefName = NS_LITERAL_CSTRING("capability.policy.") +
policyName +
NS_LITERAL_CSTRING(".checkloaduri.enabled");
if (!Preferences::GetString(checkLoadURIPrefName.get()).LowerCaseEqualsLiteral("allaccess")) {
continue;
}
// Grab the list of domains associated with this policy.
nsCString domainPrefName = NS_LITERAL_CSTRING("capability.policy.") +
policyName +
NS_LITERAL_CSTRING(".sites");
auto siteList = Preferences::GetCString(domainPrefName.get());
AddSitesToFileURIWhitelist(siteList);
}
mFileURIWhitelist.reset();
}
void
@ -1516,7 +1485,7 @@ nsScriptSecurityManager::AddSitesToFileURIWhitelist(const nsCString& aSiteList)
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), site, nullptr, nullptr, sIOService);
if (NS_SUCCEEDED(rv)) {
mFileURIWhitelist.AppendElement(uri);
mFileURIWhitelist.ref().AppendElement(uri);
} else {
nsCOMPtr<nsIConsoleService> console(do_GetService("@mozilla.org/consoleservice;1"));
if (console) {
@ -1676,3 +1645,45 @@ nsScriptSecurityManager::PolicyAllowsScript(nsIURI* aURI, bool *aRv)
return NS_OK;
}
const nsTArray<nsCOMPtr<nsIURI>>&
nsScriptSecurityManager::EnsureFileURIWhitelist()
{
if (mFileURIWhitelist.isSome()) {
return mFileURIWhitelist.ref();
}
//
// Rebuild the set of principals for which we allow file:// URI loads. This
// implements a small subset of an old pref-based CAPS people that people
// have come to depend on. See bug 995943.
//
mFileURIWhitelist.emplace();
auto policies = mozilla::Preferences::GetCString("capability.policy.policynames");
for (uint32_t base = SkipPast<IsWhitespaceOrComma>(policies, 0), bound = 0;
base < policies.Length();
base = SkipPast<IsWhitespaceOrComma>(policies, bound))
{
// Grab the current policy name.
bound = SkipUntil<IsWhitespaceOrComma>(policies, base);
auto policyName = Substring(policies, base, bound - base);
// Figure out if this policy allows loading file:// URIs. If not, we can skip it.
nsCString checkLoadURIPrefName = NS_LITERAL_CSTRING("capability.policy.") +
policyName +
NS_LITERAL_CSTRING(".checkloaduri.enabled");
if (!Preferences::GetString(checkLoadURIPrefName.get()).LowerCaseEqualsLiteral("allaccess")) {
continue;
}
// Grab the list of domains associated with this policy.
nsCString domainPrefName = NS_LITERAL_CSTRING("capability.policy.") +
policyName +
NS_LITERAL_CSTRING(".sites");
auto siteList = Preferences::GetCString(domainPrefName.get());
AddSitesToFileURIWhitelist(siteList);
}
return mFileURIWhitelist.ref();
}

Просмотреть файл

@ -124,10 +124,18 @@ private:
CheckLoadURIFlags(nsIURI* aSourceURI, nsIURI* aTargetURI, nsIURI* aSourceBaseURI,
nsIURI* aTargetBaseURI, uint32_t aFlags);
// Returns the file URI whitelist, initializing it if it has not been
// initialized.
const nsTArray<nsCOMPtr<nsIURI>>& EnsureFileURIWhitelist();
nsCOMPtr<nsIPrincipal> mSystemPrincipal;
bool mPrefInitialized;
bool mIsJavaScriptEnabled;
nsTArray<nsCOMPtr<nsIURI>> mFileURIWhitelist;
// List of URIs whose domains and sub-domains are whitelisted to allow
// access to file: URIs. Lazily initialized; isNothing() when not yet
// initialized.
mozilla::Maybe<nsTArray<nsCOMPtr<nsIURI>>> mFileURIWhitelist;
// This machinery controls new-style domain policies. The old-style
// policy machinery will be removed soon.

Просмотреть файл

@ -16,10 +16,6 @@
#include "nsRuleNode.h"
#include "nsRuleData.h"
// For IsPictureEnabled() -- the candidate parser needs to be aware of sizes
// support being enabled
#include "HTMLPictureElement.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -557,8 +553,7 @@ ResponsiveImageDescriptors::AddDescriptor(const nsAString& aDescriptor)
// If the value is not a valid non-negative integer, it doesn't match this
// descriptor, fall through.
if (ParseInteger(valueStr, possibleWidth) && possibleWidth >= 0) {
if (possibleWidth != 0 && HTMLPictureElement::IsPictureEnabled() &&
mWidth.isNothing() && mDensity.isNothing()) {
if (possibleWidth != 0 && mWidth.isNothing() && mDensity.isNothing()) {
mWidth.emplace(possibleWidth);
} else {
// Valid width descriptor, but width or density were already seen, sizes

Просмотреть файл

@ -6239,12 +6239,18 @@ NS_IMETHODIMP
nsDocument::LoadBindingDocument(const nsAString& aURI)
{
ErrorResult rv;
nsIDocument::LoadBindingDocument(aURI, rv);
nsIDocument::LoadBindingDocument(aURI,
nsContentUtils::GetCurrentJSContext()
? Some(nsContentUtils::SubjectPrincipal())
: Nothing(),
rv);
return rv.StealNSResult();
}
void
nsIDocument::LoadBindingDocument(const nsAString& aURI, ErrorResult& rv)
nsIDocument::LoadBindingDocument(const nsAString& aURI,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& rv)
{
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), aURI,
@ -6258,8 +6264,7 @@ nsIDocument::LoadBindingDocument(const nsAString& aURI, ErrorResult& rv)
// It's just designed to preserve the old semantics during a mass-conversion
// patch.
nsCOMPtr<nsIPrincipal> subjectPrincipal =
nsContentUtils::GetCurrentJSContext() ? nsContentUtils::SubjectPrincipal()
: NodePrincipal();
aSubjectPrincipal.isSome() ? aSubjectPrincipal.value() : NodePrincipal();
BindingManager()->LoadBindingDocument(this, uri, subjectPrincipal);
}

Просмотреть файл

@ -10577,7 +10577,8 @@ nsGlobalWindow::GetSessionStorage(ErrorResult& aError)
}
DOMStorage*
nsGlobalWindow::GetLocalStorage(ErrorResult& aError)
nsGlobalWindow::GetLocalStorage(const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aError)
{
MOZ_RELEASE_ASSERT(IsInnerWindow());
@ -10586,7 +10587,7 @@ nsGlobalWindow::GetLocalStorage(ErrorResult& aError)
}
if (!mLocalStorage) {
if (!DOMStorage::CanUseStorage(AsInner())) {
if (!DOMStorage::CanUseStorage(AsInner(), aSubjectPrincipal)) {
aError.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr;
}
@ -11535,8 +11536,7 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
// Clone the storage event included in the observer notification. We want
// to dispatch clones rather than the original event.
ErrorResult error;
RefPtr<StorageEvent> newEvent = CloneStorageEvent(eventType,
event, error);
RefPtr<StorageEvent> newEvent = CloneStorageEvent(eventType, event, error);
if (error.Failed()) {
return error.StealNSResult();
}
@ -11653,7 +11653,10 @@ nsGlobalWindow::CloneStorageEvent(const nsAString& aType,
RefPtr<DOMStorage> storage;
if (storageArea->GetType() == DOMStorage::LocalStorage) {
storage = GetLocalStorage(aRv);
storage = GetLocalStorage(nsContentUtils::GetCurrentJSContext()
? Some(nsContentUtils::SubjectPrincipal())
: Nothing(),
aRv);
} else {
MOZ_ASSERT(storageArea->GetType() == DOMStorage::SessionStorage);
storage = GetSessionStorage(aRv);

Просмотреть файл

@ -1044,7 +1044,9 @@ public:
void Btoa(const nsAString& aBinaryData, nsAString& aAsciiBase64String,
mozilla::ErrorResult& aError);
mozilla::dom::DOMStorage* GetSessionStorage(mozilla::ErrorResult& aError);
mozilla::dom::DOMStorage* GetLocalStorage(mozilla::ErrorResult& aError);
mozilla::dom::DOMStorage*
GetLocalStorage(const mozilla::Maybe<nsIPrincipal*>& aSubjectPrincipal,
mozilla::ErrorResult& aError);
mozilla::dom::Selection* GetSelectionOuter();
mozilla::dom::Selection* GetSelection(mozilla::ErrorResult& aError);
already_AddRefed<nsISelection> GetSelection() override;

Просмотреть файл

@ -134,6 +134,11 @@ BroadcastBlobURLRegistration(const nsACString& aURI,
return;
}
// We don't need to broadcast Blob URL if we have just 1 content process.
if (Preferences::GetInt("dom.ipc.processCount", 0) <= 1) {
return;
}
ContentChild* cc = ContentChild::GetSingleton();
BlobChild* actor = cc->GetOrCreateActorForBlobImpl(aBlobImpl);
if (NS_WARN_IF(!actor)) {

Просмотреть файл

@ -2685,7 +2685,9 @@ public:
const nsAString& aAttrName,
const nsAString& aAttrValue);
Element* GetBindingParent(nsINode& aNode);
void LoadBindingDocument(const nsAString& aURI, mozilla::ErrorResult& rv);
void LoadBindingDocument(const nsAString& aURI,
const mozilla::Maybe<nsIPrincipal*>& aSubjectPrincipal,
mozilla::ErrorResult& rv);
mozilla::dom::XPathExpression*
CreateExpression(const nsAString& aExpression,
mozilla::dom::XPathNSResolver* aResolver,

Просмотреть файл

@ -3537,8 +3537,10 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp
}
nsIDocument*
nsObjectLoadingContent::GetContentDocument()
nsObjectLoadingContent::GetContentDocument(const mozilla::Maybe<nsIPrincipal*>& aSubjectPrincipal)
{
MOZ_ASSERT(aSubjectPrincipal.isSome());
nsCOMPtr<nsIContent> thisContent =
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
@ -3552,7 +3554,7 @@ nsObjectLoadingContent::GetContentDocument()
}
// Return null for cross-origin contentDocument.
if (!nsContentUtils::SubjectPrincipal()->SubsumesConsideringDomain(sub_doc->NodePrincipal())) {
if (!aSubjectPrincipal.value()->SubsumesConsideringDomain(sub_doc->NodePrincipal())) {
return nullptr;
}

Просмотреть файл

@ -27,6 +27,7 @@
class nsAsyncInstantiateEvent;
class nsStopPluginRunnable;
class AutoSetInstantiatingToFalse;
class nsIPrincipal;
class nsFrameLoader;
class nsPluginFrame;
class nsXULElement;
@ -179,7 +180,7 @@ class nsObjectLoadingContent : public nsImageLoadingContent
mozilla::ErrorResult& aRv);
// WebIDL API
nsIDocument* GetContentDocument();
nsIDocument* GetContentDocument(const mozilla::Maybe<nsIPrincipal*>& aSubjectPrincipal);
void GetActualType(nsAString& aType) const
{
CopyUTF8toUTF16(mContentType, aType);

Просмотреть файл

@ -329,6 +329,12 @@ operator<(const RefPtr<nsPluginElement>& lhs,
return lhs->PluginTag()->Name() < rhs->PluginTag()->Name();
}
static bool
PluginShouldBeHidden(nsCString aName) {
// This only supports one hidden plugin
return Preferences::GetCString("plugins.navigator.hidden_ctp_plugin").Equals(aName);
}
void
nsPluginArray::EnsurePlugins()
{
@ -357,8 +363,7 @@ nsPluginArray::EnsurePlugins()
if (pluginTag->IsClicktoplay()) {
nsCString name;
pluginTag->GetName(name);
if (name.EqualsLiteral("Shockwave Flash") &&
Preferences::GetBool("plugins.navigator_hide_disabled_flash", false)) {
if (PluginShouldBeHidden(name)) {
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
nsCString permString;
nsresult rv = pluginHost->GetPermissionStringForTag(pluginTag, 0, permString);
@ -377,6 +382,12 @@ nsPluginArray::EnsurePlugins()
}
}
if (mPlugins.Length() == 0 && mCTPPlugins.Length() != 0) {
nsCOMPtr<nsPluginTag> hiddenTag = new nsPluginTag("Hidden Plugin", NULL, "dummy.plugin", NULL, NULL,
NULL, NULL, NULL, 0, 0, false);
mPlugins.AppendElement(new nsPluginElement(mWindow, hiddenTag));
}
// Alphabetize the enumeration order of non-hidden plugins to reduce
// fingerprintable entropy based on plugins' installation file times.
mPlugins.Sort();

Просмотреть файл

@ -167,9 +167,10 @@ public:
{
GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aReferrer);
}
nsIDocument* GetSVGDocument()
nsIDocument*
GetSVGDocument(const mozilla::Maybe<nsIPrincipal*>& aSubjectPrincipal)
{
return GetContentDocument();
return GetContentDocument(aSubjectPrincipal);
}
bool Mozbrowser() const
{

Просмотреть файл

@ -50,12 +50,8 @@
#include "nsLayoutUtils.h"
#include "mozilla/Preferences.h"
using namespace mozilla::net;
static const char *kPrefSrcsetEnabled = "dom.image.srcset.enabled";
NS_IMPL_NS_NEW_HTML_ELEMENT(Image)
#ifdef DEBUG
@ -170,19 +166,9 @@ HTMLImageElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const
nsGenericHTMLElement::IsInteractiveHTMLContent(aIgnoreTabindex);
}
bool
HTMLImageElement::IsSrcsetEnabled()
{
return Preferences::GetBool(kPrefSrcsetEnabled, false);
}
nsresult
HTMLImageElement::GetCurrentSrc(nsAString& aValue)
{
if (!IsSrcsetEnabled()) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIURI> currentURI;
GetCurrentURI(getter_AddRefs(currentURI));
if (currentURI) {
@ -433,12 +419,10 @@ HTMLImageElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
CancelImageRequests(aNotify);
}
} else if (aName == nsGkAtoms::srcset &&
aNameSpaceID == kNameSpaceID_None &&
IsSrcsetEnabled()) {
aNameSpaceID == kNameSpaceID_None) {
PictureSourceSrcsetChanged(this, attrVal.String(), aNotify);
} else if (aName == nsGkAtoms::sizes &&
aNameSpaceID == kNameSpaceID_None &&
HTMLPictureElement::IsPictureEnabled()) {
aNameSpaceID == kNameSpaceID_None) {
PictureSourceSizesChanged(this, attrVal.String(), aNotify);
}
@ -929,14 +913,10 @@ HTMLImageElement::QueueImageLoadTask(bool aAlwaysLoad)
bool
HTMLImageElement::HaveSrcsetOrInPicture()
{
if (IsSrcsetEnabled() && HasAttr(kNameSpaceID_None, nsGkAtoms::srcset)) {
if (HasAttr(kNameSpaceID_None, nsGkAtoms::srcset)) {
return true;
}
if (!HTMLPictureElement::IsPictureEnabled()) {
return false;
}
Element *parent = nsINode::GetParentElement();
return (parent && parent->IsHTMLElement(nsGkAtoms::picture));
}
@ -1027,14 +1007,8 @@ HTMLImageElement::PictureSourceSrcsetChanged(nsIContent *aSourceNode,
const nsAString& aNewValue,
bool aNotify)
{
bool isSelf = aSourceNode == this;
if (!IsSrcsetEnabled() ||
(!isSelf && !HTMLPictureElement::IsPictureEnabled())) {
return;
}
MOZ_ASSERT(isSelf || IsPreviousSibling(aSourceNode, this),
MOZ_ASSERT(aSourceNode == this ||
IsPreviousSibling(aSourceNode, this),
"Should not be getting notifications for non-previous-siblings");
nsIContent *currentSrc =
@ -1064,10 +1038,6 @@ HTMLImageElement::PictureSourceSizesChanged(nsIContent *aSourceNode,
const nsAString& aNewValue,
bool aNotify)
{
if (!HTMLPictureElement::IsPictureEnabled()) {
return;
}
MOZ_ASSERT(aSourceNode == this ||
IsPreviousSibling(aSourceNode, this),
"Should not be getting notifications for non-previous-siblings");
@ -1090,10 +1060,6 @@ void
HTMLImageElement::PictureSourceMediaOrTypeChanged(nsIContent *aSourceNode,
bool aNotify)
{
if (!HTMLPictureElement::IsPictureEnabled()) {
return;
}
MOZ_ASSERT(IsPreviousSibling(aSourceNode, this),
"Should not be getting notifications for non-previous-siblings");
@ -1105,10 +1071,6 @@ HTMLImageElement::PictureSourceMediaOrTypeChanged(nsIContent *aSourceNode,
void
HTMLImageElement::PictureSourceAdded(nsIContent *aSourceNode)
{
if (!HTMLPictureElement::IsPictureEnabled()) {
return;
}
MOZ_ASSERT(aSourceNode == this ||
IsPreviousSibling(aSourceNode, this),
"Should not be getting notifications for non-previous-siblings");
@ -1119,10 +1081,6 @@ HTMLImageElement::PictureSourceAdded(nsIContent *aSourceNode)
void
HTMLImageElement::PictureSourceRemoved(nsIContent *aSourceNode)
{
if (!HTMLPictureElement::IsPictureEnabled()) {
return;
}
MOZ_ASSERT(aSourceNode == this ||
IsPreviousSibling(aSourceNode, this),
"Should not be getting notifications for non-previous-siblings");
@ -1135,15 +1093,9 @@ HTMLImageElement::UpdateResponsiveSource()
{
bool hadSelector = !!mResponsiveSelector;
if (!IsSrcsetEnabled()) {
mResponsiveSelector = nullptr;
return hadSelector;
}
nsIContent *currentSource =
mResponsiveSelector ? mResponsiveSelector->Content() : nullptr;
bool pictureEnabled = HTMLPictureElement::IsPictureEnabled();
Element *parent = pictureEnabled ? nsINode::GetParentElement() : nullptr;
Element *parent = nsINode::GetParentElement();
nsINode *candidateSource = nullptr;
if (parent && parent->IsHTMLElement(nsGkAtoms::picture)) {
@ -1231,7 +1183,6 @@ HTMLImageElement::SourceElementMatches(nsIContent* aSourceNode)
DebugOnly<Element *> parent(nsINode::GetParentElement());
MOZ_ASSERT(parent && parent->IsHTMLElement(nsGkAtoms::picture));
MOZ_ASSERT(IsPreviousSibling(aSourceNode, this));
MOZ_ASSERT(HTMLPictureElement::IsPictureEnabled());
// Check media and type
HTMLSourceElement *src = static_cast<HTMLSourceElement*>(aSourceNode);
@ -1249,15 +1200,8 @@ HTMLImageElement::SourceElementMatches(nsIContent* aSourceNode)
}
bool
HTMLImageElement::TryCreateResponsiveSelector(nsIContent *aSourceNode,
const nsAString *aSrcset,
const nsAString *aSizes)
HTMLImageElement::TryCreateResponsiveSelector(nsIContent *aSourceNode)
{
if (!IsSrcsetEnabled()) {
return false;
}
bool pictureEnabled = HTMLPictureElement::IsPictureEnabled();
// Skip if this is not a <source> with matching media query
bool isSourceTag = aSourceNode->IsHTMLElement(nsGkAtoms::source);
if (isSourceTag) {
@ -1271,10 +1215,7 @@ HTMLImageElement::TryCreateResponsiveSelector(nsIContent *aSourceNode,
// Skip if has no srcset or an empty srcset
nsString srcset;
if (aSrcset) {
srcset = *aSrcset;
} else if (!aSourceNode->GetAttr(kNameSpaceID_None, nsGkAtoms::srcset,
srcset)) {
if (!aSourceNode->GetAttr(kNameSpaceID_None, nsGkAtoms::srcset, srcset)) {
return false;
}
@ -1290,13 +1231,9 @@ HTMLImageElement::TryCreateResponsiveSelector(nsIContent *aSourceNode,
return false;
}
if (pictureEnabled && aSizes) {
sel->SetSizesFromDescriptor(*aSizes);
} else if (pictureEnabled) {
nsAutoString sizes;
aSourceNode->GetAttr(kNameSpaceID_None, nsGkAtoms::sizes, sizes);
sel->SetSizesFromDescriptor(sizes);
}
nsAutoString sizes;
aSourceNode->GetAttr(kNameSpaceID_None, nsGkAtoms::sizes, sizes);
sel->SetSizesFromDescriptor(sizes);
// If this is the <img> tag, also pull in src as the default source
if (!isSourceTag) {
@ -1326,12 +1263,7 @@ HTMLImageElement::SelectSourceForTagWithAttrs(nsIDocument *aDocument,
MOZ_ASSERT(!aIsSourceTag || aSrcAttr.IsEmpty(),
"Passing aSrcAttr makes no sense with aIsSourceTag set");
bool pictureEnabled = HTMLPictureElement::IsPictureEnabled();
if (aIsSourceTag && !pictureEnabled) {
return false;
}
if (!IsSrcsetEnabled() || aSrcsetAttr.IsEmpty()) {
if (aSrcsetAttr.IsEmpty()) {
if (!aIsSourceTag) {
// For an <img> with no srcset, we would always select the src attr.
aResult.Assign(aSrcAttr);
@ -1355,7 +1287,7 @@ HTMLImageElement::SelectSourceForTagWithAttrs(nsIDocument *aDocument,
new ResponsiveImageSelector(aDocument);
sel->SetCandidatesFromSourceSet(aSrcsetAttr);
if (pictureEnabled && !aSizesAttr.IsEmpty()) {
if (!aSizesAttr.IsEmpty()) {
sel->SetSizesFromDescriptor(aSizesAttr);
}
if (!aIsSourceTag) {

Просмотреть файл

@ -15,9 +15,6 @@
#include "Units.h"
#include "nsCycleCollectionParticipant.h"
// Only needed for IsPictureEnabled()
#include "mozilla/dom/HTMLPictureElement.h"
namespace mozilla {
class EventChainPreVisitor;
namespace dom {
@ -97,8 +94,6 @@ public:
void MaybeLoadImage();
static bool IsSrcsetEnabled();
bool IsMap()
{
return GetBoolAttr(nsGkAtoms::ismap);
@ -336,9 +331,7 @@ protected:
// If the node's srcset/sizes make for an invalid selector, returns
// false. This does not guarantee the resulting selector matches an image,
// only that it is valid.
bool TryCreateResponsiveSelector(nsIContent *aSourceNode,
const nsAString *aSrcset = nullptr,
const nsAString *aSizes = nullptr);
bool TryCreateResponsiveSelector(nsIContent *aSourceNode);
CSSIntPoint GetXY();
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;

Просмотреть файл

@ -465,15 +465,16 @@ HTMLObjectElement::GetContentDocument(nsIDOMDocument **aContentDocument)
{
NS_ENSURE_ARG_POINTER(aContentDocument);
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(GetContentDocument());
nsCOMPtr<nsIDOMDocument> domDoc =
do_QueryInterface(GetContentDocument(Some(nsContentUtils::SubjectPrincipal())));
domDoc.forget(aContentDocument);
return NS_OK;
}
nsPIDOMWindowOuter*
HTMLObjectElement::GetContentWindow()
HTMLObjectElement::GetContentWindow(const mozilla::Maybe<nsIPrincipal*>& aSubjectPrincipal)
{
nsIDocument* doc = GetContentDocument();
nsIDocument* doc = GetContentDocument(aSubjectPrincipal);
if (doc) {
return doc->GetWindow();
}

Просмотреть файл

@ -156,7 +156,10 @@ public:
SetHTMLAttr(nsGkAtoms::height, aValue, aRv);
}
using nsObjectLoadingContent::GetContentDocument;
nsPIDOMWindowOuter* GetContentWindow();
nsPIDOMWindowOuter*
GetContentWindow(const mozilla::Maybe<nsIPrincipal*>& aSubjectPrincipal);
using nsIConstraintValidation::CheckValidity;
using nsIConstraintValidation::ReportValidity;
using nsIConstraintValidation::GetValidationMessage;
@ -234,9 +237,11 @@ public:
{
SetHTMLAttr(nsGkAtoms::border, aValue, aRv);
}
nsIDocument* GetSVGDocument()
nsIDocument*
GetSVGDocument(const mozilla::Maybe<nsIPrincipal*>& aSubjectPrincipal)
{
return GetContentDocument();
return GetContentDocument(aSubjectPrincipal);
}
private:

Просмотреть файл

@ -8,18 +8,11 @@
#include "mozilla/dom/HTMLPictureElementBinding.h"
#include "mozilla/dom/HTMLImageElement.h"
#include "mozilla/Preferences.h"
static const char *kPrefPictureEnabled = "dom.image.picture.enabled";
// Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Picture) to add pref check.
nsGenericHTMLElement*
NS_NewHTMLPictureElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
mozilla::dom::FromParser aFromParser)
{
if (!mozilla::dom::HTMLPictureElement::IsPictureEnabled()) {
return new mozilla::dom::HTMLUnknownElement(aNodeInfo);
}
return new mozilla::dom::HTMLPictureElement(aNodeInfo);
}
@ -95,13 +88,6 @@ HTMLPictureElement::InsertChildAt(nsIContent* aKid, uint32_t aIndex, bool aNotif
return rv;
}
bool
HTMLPictureElement::IsPictureEnabled()
{
return HTMLImageElement::IsSrcsetEnabled() &&
Preferences::GetBool(kPrefPictureEnabled, false);
}
JSObject*
HTMLPictureElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{

Просмотреть файл

@ -11,8 +11,6 @@
#include "nsIDOMHTMLPictureElement.h"
#include "nsGenericHTMLElement.h"
#include "mozilla/dom/HTMLUnknownElement.h"
namespace mozilla {
namespace dom {
@ -32,8 +30,6 @@ public:
virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex, bool aNotify) override;
static bool IsPictureEnabled();
protected:
virtual ~HTMLPictureElement();

Просмотреть файл

@ -187,9 +187,10 @@ public:
// height covered by <applet>
// align covered by <applet>
// name covered by <applet>
nsIDocument* GetSVGDocument()
nsIDocument*
GetSVGDocument(const mozilla::Maybe<nsIPrincipal*>& aSubjectPrincipal)
{
return GetContentDocument();
return GetContentDocument(aSubjectPrincipal);
}
/**

Просмотреть файл

@ -71,7 +71,7 @@ load 903106.html
load 916322-1.html
load 916322-2.html
load 1032654.html
pref(dom.image.srcset.enabled,true) load 1141260.html
load 1141260.html
load 1228876.html
load 1230110.html
load 1237633.html

Просмотреть файл

@ -79,13 +79,14 @@ nsresult
nsGenericHTMLFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
{
NS_PRECONDITION(aContentDocument, "Null out param");
nsCOMPtr<nsIDOMDocument> document = do_QueryInterface(GetContentDocument());
nsCOMPtr<nsIDOMDocument> document =
do_QueryInterface(GetContentDocument(Some(nsContentUtils::SubjectPrincipal())));
document.forget(aContentDocument);
return NS_OK;
}
nsIDocument*
nsGenericHTMLFrameElement::GetContentDocument()
nsGenericHTMLFrameElement::GetContentDocument(const Maybe<nsIPrincipal*>& aSubjectPrincipal)
{
nsCOMPtr<nsPIDOMWindowOuter> win = GetContentWindow();
if (!win) {
@ -98,8 +99,8 @@ nsGenericHTMLFrameElement::GetContentDocument()
}
// Return null for cross-origin contentDocument.
if (!nsContentUtils::SubjectPrincipal()->
SubsumesConsideringDomain(doc->NodePrincipal())) {
if (!aSubjectPrincipal.value()
->SubsumesConsideringDomain(doc->NodePrincipal())) {
return nullptr;
}
return doc;

Просмотреть файл

@ -102,7 +102,8 @@ protected:
// it makes sense.
void EnsureFrameLoader();
nsresult LoadSrc();
nsIDocument* GetContentDocument();
nsIDocument*
GetContentDocument(const mozilla::Maybe<nsIPrincipal*>& aSubjectPrincipal);
nsresult GetContentDocument(nsIDOMDocument** aContentDocument);
already_AddRefed<nsPIDOMWindowOuter> GetContentWindow();

Просмотреть файл

@ -2390,7 +2390,7 @@ nsHTMLDocument::GenerateParserKey(void)
}
NS_IMETHODIMP
nsHTMLDocument::GetDesignMode(nsAString & aDesignMode)
nsHTMLDocument::GetDesignMode(nsAString& aDesignMode)
{
if (HasFlag(NODE_IS_EDITABLE)) {
aDesignMode.AssignLiteral("on");
@ -2832,17 +2832,22 @@ nsHTMLDocument::EditingStateChanged()
}
NS_IMETHODIMP
nsHTMLDocument::SetDesignMode(const nsAString & aDesignMode)
nsHTMLDocument::SetDesignMode(const nsAString& aDesignMode)
{
ErrorResult rv;
SetDesignMode(aDesignMode, rv);
SetDesignMode(aDesignMode, nsContentUtils::GetCurrentJSContext()
? Some(nsContentUtils::SubjectPrincipal())
: Nothing(), rv);
return rv.StealNSResult();
}
void
nsHTMLDocument::SetDesignMode(const nsAString& aDesignMode, ErrorResult& rv)
nsHTMLDocument::SetDesignMode(const nsAString& aDesignMode,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& rv)
{
if (!nsContentUtils::LegacyIsCallerNativeCode() && !nsContentUtils::SubjectPrincipal()->Subsumes(NodePrincipal())) {
if (!nsContentUtils::LegacyIsCallerNativeCode() &&
!aSubjectPrincipal.value()->Subsumes(NodePrincipal())) {
rv.Throw(NS_ERROR_DOM_PROP_ACCESS_DENIED);
return;
}

Просмотреть файл

@ -210,8 +210,14 @@ public:
mozilla::ErrorResult& rv);
void Writeln(JSContext* cx, const mozilla::dom::Sequence<nsString>& aText,
mozilla::ErrorResult& rv);
// The XPCOM GetDesignMode() works OK for us, since it never throws.
void SetDesignMode(const nsAString& aDesignMode, mozilla::ErrorResult& rv);
void GetDesignMode(nsAString& aDesignMode,
const mozilla::Maybe<nsIPrincipal*>& aSubjectPrincipal)
{
GetDesignMode(aDesignMode);
}
void SetDesignMode(const nsAString& aDesignMode,
const mozilla::Maybe<nsIPrincipal*>& aSubjectPrincipal,
mozilla::ErrorResult& rv);
bool ExecCommand(const nsAString& aCommandID, bool aDoShowUI,
const nsAString& aValue, mozilla::ErrorResult& rv);
bool QueryCommandEnabled(const nsAString& aCommandID,

Просмотреть файл

@ -48,8 +48,8 @@ skip == bug917595-exif-rotated.jpg bug917595-exif-rotated.jpg
# Bug 1150490 disabling on Mulet as on B2G
# Test support for SVG-as-image in <picture> elements.
pref(dom.image.picture.enabled,true) pref(dom.image.srcset.enabled,true) == bug1106522-1.html bug1106522-1.html
pref(dom.image.picture.enabled,true) pref(dom.image.srcset.enabled,true) == bug1106522-2.html bug1106522-2.html
== bug1106522-1.html bug1106522-1.html
== bug1106522-2.html bug1106522-2.html
== href-attr-change-restyles.html href-attr-change-restyles.html
== figure.html figure.html

Просмотреть файл

@ -44,8 +44,8 @@ fuzzy(1,149) == bug917595-iframe-1.html bug917595-1-ref.html
skip-if(B2G||Mulet) fuzzy-if((!B2G&&!Mulet),3,640) == bug917595-exif-rotated.jpg bug917595-pixel-rotated.jpg # bug 1060869 # Bug 1150490 disabling on Mulet as on B2G
# Test support for SVG-as-image in <picture> elements.
pref(dom.image.picture.enabled,true) pref(dom.image.srcset.enabled,true) == bug1106522-1.html bug1106522-ref.html
pref(dom.image.picture.enabled,true) pref(dom.image.srcset.enabled,true) == bug1106522-2.html bug1106522-ref.html
== bug1106522-1.html bug1106522-ref.html
== bug1106522-2.html bug1106522-ref.html
== href-attr-change-restyles.html href-attr-change-restyles-ref.html
== figure.html figure-ref.html

Просмотреть файл

@ -3259,6 +3259,10 @@ TabChild::ReinitRendering()
lf->IdentifyTextureHost(mTextureFactoryIdentifier);
mApzcTreeManager = CompositorBridgeChild::Get()->GetAPZCTreeManager(mLayersId);
if (mApzcTreeManager) {
APZChild* apz = ContentProcessController::Create(mUniqueId);
CompositorBridgeChild::Get()->SendPAPZConstructor(apz, mLayersId);
}
}
void

Просмотреть файл

@ -3955,7 +3955,7 @@ void
MediaStreamGraphImpl::UnregisterCaptureStreamForWindow(uint64_t aWindowId)
{
MOZ_ASSERT(NS_IsMainThread());
for (uint32_t i = 0; i < mWindowCaptureStreams.Length(); i++) {
for (int32_t i = mWindowCaptureStreams.Length() - 1; i >= 0; i--) {
if (mWindowCaptureStreams[i].mWindowId == aWindowId) {
mWindowCaptureStreams.RemoveElementAt(i);
}

Просмотреть файл

@ -54,11 +54,13 @@ parent:
async Drain();
async Shutdown();
async SetSeekThreshold(int64_t time);
async __delete__();
child:
async InitComplete();
async InitComplete(bool hardware, nsCString hardwareReason);
async InitFailed(nsresult reason);
// Each output includes a SurfaceDescriptorGPUVideo that represents the decoded

Просмотреть файл

@ -102,6 +102,26 @@ RemoteVideoDecoder::Shutdown()
}), NS_DISPATCH_NORMAL);
}
bool
RemoteVideoDecoder::IsHardwareAccelerated(nsACString& aFailureReason) const
{
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
return mActor->IsHardwareAccelerated(aFailureReason);
}
void
RemoteVideoDecoder::SetSeekThreshold(const media::TimeUnit& aTime)
{
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
RefPtr<RemoteVideoDecoder> self = this;
media::TimeUnit time = aTime;
VideoDecoderManagerChild::GetManagerThread()->Dispatch(NS_NewRunnableFunction([=]() {
MOZ_ASSERT(self->mActor);
self->mActor->SetSeekThreshold(time);
}), NS_DISPATCH_NORMAL);
}
nsresult
RemoteDecoderModule::Startup()
{

Просмотреть файл

@ -32,6 +32,8 @@ public:
void Flush() override;
void Drain() override;
void Shutdown() override;
bool IsHardwareAccelerated(nsACString& aFailureReason) const override;
void SetSeekThreshold(const media::TimeUnit& aTime) override;
const char* GetDescriptionName() const override { return "RemoteVideoDecoder"; }

Просмотреть файл

@ -23,6 +23,8 @@ VideoDecoderChild::VideoDecoderChild()
: mThread(VideoDecoderManagerChild::GetManagerThread())
, mLayersBackend(layers::LayersBackend::LAYERS_NONE)
, mCanSend(true)
, mInitialized(false)
, mIsHardwareAccelerated(false)
{
}
@ -80,10 +82,13 @@ VideoDecoderChild::RecvError(const nsresult& aError)
}
bool
VideoDecoderChild::RecvInitComplete()
VideoDecoderChild::RecvInitComplete(const bool& aHardware, const nsCString& aHardwareReason)
{
AssertOnManagerThread();
mInitPromise.Resolve(TrackInfo::kVideoTrack, __func__);
mInitialized = true;
mIsHardwareAccelerated = aHardware;
mHardwareAcceleratedReason = aHardwareReason;
return true;
}
@ -98,6 +103,13 @@ VideoDecoderChild::RecvInitFailed(const nsresult& aReason)
void
VideoDecoderChild::ActorDestroy(ActorDestroyReason aWhy)
{
if (aWhy == AbnormalShutdown) {
if (mInitialized) {
mCallback->Error(NS_ERROR_DOM_MEDIA_FATAL_ERR);
} else {
mInitPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
}
}
mCanSend = false;
}
@ -197,6 +209,23 @@ VideoDecoderChild::Shutdown()
if (!mCanSend || !SendShutdown()) {
mCallback->Error(NS_ERROR_DOM_MEDIA_FATAL_ERR);
}
mInitialized = false;
}
bool
VideoDecoderChild::IsHardwareAccelerated(nsACString& aFailureReason) const
{
aFailureReason = mHardwareAcceleratedReason;
return mIsHardwareAccelerated;
}
void
VideoDecoderChild::SetSeekThreshold(const media::TimeUnit& aTime)
{
AssertOnManagerThread();
if (!mCanSend || !SendSetSeekThreshold(aTime.ToMicroseconds())) {
mCallback->Error(NS_ERROR_DOM_MEDIA_FATAL_ERR);
}
}
void

Просмотреть файл

@ -29,7 +29,7 @@ public:
bool RecvInputExhausted() override;
bool RecvDrainComplete() override;
bool RecvError(const nsresult& aError) override;
bool RecvInitComplete() override;
bool RecvInitComplete(const bool& aHardware, const nsCString& aHardwareReason) override;
bool RecvInitFailed(const nsresult& aReason) override;
void ActorDestroy(ActorDestroyReason aWhy) override;
@ -39,6 +39,8 @@ public:
void Flush();
void Drain();
void Shutdown();
bool IsHardwareAccelerated(nsACString& aFailureReason) const;
void SetSeekThreshold(const media::TimeUnit& aTime);
MOZ_IS_CLASS_INIT
void InitIPDL(MediaDataDecoderCallback* aCallback,
@ -63,7 +65,10 @@ private:
VideoInfo mVideoInfo;
layers::LayersBackend mLayersBackend;
nsCString mHardwareAcceleratedReason;
bool mCanSend;
bool mInitialized;
bool mIsHardwareAccelerated;
};
} // namespace dom

Просмотреть файл

@ -81,7 +81,9 @@ VideoDecoderParent::RecvInit(const VideoInfo& aInfo, const layers::LayersBackend
mDecoder->Init()->Then(mManagerTaskQueue, __func__,
[self] (TrackInfo::TrackType aTrack) {
if (!self->mDestroyed) {
Unused << self->SendInitComplete();
nsCString hardwareReason;
bool hardwareAccelerated = self->mDecoder->IsHardwareAccelerated(hardwareReason);
Unused << self->SendInitComplete(hardwareAccelerated, hardwareReason);
}
},
[self] (MediaResult aReason) {
@ -135,6 +137,14 @@ VideoDecoderParent::RecvShutdown()
return true;
}
bool
VideoDecoderParent::RecvSetSeekThreshold(const int64_t& aTime)
{
MOZ_ASSERT(!mDestroyed);
mDecoder->SetSeekThreshold(media::TimeUnit::FromMicroseconds(aTime));
return true;
}
void
VideoDecoderParent::ActorDestroy(ActorDestroyReason aWhy)
{

Просмотреть файл

@ -35,6 +35,7 @@ public:
bool RecvFlush() override;
bool RecvDrain() override;
bool RecvShutdown() override;
bool RecvSetSeekThreshold(const int64_t& aTime) override;
void ActorDestroy(ActorDestroyReason aWhy) override;

Просмотреть файл

@ -33,9 +33,9 @@
#include "nsGlobalWindow.h"
#include "nsIDocument.h"
#include "nsIContent.h"
#include "nsIIDNService.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptContext.h"
#include "nsIUnicodeNormalizer.h"
#include "nsDOMJSUtils.h"
#include "nsIPrincipal.h"
#include "nsWildCard.h"
@ -1935,18 +1935,25 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
return NPERR_GENERIC_ERROR;
}
nsCOMPtr<nsIUnicodeNormalizer> normalizer = do_GetService(NS_UNICODE_NORMALIZER_CONTRACTID);
if (!normalizer) {
nsCOMPtr<nsIIDNService> idnService = do_GetService(NS_IDNSERVICE_CONTRACTID);
if (!idnService) {
return NPERR_GENERIC_ERROR;
}
nsAutoString normalizedUTF16Origin;
res = normalizer->NormalizeUnicodeNFKC(utf16Origin, normalizedUTF16Origin);
// This is a bit messy: we convert to UTF-8 here, but then
// nsIDNService::Normalize will convert back to UTF-16 for processing,
// and back to UTF-8 again to return the result.
// Alternative: perhaps we should add a NormalizeUTF16 version of the API,
// and just convert to UTF-8 for the final return (resulting in one
// encoding form conversion instead of three).
NS_ConvertUTF16toUTF8 utf8Origin(utf16Origin);
nsAutoCString normalizedUTF8Origin;
res = idnService->Normalize(utf8Origin, normalizedUTF8Origin);
if (NS_FAILED(res)) {
return NPERR_GENERIC_ERROR;
}
*(char**)result = ToNewUTF8String(normalizedUTF16Origin);
*(char**)result = ToNewCString(normalizedUTF8Origin);
return *(char**)result ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
}

Просмотреть файл

@ -2093,6 +2093,22 @@ nsPluginHost::AddPluginTag(nsPluginTag* aPluginTag)
}
}
static bool
PluginInfoIsFlash(const nsPluginInfo& info)
{
if (strcmp(info.fDescription, "Shockwave Flash") != 0) {
return false;
}
for (uint32_t i = 0; i < info.fVariantCount; ++i) {
if (info.fMimeTypeArray[i] &&
(!strcmp(info.fMimeTypeArray[i], "application/x-shockwave-flash") ||
!strcmp(info.fMimeTypeArray[i], "application/x-shockwave-flash-test"))) {
return true;
}
}
return false;
}
typedef NS_NPAPIPLUGIN_CALLBACK(char *, NP_GETMIMEDESCRIPTION)(void);
nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir,
@ -2113,6 +2129,8 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir,
("nsPluginHost::ScanPluginsDirectory dir=%s\n", dirPath.get()));
#endif
bool flashOnly = Preferences::GetBool("plugin.load_flash_only", true);
nsCOMPtr<nsISimpleEnumerator> iter;
rv = pluginsDir->GetDirectoryEntries(getter_AddRefs(iter));
if (NS_FAILED(rv))
@ -2215,7 +2233,8 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir,
res = pluginFile.GetPluginInfo(info, &library);
}
// if we don't have mime type don't proceed, this is not a plugin
if (NS_FAILED(res) || !info.fMimeTypeArray) {
if (NS_FAILED(res) || !info.fMimeTypeArray ||
(flashOnly && !PluginInfoIsFlash(info))) {
RefPtr<nsInvalidPluginTag> invalidTag = new nsInvalidPluginTag(filePath.get(),
fileModTime);
pluginFile.FreePluginInfo(info);

Просмотреть файл

@ -73,6 +73,7 @@ skip-if = !crashreporter || e10s
[test_getauthenticationinfo.html]
[test_hanging.html]
skip-if = !crashreporter || e10s
[test_hidden_plugin.html]
[test_instance_re-parent.html]
skip-if = release_build # Bug 1172627
[test_instance_unparent1.html]

Просмотреть файл

@ -27,10 +27,6 @@ function getTestPlugin(pluginName) {
// ends
function setTestPluginEnabledState(newEnabledState, pluginName) {
var oldEnabledState = SpecialPowers.setTestPluginEnabledState(newEnabledState, pluginName);
if (!oldEnabledState) {
ok(false, "Cannot find plugin '" + plugin + "'");
return;
}
var plugin = getTestPlugin(pluginName);
while (plugin.enabledState != newEnabledState) {
// Run a nested event loop to wait for the preference change to

Просмотреть файл

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<title>Test whether we are adding the dummy plugin correctly when there is only 1 plugin and its hidden</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<body>
<script type="application/javascript;version=1.7">
"use strict"
{
SimpleTest.waitForExplicitFinish();
let ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"].getService(SpecialPowers.Ci.nsIPluginHost);
let plugins = ph.getPluginTags();
let testPluginName = plugins[0].name;
let oldPrefVal = null;
let prefName = "plugins.navigator.hidden_ctp_plugin";
try {
oldPrefVal = SpecialPowers.getCharPref(prefName);
} catch (ex) {}
let promise = SpecialPowers.pushPrefEnv({ set: [[prefName, testPluginName]]});
promise.then(function() {
for (let i = 0; i < plugins.length; i++) {
let plugin = plugins[i];
let newState = (plugin.name == testPluginName ? SpecialPowers.Ci.nsIPluginTag.STATE_CLICKTOPLAY :
SpecialPowers.Ci.nsIPluginTag.STATE_DISABLED);
if (plugin.enabledState != newState) {
let oldState = plugin.enabledState;
setTestPluginEnabledState(newState, plugin.name);
SimpleTest.registerCleanupFunction(function() {
if (plugin.enabledState != oldState)
setTestPluginEnabledState(oldState, plugin.name);
});
}
}
// we have disabled all the plugins except for 1 which is click to play and hidden. The
// navigator.plugins list should have only one entry and it should be the dummy plugin.
isnot(navigator.plugins.length, 0, "navigator.plugins should not be empty");
SimpleTest.finish();
});
}
</script>
</body>

Просмотреть файл

@ -6,12 +6,17 @@
var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import("resource://gre/modules/Promise.jsm");
Cu.import("resource://gre/modules/Services.jsm");
const gIsWindows = mozinfo.os == "win";
const gIsOSX = mozinfo.os == "mac";
const gIsLinux = mozinfo.os == "linux";
const gDirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
function allow_all_plugins() {
Services.prefs.setBoolPref("plugin.load_flash_only", false);
}
// Finds the test plugin library
function get_test_plugin(secondplugin=false) {
var pluginEnum = gDirSvc.get("APluginsDL", Ci.nsISimpleEnumerator);

Просмотреть файл

@ -9,6 +9,8 @@ function run_test() {
const pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
const pluginDefaultState = Services.prefs.getIntPref("plugin.default.state");
Services.prefs.setBoolPref("plugin.load_flash_only", false);
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,

Просмотреть файл

@ -1,86 +0,0 @@
/* 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");
// Plugin registry uses different field delimeters on different platforms
var DELIM = mozinfo.os == "win" ? "|" : ":";
var gProfD = do_get_profile_startup();
// Writes out some plugin registry to the profile
function write_registry(version, info) {
var header = "Generated File. Do not edit.\n\n";
header += "[HEADER]\n";
header += "Version" + DELIM + version + DELIM + "$\n\n";
header += "[PLUGINS]\n";
var registry = gProfD.clone();
registry.append("pluginreg.dat");
var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
.createInstance(Components.interfaces.nsIFileOutputStream);
// write, create, truncate
foStream.init(registry, 0x02 | 0x08 | 0x20, 0o666, 0);
var charset = "UTF-8"; // Can be any character encoding name that Mozilla supports
var os = Cc["@mozilla.org/intl/converter-output-stream;1"].
createInstance(Ci.nsIConverterOutputStream);
os.init(foStream, charset, 0, 0x0000);
os.writeString(header);
os.writeString(info);
os.close();
}
function run_test() {
var plugin = get_test_plugintag();
do_check_true(plugin == null);
var file = get_test_plugin();
if (!file)
do_throw("Plugin library not found");
// Write out a 0.9 version registry that marks the test plugin as disabled
var registry = "";
if (gIsOSX) {
registry += file.leafName + DELIM + "$\n";
registry += file.path + DELIM + "$\n";
} else {
registry += file.path + DELIM + "$\n";
registry += DELIM + "$\n";
}
registry += file.lastModifiedTime + DELIM + "0" + DELIM + "0" + DELIM + "$\n";
registry += "Plug-in for testing purposes.\u2122 " +
"(\u0939\u093f\u0928\u094d\u0926\u0940 " +
"\u4e2d\u6587 " +
"\u0627\u0644\u0639\u0631\u0628\u064a\u0629)" +
DELIM + "$\n";
registry += "Test Plug-in" + DELIM + "$\n";
registry += "1\n";
registry += "0" + DELIM + "application/x-test" + DELIM + "Test mimetype" +
DELIM + "tst" + DELIM + "$\n";
write_registry("0.9", registry);
// Initialise profile folder
do_get_profile();
plugin = get_test_plugintag();
if (!plugin)
do_throw("Plugin tag not found");
// If the plugin was not rescanned then this version will not be correct
do_check_eq(plugin.version, "1.0.0.0");
do_check_eq(plugin.description,
"Plug-in for testing purposes.\u2122 " +
"(\u0939\u093f\u0928\u094d\u0926\u0940 " +
"\u4e2d\u6587 " +
"\u0627\u0644\u0639\u0631\u0628\u064a\u0629)");
// If the plugin registry was not read then the plugin will not be disabled
do_check_true(plugin.disabled);
do_check_false(plugin.blocklisted);
// Clean up
Services.prefs.clearUserPref("plugin.importedState");
}

Просмотреть файл

@ -6,6 +6,7 @@
Components.utils.import("resource://gre/modules/Services.jsm");
function run_test() {
allow_all_plugins();
do_get_profile_startup();
var plugin = get_test_plugintag();

Просмотреть файл

@ -39,6 +39,7 @@ function write_registry(version, info) {
}
function run_test() {
allow_all_plugins();
var plugin = get_test_plugintag();
do_check_true(plugin == null);

Просмотреть файл

@ -9,6 +9,7 @@ function check_state(aTag, aExpectedClicktoplay, aExpectedDisabled) {
}
function run_test() {
allow_all_plugins();
let tag = get_test_plugintag();
tag.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
check_state(tag, false, false);

Просмотреть файл

@ -32,6 +32,7 @@ function test_expected_permission_string(aPermString) {
}
function run_test() {
allow_all_plugins();
do_check_true(gIsWindows || gIsOSX || gIsLinux);
do_check_true(!(gIsWindows && gIsOSX) && !(gIsWindows && gIsLinux) &&
!(gIsOSX && gIsLinux));

Просмотреть файл

@ -39,6 +39,8 @@ function write_registry(version, info) {
}
function run_test() {
allow_all_plugins();
do_check_true(gIsWindows || gIsOSX || gIsLinux);
let file = get_test_plugin_no_symlink();

Просмотреть файл

@ -1,6 +1,7 @@
Components.utils.import("resource://gre/modules/Services.jsm");
function run_test() {
allow_all_plugins();
let pluginDefaultState = Services.prefs.getIntPref("plugin.default.state");
// if this fails, we just have to switch around the values we're testing
do_check_neq(pluginDefaultState, Ci.nsIPluginTag.STATE_DISABLED);

Просмотреть файл

@ -30,6 +30,7 @@ function getTestaddonFilename() {
}
function run_test() {
allow_all_plugins();
loadAddonManager();
gProfileDir = do_get_profile();
do_register_cleanup(() => shutdownManager());

Просмотреть файл

@ -10,9 +10,6 @@ support-files =
[test_allowed_types.js]
skip-if = appname == "thunderbird"
reason = plugins are disabled by default in Thunderbird
[test_bug455213.js]
# Bug 676953: test fails consistently on Android
fail-if = os == "android"
[test_bug471245.js]
# Bug 676953: test fails consistently on Android
fail-if = os == "android"

Просмотреть файл

@ -48,7 +48,7 @@ function handleRequest(request, response) {
return;
}
if (query.has("imgtWrongType")) {
if (query.has("imgWrongType")) {
response.setHeader("Content-Type", "text/html", false);
response.write(IMG);
return;

Просмотреть файл

@ -38,77 +38,80 @@ function checkFinish() {
}
}
// 1) Test CSS with correct mime type
var cssCorrectType = document.getElementById("cssCorrectType");
cssCorrectType.onload = function() {
ok(true, "style nosniff correct type should load");
checkFinish();
}
cssCorrectType.onerror = function() {
ok(false, "style nosniff correct type should load");
checkFinish();
}
cssCorrectType.href = "file_nosniff_testserver.sjs?cssCorrectType";
SpecialPowers.pushPrefEnv({set: [["security.xcto_nosniff_block_images", true]]}, function() {
// 2) Test CSS with wrong mime type
var cssWrongType = document.getElementById("cssWrongType");
cssWrongType.onload = function() {
ok(false, "style nosniff wrong type should not load");
checkFinish();
}
cssWrongType.onerror = function() {
ok(true, "style nosniff wrong type should not load");
checkFinish();
}
cssWrongType.href = "file_nosniff_testserver.sjs?cssWrongType";
// 1) Test CSS with correct mime type
var cssCorrectType = document.getElementById("cssCorrectType");
cssCorrectType.onload = function() {
ok(true, "style nosniff correct type should load");
checkFinish();
}
cssCorrectType.onerror = function() {
ok(false, "style nosniff correct type should load");
checkFinish();
}
cssCorrectType.href = "file_nosniff_testserver.sjs?cssCorrectType";
// 3) Test SCRIPT with correct mime type
var scriptCorrectType = document.getElementById("scriptCorrectType");
scriptCorrectType.onload = function() {
ok(true, "script nosniff correct type should load");
checkFinish();
}
scriptCorrectType.onerror = function() {
ok(false, "script nosniff correct type should load");
checkFinish();
}
scriptCorrectType.src = "file_nosniff_testserver.sjs?scriptCorrectType";
// 2) Test CSS with wrong mime type
var cssWrongType = document.getElementById("cssWrongType");
cssWrongType.onload = function() {
ok(false, "style nosniff wrong type should not load");
checkFinish();
}
cssWrongType.onerror = function() {
ok(true, "style nosniff wrong type should not load");
checkFinish();
}
cssWrongType.href = "file_nosniff_testserver.sjs?cssWrongType";
// 4) Test SCRIPT with wrong mime type
var scriptWrongType = document.getElementById("scriptWrongType");
scriptWrongType.onload = function() {
ok(false, "script nosniff wrong type should not load");
checkFinish();
}
scriptWrongType.onerror = function() {
ok(true, "script nosniff wrong type should not load");
checkFinish();
}
scriptWrongType.src = "file_nosniff_testserver.sjs?scriptWrongType";
// 3) Test SCRIPT with correct mime type
var scriptCorrectType = document.getElementById("scriptCorrectType");
scriptCorrectType.onload = function() {
ok(true, "script nosniff correct type should load");
checkFinish();
}
scriptCorrectType.onerror = function() {
ok(false, "script nosniff correct type should load");
checkFinish();
}
scriptCorrectType.src = "file_nosniff_testserver.sjs?scriptCorrectType";
// 5) Test IMG with correct mime type
var imgCorrectType = document.getElementById("imgCorrectType");
imgCorrectType.onload = function() {
ok(true, "img nosniff correct type should load");
checkFinish();
}
imgCorrectType.onerror = function() {
ok(false, "img nosniff correct type should load");
checkFinish();
}
imgCorrectType.src = "file_nosniff_testserver.sjs?imgCorrectType";
// 4) Test SCRIPT with wrong mime type
var scriptWrongType = document.getElementById("scriptWrongType");
scriptWrongType.onload = function() {
ok(false, "script nosniff wrong type should not load");
checkFinish();
}
scriptWrongType.onerror = function() {
ok(true, "script nosniff wrong type should not load");
checkFinish();
}
scriptWrongType.src = "file_nosniff_testserver.sjs?scriptWrongType";
// 6) Test IMG with wrong mime type
var imgWrongType = document.getElementById("imgWrongType");
imgWrongType.onload = function() {
ok(false, "img nosniff wrong type should not load");
checkFinish();
}
imgWrongType.onerror = function() {
ok(true, "img nosniff wrong type should not load");
checkFinish();
}
imgWrongType.src = "file_nosniff_testserver.sjs?imgWrongType";
// 5) Test IMG with correct mime type
var imgCorrectType = document.getElementById("imgCorrectType");
imgCorrectType.onload = function() {
ok(true, "img nosniff correct type should load");
checkFinish();
}
imgCorrectType.onerror = function() {
ok(false, "img nosniff correct type should load");
checkFinish();
}
imgCorrectType.src = "file_nosniff_testserver.sjs?imgCorrectType";
// 6) Test IMG with wrong mime type
var imgWrongType = document.getElementById("imgWrongType");
imgWrongType.onload = function() {
ok(false, "img nosniff wrong type should not load");
checkFinish();
}
imgWrongType.onerror = function() {
ok(true, "img nosniff wrong type should not load");
checkFinish();
}
imgWrongType.src = "file_nosniff_testserver.sjs?imgWrongType";
});
</script>
</body>

Просмотреть файл

@ -166,16 +166,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=62178
SpecialPowers.pushPrefEnv({'set': [["security.mixed_content.use_hsts", false],
["security.mixed_content.send_hsts_priming", false]]});
//Set the first set of mixed content settings and increment the counter.
//Enable <picture> and <img srcset> for the test.
changePrefs([[ "dom.image.srcset.enabled", true ], [ "dom.image.picture.enabled", true ]],
function() {
//listen for a messages from the mixed content test harness
window.addEventListener("message", receiveMessage, false);
changePrefs([], function() {
//listen for a messages from the mixed content test harness
window.addEventListener("message", receiveMessage, false);
//Kick off test
reloadFrame();
}
);
//Kick off test
reloadFrame();
});
}
SimpleTest.waitForExplicitFinish();

Просмотреть файл

@ -67,9 +67,12 @@ DOMStorage::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
}
uint32_t
DOMStorage::GetLength(ErrorResult& aRv)
DOMStorage::GetLength(const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv)
{
if (!CanUseStorage(nullptr, this)) {
MOZ_ASSERT(aSubjectPrincipal.isSome());
if (!CanUseStorage(nullptr, aSubjectPrincipal, this)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return 0;
}
@ -80,9 +83,13 @@ DOMStorage::GetLength(ErrorResult& aRv)
}
void
DOMStorage::Key(uint32_t aIndex, nsAString& aResult, ErrorResult& aRv)
DOMStorage::Key(uint32_t aIndex, nsAString& aResult,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv)
{
if (!CanUseStorage(nullptr, this)) {
MOZ_ASSERT(aSubjectPrincipal.isSome());
if (!CanUseStorage(nullptr, aSubjectPrincipal, this)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
@ -91,9 +98,13 @@ DOMStorage::Key(uint32_t aIndex, nsAString& aResult, ErrorResult& aRv)
}
void
DOMStorage::GetItem(const nsAString& aKey, nsAString& aResult, ErrorResult& aRv)
DOMStorage::GetItem(const nsAString& aKey, nsAString& aResult,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv)
{
if (!CanUseStorage(nullptr, this)) {
MOZ_ASSERT(aSubjectPrincipal.isSome());
if (!CanUseStorage(nullptr, aSubjectPrincipal, this)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
@ -103,9 +114,12 @@ DOMStorage::GetItem(const nsAString& aKey, nsAString& aResult, ErrorResult& aRv)
void
DOMStorage::SetItem(const nsAString& aKey, const nsAString& aData,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv)
{
if (!CanUseStorage(nullptr, this)) {
MOZ_ASSERT(aSubjectPrincipal.isSome());
if (!CanUseStorage(nullptr, aSubjectPrincipal, this)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
@ -129,9 +143,13 @@ DOMStorage::SetItem(const nsAString& aKey, const nsAString& aData,
}
void
DOMStorage::RemoveItem(const nsAString& aKey, ErrorResult& aRv)
DOMStorage::RemoveItem(const nsAString& aKey,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv)
{
if (!CanUseStorage(nullptr, this)) {
MOZ_ASSERT(aSubjectPrincipal.isSome());
if (!CanUseStorage(nullptr, aSubjectPrincipal, this)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
@ -148,9 +166,12 @@ DOMStorage::RemoveItem(const nsAString& aKey, ErrorResult& aRv)
}
void
DOMStorage::Clear(ErrorResult& aRv)
DOMStorage::Clear(const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv)
{
if (!CanUseStorage(nullptr, this)) {
MOZ_ASSERT(aSubjectPrincipal.isSome());
if (!CanUseStorage(nullptr, aSubjectPrincipal, this)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
@ -226,7 +247,9 @@ static const char kStorageEnabled[] = "dom.storage.enabled";
// static, public
bool
DOMStorage::CanUseStorage(nsPIDOMWindowInner* aWindow, DOMStorage* aStorage)
DOMStorage::CanUseStorage(nsPIDOMWindowInner* aWindow,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
DOMStorage* aStorage)
{
// This method is responsible for correct setting of mIsSessionOnly.
@ -248,9 +271,8 @@ DOMStorage::CanUseStorage(nsPIDOMWindowInner* aWindow, DOMStorage* aStorage)
if (aStorage) {
aStorage->mIsSessionOnly = access <= nsContentUtils::StorageAccess::eSessionScoped;
nsCOMPtr<nsIPrincipal> subjectPrincipal =
nsContentUtils::SubjectPrincipal();
return aStorage->CanAccess(subjectPrincipal);
MOZ_ASSERT(aSubjectPrincipal.isSome());
return aStorage->CanAccess(aSubjectPrincipal.value());
}
return true;
@ -298,7 +320,8 @@ DOMStorage::CanAccess(nsIPrincipal* aPrincipal)
void
DOMStorage::GetSupportedNames(nsTArray<nsString>& aKeys)
{
if (!CanUseStorage(nullptr, this)) {
if (!CanUseStorage(nullptr, Some(nsContentUtils::SubjectPrincipal()),
this)) {
// return just an empty array
aKeys.Clear();
return;

Просмотреть файл

@ -9,6 +9,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/Maybe.h"
#include "nsIDOMStorage.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWeakReference.h"
@ -69,40 +70,53 @@ public:
return mWindow;
}
uint32_t GetLength(ErrorResult& aRv);
uint32_t GetLength(const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv);
void Key(uint32_t aIndex, nsAString& aResult, ErrorResult& aRv);
void Key(uint32_t aIndex, nsAString& aResult,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv);
void GetItem(const nsAString& aKey, nsAString& aResult, ErrorResult& aRv);
void GetItem(const nsAString& aKey, nsAString& aResult,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv);
void GetSupportedNames(nsTArray<nsString>& aKeys);
void NamedGetter(const nsAString& aKey, bool& aFound, nsAString& aResult,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv)
{
GetItem(aKey, aResult, aRv);
GetItem(aKey, aResult, aSubjectPrincipal, aRv);
aFound = !aResult.IsVoid();
}
void SetItem(const nsAString& aKey, const nsAString& aValue,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv);
void NamedSetter(const nsAString& aKey, const nsAString& aValue,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv)
{
SetItem(aKey, aValue, aRv);
SetItem(aKey, aValue, aSubjectPrincipal, aRv);
}
void RemoveItem(const nsAString& aKey, ErrorResult& aRv);
void RemoveItem(const nsAString& aKey,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv);
void NamedDeleter(const nsAString& aKey, bool& aFound, ErrorResult& aRv)
void NamedDeleter(const nsAString& aKey, bool& aFound,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv)
{
RemoveItem(aKey, aRv);
RemoveItem(aKey, aSubjectPrincipal, aRv);
aFound = !aRv.ErrorCodeIs(NS_SUCCESS_DOM_NO_OPERATION);
}
void Clear(ErrorResult& aRv);
void Clear(const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv);
// The method checks whether the caller can use a storage.
// CanUseStorage is called before any DOM initiated operation
@ -112,6 +126,7 @@ public:
// state determination are complex and share the code (comes hand in
// hand together).
static bool CanUseStorage(nsPIDOMWindowInner* aWindow,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
DOMStorage* aStorage = nullptr);
bool IsPrivate() const;

Просмотреть файл

@ -100,14 +100,12 @@ skip-if = buildapp == 'mulet'
skip-if = buildapp == 'mulet'
[test_performance_timeline.html]
[test_picture_mutations.html]
[test_picture_pref.html]
skip-if = buildapp == 'b2g' || buildapp == 'mulet'
[test_resource_timing.html]
skip-if = buildapp == 'b2g' || buildapp == 'mulet'
[test_resource_timing_cross_origin.html]
skip-if = buildapp == 'b2g' || buildapp == 'mulet'
[test_performance_now.html]
[test_srcset_pref.html]
[test_showModalDialog.html]
skip-if = e10s || buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' #Don't run modal tests on Android # b2g(showmodaldialog) b2g-debug(showmodaldialog) b2g-desktop(showmodaldialog)
[test_showModalDialog_e10s.html]

Просмотреть файл

@ -218,8 +218,7 @@
}
addEventListener("load", function() {
SpecialPowers.pushPrefEnv({'set': [ ["layout.css.devPixelsPerPx", "1.0"],
[ "dom.image.srcset.enabled", true ]] },
SpecialPowers.pushPrefEnv({'set': [["layout.css.devPixelsPerPx", "1.0"]] },
function() {
// Create this after the pref is set, as it is guarding webIDL attributes
img = document.createElement("img");

Просмотреть файл

@ -293,9 +293,7 @@
}
addEventListener("load", function() {
SpecialPowers.pushPrefEnv({'set': [ ["layout.css.devPixelsPerPx", "1.0" ],
[ "dom.image.srcset.enabled", true ],
[ "dom.image.picture.enabled", true ]] },
SpecialPowers.pushPrefEnv({'set': [["layout.css.devPixelsPerPx", "1.0" ]] },
function() {
// Create these after the pref is set, as it is guarding webIDL attributes
img = document.createElement("img");

Просмотреть файл

@ -1,108 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=870022
-->
<head>
<title>Test for dom.image.picture.enabled (Bug 870022)</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="setupTest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=870022">Mozilla Bug 870022</a>
<!-- Tests that the picture pref can still be disabled, accounting
for dom.images.srcset.enabled being flipped on in the mean time. -->
<!-- these should all load red.png (naturalWidth 1) not big.png (natural
width 3000) regardless of dom.images.srcset.enabled being on or off -->
<div id="testContainer">
<picture>
<source srcset="http://example.com/tests/image/test/mochitest/big.png">
<img id="img1" src="http://example.com/tests/image/test/mochitest/red.png">
</picture>
<picture>
<source srcset="http://example.com/tests/image/test/mochitest/big.png 500w"
sizes="500w">
<img id="img2"
src="http://example.com/tests/image/test/mochitest/red.png"
srcset="http://example.com/tests/image/test/mochitest/big.png 500w"
sizes="50px">
</picture>
<!-- Should load red.png with srcset on, otherwise nothing -->
<img id="img-srcset-only"
srcset="http://example.com/tests/image/test/mochitest/big.png 500w, http://example.com/tests/image/test/mochitest/red.png 1x"
sizes="50px">
<!-- Should not load regardless of srcset pref -->
<img id="img-never"
srcset="http://example.com/tests/image/test/mochitest/big.png 500w"
sizes="50px">
</div>
<script type="application/javascript">
const srcsetPref = 'dom.image.srcset.enabled';
const picturePref = 'dom.image.picture.enabled';
SimpleTest.waitForExplicitFinish();
var srcsetEnabled = SpecialPowers.getBoolPref(srcsetPref);
var pictureEnabled = SpecialPowers.getBoolPref(picturePref);
is(pictureEnabled, true, "picture expected to be enabled by default");
function setupTest() {
SpecialPowers.pushPrefEnv({'set': [[ "dom.image.picture.enabled", false ]] }, function() {
var container = document.querySelector("#testContainer");
// We want to re-create the elements with the pref disabled to ensure
// webIDL attributes are not attached
var iframe = document.createElement("iframe");
iframe.addEventListener("load", function() {
runTest(iframe);
});
document.body.appendChild(iframe);
iframe.src = "data:text/html;base64," + btoa(container.innerHTML);
});
}
function runTest(iframe) {
var doc = iframe.contentDocument;
var win = iframe.contentWindow;
var img = doc.querySelector("img");
var source = doc.querySelector("source");
is(img.sizes, undefined, "sizes should not be visible on <img>");
is(source.sizes, undefined, "sizes should not be visible on <source>");
is(source.srcset, undefined, "srcset should not be visible on <source>");
var imgSizesDesc = Object.getOwnPropertyDescriptor(win.HTMLImageElement.prototype, "sizes");
var sourceSizesDesc = Object.getOwnPropertyDescriptor(win.HTMLSourceElement.prototype, "sizes");
var sourceSrcsetDesc = Object.getOwnPropertyDescriptor(win.HTMLSourceElement.prototype, "srcset");
is(imgSizesDesc, undefined, "HTMLImageElement should know nothing of sizes");
is(sourceSizesDesc, undefined, "HTMLSourceElement should know nothing of sizes");
is(sourceSrcsetDesc, undefined, "HTMLSourceElement should know nothing of srcset");
// Make sure the test images loaded red.png, which is 1x1, not big.png
for (var id of [ 'img1', 'img2' ]) {
var testImg = doc.getElementById(id);
is(testImg.naturalWidth, 1, "Image should have loaded small source");
}
var srcsetOnlyImg = doc.getElementById("img-srcset-only");
is(srcsetOnlyImg.naturalWidth, srcsetEnabled ? 1 : 0,
"srcset image should only load if srcset is enabled, and never the computed width candidate");
var neverImg = doc.getElementById("img-never");
is(neverImg.naturalWidth, 0, "Image should not have loaded");
SimpleTest.finish();
}
</script>
</body>
</html>

Просмотреть файл

@ -1,59 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=870021
-->
<head>
<title>Test for dom.image.srcset.enabled (Bug 870021)</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="setupTest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=870021">Mozilla Bug 870021</a>
<div id="imgContainer">
</div>
<script type="application/javascript">
const srcsetPref = 'dom.image.srcset.enabled';
SimpleTest.waitForExplicitFinish();
is(SpecialPowers.getBoolPref(srcsetPref), true, "srcset should be enabled by default");
function setupTest() {
// Ensure that disabling the pref works as expected
SpecialPowers.pushPrefEnv({'set': [[ "dom.image.srcset.enabled", false ]] }, function() {
var container = document.querySelector("#imgContainer");
var img = document.createElement("img");
img.setAttribute("src", "http://example.com/tests/image/test/mochitest/blue.png");
img.setAttribute("srcset", "http://example.com/tests/image/test/mochitest/big.png");
container.insertBefore(img, container.firstChild);
img.addEventListener("load", function imgLoad() {
img.removeEventListener("load", imgLoad);
runTest();
});
});
}
function runTest() {
var img = document.querySelector("img");
is(img.currentSrc, undefined, "currentSrc should not be visible");
is(img.srcset, undefined, "srcset should not be visible");
var currentSrcDesc = Object.getOwnPropertyDescriptor(HTMLImageElement.prototype, "currentSrc");
var srcsetDesc = Object.getOwnPropertyDescriptor(HTMLImageElement.prototype, "srcset");
is(currentSrcDesc, undefined, "HTMLImageElement should know nothing of currentSrc");
is(srcsetDesc, undefined, "HTMLImageElement should know nothing of srcset");
// Make sure the test image loaded the src image, which is 1x1, not the srcset image
is(img.naturalWidth, 1, "Image should have loaded small source");
SimpleTest.finish();
}
</script>
</body>
</html>

Просмотреть файл

@ -344,7 +344,7 @@ partial interface Document {
DOMString attrValue);
[Func="IsChromeOrXBL"]
Element? getBindingParent(Node node);
[Throws, Func="IsChromeOrXBL"]
[Throws, Func="IsChromeOrXBL", NeedsSubjectPrincipal]
void loadBindingDocument(DOMString documentURL);
// nsIDOMDocumentTouch

Просмотреть файл

@ -43,7 +43,7 @@ interface HTMLDocument : Document {
[Throws]
void writeln(DOMString... text);
[SetterThrows]
[SetterThrows, NeedsSubjectPrincipal]
attribute DOMString designMode;
[Throws]
boolean execCommand(DOMString commandId, optional boolean showUI = false,

Просмотреть файл

@ -37,6 +37,7 @@ partial interface HTMLEmbedElement {
partial interface HTMLEmbedElement {
// GetSVGDocument
[NeedsSubjectPrincipal]
Document? getSVGDocument();
};

Просмотреть файл

@ -24,6 +24,7 @@ interface HTMLFrameElement : HTMLElement {
attribute DOMString longDesc;
[SetterThrows]
attribute boolean noResize;
[NeedsSubjectPrincipal]
readonly attribute Document? contentDocument;
readonly attribute WindowProxy? contentWindow;

Просмотреть файл

@ -28,6 +28,7 @@ interface HTMLIFrameElement : HTMLElement {
attribute DOMString height;
[SetterThrows, Pure, Pref="network.http.enablePerElementReferrer"]
attribute DOMString referrerPolicy;
[NeedsSubjectPrincipal]
readonly attribute Document? contentDocument;
readonly attribute WindowProxy? contentWindow;
};
@ -49,6 +50,7 @@ partial interface HTMLIFrameElement {
partial interface HTMLIFrameElement {
// GetSVGDocument
[NeedsSubjectPrincipal]
Document? getSVGDocument();
};

Просмотреть файл

@ -22,7 +22,7 @@ interface HTMLImageElement : HTMLElement {
attribute DOMString alt;
[SetterThrows]
attribute DOMString src;
[SetterThrows, Pref="dom.image.srcset.enabled"]
[SetterThrows]
attribute DOMString srcset;
[SetterThrows]
attribute DOMString? crossOrigin;
@ -60,9 +60,8 @@ partial interface HTMLImageElement {
// [Update me: not in whatwg spec yet]
// http://picture.responsiveimages.org/#the-img-element
partial interface HTMLImageElement {
[SetterThrows, Pref="dom.image.picture.enabled"]
[SetterThrows]
attribute DOMString sizes;
[Pref="dom.image.srcset.enabled"]
readonly attribute DOMString currentSrc;
};

Просмотреть файл

@ -32,8 +32,10 @@ interface HTMLObjectElement : HTMLElement {
[Pure, SetterThrows]
attribute DOMString height;
// Not pure: can trigger about:blank instantiation
[NeedsSubjectPrincipal]
readonly attribute Document? contentDocument;
// Not pure: can trigger about:blank instantiation
[NeedsSubjectPrincipal]
readonly attribute WindowProxy? contentWindow;
readonly attribute boolean willValidate;
@ -74,6 +76,7 @@ partial interface HTMLObjectElement {
partial interface HTMLObjectElement {
// GetSVGDocument
[NeedsSubjectPrincipal]
Document? getSVGDocument();
};

Просмотреть файл

@ -4,6 +4,5 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[Pref="dom.image.picture.enabled"]
interface HTMLPictureElement : HTMLElement {
};

Просмотреть файл

@ -19,9 +19,9 @@ interface HTMLSourceElement : HTMLElement {
};
partial interface HTMLSourceElement {
[SetterThrows, Pref="dom.image.picture.enabled"]
[SetterThrows]
attribute DOMString srcset;
[SetterThrows, Pref="dom.image.picture.enabled"]
[SetterThrows]
attribute DOMString sizes;
[SetterThrows]
attribute DOMString media;

Просмотреть файл

@ -12,22 +12,22 @@
*/
interface Storage {
[Throws]
[Throws, NeedsSubjectPrincipal]
readonly attribute unsigned long length;
[Throws]
[Throws, NeedsSubjectPrincipal]
DOMString? key(unsigned long index);
[Throws]
[Throws, NeedsSubjectPrincipal]
getter DOMString? getItem(DOMString key);
[Throws]
[Throws, NeedsSubjectPrincipal]
setter creator void setItem(DOMString key, DOMString value);
[Throws]
[Throws, NeedsSubjectPrincipal]
deleter void removeItem(DOMString key);
[Throws]
[Throws, NeedsSubjectPrincipal]
void clear();
[ChromeOnly]

Просмотреть файл

@ -129,7 +129,7 @@ Window implements WindowSessionStorage;
// http://www.whatwg.org/specs/web-apps/current-work/
[NoInterfaceObject]
interface WindowLocalStorage {
[Throws] readonly attribute Storage? localStorage;
[Throws, NeedsSubjectPrincipal] readonly attribute Storage? localStorage;
};
Window implements WindowLocalStorage;

Просмотреть файл

@ -66,8 +66,6 @@ onload = function() {
["browser.send_pings", true],
["browser.send_pings.max_per_link", -1],
["dom.caches.enabled", true],
["dom.image.picture.enabled", true],
["dom.image.srcset.enabled", true],
["dom.requestcontext.enabled", true],
["dom.serviceWorkers.exemptFromPerDomainMax", true],
["dom.serviceWorkers.enabled", true],

Просмотреть файл

@ -1238,12 +1238,6 @@ EventRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
return true;
}
}
else if (mType.EqualsASCII(sEventStrings[STRING_readystatechange])) {
if (mReadyState == 4 && !mUploadEvent && !mProxy->mSeenLoadStart) {
// We've already dispatched premature abort events.
return true;
}
}
if (mProgressEvent) {
// Cache these for premature abort events.
@ -1310,6 +1304,13 @@ EventRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
XMLHttpRequestWorker* xhr = mProxy->mXMLHttpRequestPrivate;
xhr->UpdateState(*state.get(), mUseCachedArrayBufferResponse);
if (mType.EqualsASCII(sEventStrings[STRING_readystatechange])) {
if (mReadyState == 4 && !mUploadEvent && !mProxy->mSeenLoadStart) {
// We've already dispatched premature abort events.
return true;
}
}
if (mUploadEvent && !xhr->GetUploadObjectNoCreate()) {
return true;
}

Просмотреть файл

@ -59,6 +59,7 @@ support-files =
subdir/relativeLoad_sub_import.js
common_temporaryFileBlob.js
worker_temporaryFileBlob.js
worker_bug1300552.js
[test_xhr_overridemimetype_throws_on_invalid_state.html]
skip-if = buildapp == 'b2g' # Requires webgl support
@ -105,3 +106,4 @@ skip-if = (os == "win") || (os == "mac") || toolkit == 'android' #bug 798220
[test_relativeLoad.html]
skip-if = buildapp == 'b2g' # b2g(Failed to load script: relativeLoad_import.js) b2g-debug(Failed to load script: relativeLoad_import.js) b2g-desktop(Failed to load script: relativeLoad_import.js)
[test_temporaryFileBlob.html]
[test_bug1300552.html]

Просмотреть файл

@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for Bug 1300552</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript">
var w = new Worker('worker_bug1300552.js');
w.onmessage = function(e) {
if (e.data.type == 'info') {
info(e.data.msg);
} else if (e.data.type == 'check') {
ok(e.data.what, e.data.msg);
} else if (e.data.type == 'finish') {
SimpleTest.finish();
} else {
ok(false, 'Something wrong happened');
}
}
SimpleTest.waitForExplicitFinish();
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,33 @@
function info(msg) {
postMessage({type: 'info', msg: msg});
}
function ok(a, msg) {
postMessage({type: 'check', what: !!a, msg: msg});
}
function finish() {
postMessage({type: 'finish'});
}
info("Creating XHR...");
var xhr = new XMLHttpRequest();
xhr.open("POST", "echo.sjs");
xhr.responseType = 'arraybuffer';
info("Sending some data...");
var data = new Array(256).join("1234567890ABCDEF");
xhr.send({toString: function() { return data; }});
var aborted = false;
xhr.onprogress = function() {
info("Onprogress, we abort!");
aborted = true;
xhr.abort();
}
xhr.onloadend = function() {
ok(aborted, "We are still alive after an abort()!");
finish();
}

Просмотреть файл

@ -104,6 +104,24 @@ BufferRecycleBin::ClearRecycledBuffers()
mRecycledBufferSize = 0;
}
void
ImageContainer::EnsureImageClient(bool aCreate)
{
// If we're not forcing a new ImageClient, then we can skip this if we don't have an existing
// ImageClient, or if the existing one belongs to an IPC actor that is still open.
if (!aCreate && (!mImageClient || mImageClient->GetForwarder()->GetLayersIPCActor()->IPCOpen())) {
return;
}
RefPtr<ImageBridgeChild> imageBridge = ImageBridgeChild::GetSingleton();
if (imageBridge) {
mIPDLChild = new ImageContainerChild(this);
mImageClient = imageBridge->CreateImageClient(CompositableType::IMAGE, this, mIPDLChild);
MOZ_ASSERT(mImageClient);
mAsyncContainerID = mImageClient->GetAsyncID();
}
}
ImageContainer::ImageContainer(Mode flag)
: mReentrantMonitor("ImageContainer.mReentrantMonitor"),
mGenerationCounter(++sGenerationCounter),
@ -113,25 +131,11 @@ ImageContainer::ImageContainer(Mode flag)
mRecycleBin(new BufferRecycleBin()),
mCurrentProducerID(-1)
{
RefPtr<ImageBridgeChild> imageBridge = ImageBridgeChild::GetSingleton();
if (imageBridge) {
// the refcount of this ImageClient is 1. we don't use a RefPtr here because the refcount
// of this class must be done on the ImageBridge thread.
switch (flag) {
case SYNCHRONOUS:
break;
case ASYNCHRONOUS:
mIPDLChild = new ImageContainerChild(this);
mImageClient = imageBridge->CreateImageClient(CompositableType::IMAGE, this, mIPDLChild);
MOZ_ASSERT(mImageClient);
break;
default:
MOZ_ASSERT(false, "This flag is invalid.");
break;
}
if (flag == ASYNCHRONOUS) {
EnsureImageClient(true);
} else {
mAsyncContainerID = sInvalidAsyncContainerId;
}
mAsyncContainerID = mImageClient ? mImageClient->GetAsyncID()
: sInvalidAsyncContainerId;
}
ImageContainer::ImageContainer(uint64_t aAsyncContainerID)
@ -331,9 +335,10 @@ bool ImageContainer::IsAsync() const
return mAsyncContainerID != sInvalidAsyncContainerId;
}
uint64_t ImageContainer::GetAsyncContainerID() const
uint64_t ImageContainer::GetAsyncContainerID()
{
NS_ASSERTION(IsAsync(),"Shared image ID is only relevant to async ImageContainers");
EnsureImageClient(false);
return mAsyncContainerID;
}

Просмотреть файл

@ -480,7 +480,7 @@ public:
*
* Can be called from any thread.
*/
uint64_t GetAsyncContainerID() const;
uint64_t GetAsyncContainerID();
/**
* Returns if the container currently has an image.
@ -596,6 +596,8 @@ private:
// calling this function!
void EnsureActiveImage();
void EnsureImageClient(bool aCreate);
void NotifyCompositeInternal(const ImageCompositeNotification& aNotification);
// ReentrantMonitor to protect thread safe access to the "current

Просмотреть файл

@ -86,7 +86,7 @@ PersistentBufferProviderBasic::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFo
already_AddRefed<PersistentBufferProviderShared>
PersistentBufferProviderShared::Create(gfx::IntSize aSize,
gfx::SurfaceFormat aFormat,
KnowsCompositor* aFwd)
ShadowLayerForwarder* aFwd)
{
if (!aFwd || !aFwd->GetTextureForwarder()->IPCOpen()) {
return nullptr;
@ -110,7 +110,7 @@ PersistentBufferProviderShared::Create(gfx::IntSize aSize,
PersistentBufferProviderShared::PersistentBufferProviderShared(gfx::IntSize aSize,
gfx::SurfaceFormat aFormat,
KnowsCompositor* aFwd,
ShadowLayerForwarder* aFwd,
RefPtr<TextureClient>& aTexture)
: mSize(aSize)
@ -136,7 +136,7 @@ PersistentBufferProviderShared::~PersistentBufferProviderShared()
}
bool
PersistentBufferProviderShared::SetForwarder(KnowsCompositor* aFwd)
PersistentBufferProviderShared::SetForwarder(ShadowLayerForwarder* aFwd)
{
MOZ_ASSERT(aFwd);
if (!aFwd) {

Просмотреть файл

@ -9,7 +9,7 @@
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/RefPtr.h" // for RefPtr, already_AddRefed, etc
#include "mozilla/layers/LayersTypes.h"
#include "mozilla/layers/TextureForwarder.h"
#include "mozilla/layers/ShadowLayers.h"
#include "mozilla/gfx/Types.h"
#include "mozilla/Vector.h"
@ -64,7 +64,7 @@ public:
virtual void OnShutdown() {}
virtual bool SetForwarder(KnowsCompositor* aFwd) { return true; }
virtual bool SetForwarder(ShadowLayerForwarder* aFwd) { return true; }
/**
* Return true if this provider preserves the drawing state (clips, transforms,
@ -117,7 +117,7 @@ public:
static already_AddRefed<PersistentBufferProviderShared>
Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
KnowsCompositor* aFwd);
ShadowLayerForwarder* aFwd);
virtual LayersBackend GetType() override { return LayersBackend::LAYERS_CLIENT; }
@ -135,12 +135,12 @@ public:
virtual void OnShutdown() override { Destroy(); }
virtual bool SetForwarder(KnowsCompositor* aFwd) override;
virtual bool SetForwarder(ShadowLayerForwarder* aFwd) override;
virtual bool PreservesDrawingState() const override { return false; }
protected:
PersistentBufferProviderShared(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
KnowsCompositor* aFwd,
ShadowLayerForwarder* aFwd,
RefPtr<TextureClient>& aTexture);
~PersistentBufferProviderShared();
@ -152,7 +152,7 @@ protected:
gfx::IntSize mSize;
gfx::SurfaceFormat mFormat;
RefPtr<KnowsCompositor> mFwd;
RefPtr<ShadowLayerForwarder> mFwd;
Vector<RefPtr<TextureClient>, 4> mTextures;
// Offset of the texture in mTextures that the canvas uses.
Maybe<uint32_t> mBack;

Просмотреть файл

@ -1255,7 +1255,7 @@ nsEventStatus AsyncPanZoomController::OnTouchEnd(const MultiTouchInput& aEvent)
SetState(NOTHING);
APZC_LOG("%p starting a fling animation if %f >= %f\n", this,
flingVelocity.Length(), gfxPrefs::APZFlingMinVelocityThreshold());
flingVelocity.Length().value, gfxPrefs::APZFlingMinVelocityThreshold());
if (flingVelocity.Length() < gfxPrefs::APZFlingMinVelocityThreshold()) {
return nsEventStatus_eConsumeNoDefault;

Просмотреть файл

@ -645,6 +645,9 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
newTransform, aRect, transformedClipRect,
dest, buffer)) {
// we succeeded in convert and scaling
} else if (source->mFromYCBCR &&
!source->GetSurface(dest)) {
gfxWarning() << "Failed to get YCbCr to rgb surface.";
} else if (source->mFromYCBCR &&
AttemptVideoScale(source, sourceMask, aOpacity, blendMode,
texturedEffect,

Просмотреть файл

@ -126,7 +126,7 @@ ClientCanvasLayer::RenderLayer()
FirePreTransactionCallback();
if (mBufferProvider && mBufferProvider->GetTextureClient()) {
if (!mBufferProvider->SetForwarder(mCanvasClient->GetForwarder())) {
if (!mBufferProvider->SetForwarder(ClientManager()->AsShadowForwarder())) {
gfxCriticalNote << "BufferProvider::SetForwarder failed";
return;
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше