Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
merge mozilla-inbound to mozilla-central. r=merge a=merge
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: Gsw48p934sI
  • Loading branch information
Archaeopteryx committed Sep 2, 2017
2 parents 3ea29de + 038c259 commit 568a771
Show file tree
Hide file tree
Showing 73 changed files with 1,838 additions and 525 deletions.
38 changes: 38 additions & 0 deletions accessible/windows/msaa/Compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@
using namespace mozilla;
using namespace mozilla::a11y;

/**
* String versions of consumer flags. See GetHumanReadableConsumersStr.
*/
static const wchar_t* ConsumerStringMap[CONSUMERS_ENUM_LEN+1] = {
L"NVDA",
L"JAWS",
L"OLDJAWS",
L"WE",
L"DOLPHIN",
L"SEROTEK",
L"COBRA",
L"ZOOMTEXT",
L"KAZAGURU",
L"YOUDAO",
L"UNKNOWN",
L"UIAUTOMATION",
L"\0"
};

/**
* Return true if module version is lesser than the given version.
*/
Expand Down Expand Up @@ -398,3 +417,22 @@ Compatibility::GetActCtxResourceId()
#endif // defined(HAVE_64BIT_BUILD)
}

// static
void
Compatibility::GetHumanReadableConsumersStr(nsAString &aResult)
{
bool appened = false;
uint32_t index = 0;
for (uint32_t consumers = sConsumers; consumers; consumers = consumers >> 1) {
if (consumers & 0x1) {
if (appened) {
aResult.AppendLiteral(",");
}
aResult.Append(ConsumerStringMap[index]);
appened = true;
}
if (++index > CONSUMERS_ENUM_LEN) {
break;
}
}
}
8 changes: 8 additions & 0 deletions accessible/windows/msaa/Compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef COMPATIBILITY_MANAGER_H
#define COMPATIBILITY_MANAGER_H

#include "nsString.h"
#include <stdint.h>

namespace mozilla {
Expand Down Expand Up @@ -45,6 +46,12 @@ class Compatibility
*/
static uint16_t GetActCtxResourceId();

/**
* Return a string describing sConsumers suitable for about:support.
* Exposed through nsIXULRuntime.accessibilityInstantiator.
*/
static void GetHumanReadableConsumersStr(nsAString &aResult);

private:
Compatibility();
Compatibility(const Compatibility&);
Expand Down Expand Up @@ -74,6 +81,7 @@ class Compatibility
UNKNOWN = 1 << 10,
UIAUTOMATION = 1 << 11
};
#define CONSUMERS_ENUM_LEN 12

private:
static uint32_t sConsumers;
Expand Down
6 changes: 4 additions & 2 deletions browser/base/content/tabbrowser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2327,6 +2327,7 @@

<method name="_insertBrowser">
<parameter name="aTab"/>
<parameter name="aInsertedOnTabCreation"/>
<body>
<![CDATA[
"use strict";
Expand Down Expand Up @@ -2388,7 +2389,8 @@
this._outerWindowIDBrowserMap.set(browser.outerWindowID, browser);
}
var evt = new CustomEvent("TabBrowserInserted", { bubbles: true, detail: {} });
var evt = new CustomEvent("TabBrowserInserted",
{ bubbles: true, detail: { insertedOnTabCreation: aInsertedOnTabCreation } });
aTab.dispatchEvent(evt);
]]>
</body>
Expand Down Expand Up @@ -2639,7 +2641,7 @@
b.registeredOpenURI = lazyBrowserURI;
}
} else {
this._insertBrowser(t);
this._insertBrowser(t, true);
}
// Dispatch a new tab notification. We do this once we're
Expand Down
4 changes: 4 additions & 0 deletions browser/components/extensions/ext-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,10 @@ class Tab extends TabBase {
return this.nativeTab.linkedBrowser;
}

get discarded() {
return !this.nativeTab.linkedPanel;
}

get frameLoader() {
// If we don't have a frameLoader yet, just return a dummy with no width and
// height.
Expand Down
5 changes: 5 additions & 0 deletions browser/components/extensions/ext-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ this.tabs = class extends ExtensionAPI {
needed.push("pinned");
} else if (event.type == "TabUnpinned") {
needed.push("pinned");
} else if (event.type == "TabBrowserInserted" &&
!event.detail.insertedOnTabCreation) {
needed.push("discarded");
}

let tab = tabManager.getWrapper(event.originalTarget);
Expand Down Expand Up @@ -290,12 +293,14 @@ this.tabs = class extends ExtensionAPI {
windowTracker.addListener("TabAttrModified", listener);
windowTracker.addListener("TabPinned", listener);
windowTracker.addListener("TabUnpinned", listener);
windowTracker.addListener("TabBrowserInserted", listener);

return () => {
windowTracker.removeListener("status", statusListener);
windowTracker.removeListener("TabAttrModified", listener);
windowTracker.removeListener("TabPinned", listener);
windowTracker.removeListener("TabUnpinned", listener);
windowTracker.removeListener("TabBrowserInserted", listener);
};
}).api(),

Expand Down
11 changes: 11 additions & 0 deletions browser/components/extensions/schemas/tabs.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"title": {"type": "string", "optional": true, "permissions": ["tabs"], "description": "The title of the tab. This property is only present if the extension's manifest includes the <code>\"tabs\"</code> permission."},
"favIconUrl": {"type": "string", "optional": true, "permissions": ["tabs"], "description": "The URL of the tab's favicon. This property is only present if the extension's manifest includes the <code>\"tabs\"</code> permission. It may also be an empty string if the tab is loading."},
"status": {"type": "string", "optional": true, "description": "Either <em>loading</em> or <em>complete</em>."},
"discarded": {"type": "boolean", "optional": true, "description": "True while the tab is not loaded with content."},
"incognito": {"type": "boolean", "description": "Whether the tab is in an incognito window."},
"width": {"type": "integer", "optional": true, "description": "The width of the tab in pixels."},
"height": {"type": "integer", "optional": true, "description": "The height of the tab in pixels."},
Expand Down Expand Up @@ -589,6 +590,11 @@
"optional": true,
"description": "Whether the tabs have completed loading."
},
"discarded": {
"type": "boolean",
"optional": true,
"description": "True while the tabs are not loaded with content."
},
"title": {
"type": "string",
"optional": true,
Expand Down Expand Up @@ -1195,6 +1201,11 @@
"optional": true,
"description": "The status of the tab. Can be either <em>loading</em> or <em>complete</em>."
},
"discarded": {
"type": "boolean",
"optional": true,
"description": "True while the tab is not loaded with content."
},
"url": {
"type": "string",
"optional": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ skip-if = debug || asan # Bug 1354681
[browser_ext_tabs_create.js]
[browser_ext_tabs_create_invalid_url.js]
[browser_ext_tabs_detectLanguage.js]
[browser_ext_tabs_discarded.js]
[browser_ext_tabs_duplicate.js]
[browser_ext_tabs_events.js]
[browser_ext_tabs_executeScript.js]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
/* global gBrowser SessionStore */
"use strict";

let lazyTabState = {entries: [{url: "http://example.com/", title: "Example Domain"}]};

add_task(async function test_discarded() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["tabs"],
},

background: async function() {
let onCreatedTabData = [];
let discardedEventData = [];

async function finishTest() {
browser.test.assertEq(0, discardedEventData.length, "number of discarded events fired");

onCreatedTabData.sort((data1, data2) => data1.index - data2.index);
browser.test.assertEq(false, onCreatedTabData[0].discarded, "non-lazy tab onCreated discard property");
browser.test.assertEq(true, onCreatedTabData[1].discarded, "lazy tab onCreated discard property");

let tabs = await browser.tabs.query({currentWindow: true});
tabs.sort((tab1, tab2) => tab1.index - tab2.index);

browser.test.assertEq(false, tabs[1].discarded, "non-lazy tab query discard property");
browser.test.assertEq(true, tabs[2].discarded, "lazy tab query discard property");

let updatedTab = await browser.tabs.update(tabs[2].id, {active: true});
browser.test.assertEq(false, updatedTab.discarded, "lazy to non-lazy update discard property");
browser.test.assertEq(false, discardedEventData[0], "lazy to non-lazy onUpdated discard property");

browser.test.notifyPass("test-finished");
}

browser.tabs.onUpdated.addListener(function(tabId, updatedInfo) {
if ("discarded" in updatedInfo) {
discardedEventData.push(updatedInfo.discarded);
}
});

browser.tabs.onCreated.addListener(function(tab) {
onCreatedTabData.push({discarded: tab.discarded, index: tab.index});
if (onCreatedTabData.length == 2) {
finishTest();
}
});
},
});

await extension.startup();

let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com");

let tab2 = BrowserTestUtils.addTab(gBrowser, "about:blank", {createLazyBrowser: true});
SessionStore.setTabState(tab2, JSON.stringify(lazyTabState));

await extension.awaitFinish("test-finished");
await extension.unload();

await BrowserTestUtils.removeTab(tab1);
await BrowserTestUtils.removeTab(tab2);
});

7 changes: 0 additions & 7 deletions dom/base/Attr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,6 @@ Attr::GetChildAt(uint32_t aIndex) const
return nullptr;
}

nsIContent * const *
Attr::GetChildArray(uint32_t* aChildCount) const
{
*aChildCount = 0;
return nullptr;
}

int32_t
Attr::IndexOf(const nsINode* aPossibleChild) const
{
Expand Down
1 change: 0 additions & 1 deletion dom/base/Attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class Attr final : public nsIAttribute,
virtual bool IsNodeOfType(uint32_t aFlags) const override;
virtual uint32_t GetChildCount() const override;
virtual nsIContent *GetChildAt(uint32_t aIndex) const override;
virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const override;
virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
bool aNotify) override;
Expand Down
12 changes: 9 additions & 3 deletions dom/base/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3044,9 +3044,15 @@ Element::List(FILE* out, int32_t aIndent,
static_cast<unsigned long long>(State().GetInternalValue()));
fprintf(out, " flags=[%08x]", static_cast<unsigned int>(GetFlags()));
if (IsCommonAncestorForRangeInSelection()) {
const nsTHashtable<nsPtrHashKey<nsRange>>* ranges =
GetExistingCommonAncestorRanges();
fprintf(out, " ranges:%d", ranges ? ranges->Count() : 0);
const LinkedList<nsRange>* ranges = GetExistingCommonAncestorRanges();
int32_t count = 0;
if (ranges) {
// Can't use range-based iteration on a const LinkedList, unfortunately.
for (const nsRange* r = ranges->getFirst(); r; r = r->getNext()) {
++count;
}
}
fprintf(out, " ranges:%d", count);
}
fprintf(out, " primaryframe=%p", static_cast<void*>(GetPrimaryFrame()));
fprintf(out, " refcount=%" PRIuPTR "<", mRefCnt.get());
Expand Down
6 changes: 0 additions & 6 deletions dom/base/FragmentOrElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2327,12 +2327,6 @@ FragmentOrElement::GetChildAt(uint32_t aIndex) const
return mAttrsAndChildren.GetSafeChildAt(aIndex);
}

nsIContent * const *
FragmentOrElement::GetChildArray(uint32_t* aChildCount) const
{
return mAttrsAndChildren.GetChildArray(aChildCount);
}

int32_t
FragmentOrElement::IndexOf(const nsINode* aPossibleChild) const
{
Expand Down
1 change: 0 additions & 1 deletion dom/base/FragmentOrElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ class FragmentOrElement : public nsIContent
// nsINode interface methods
virtual uint32_t GetChildCount() const override;
virtual nsIContent *GetChildAt(uint32_t aIndex) const override;
virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const override;
virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
bool aNotify) override;
Expand Down
7 changes: 0 additions & 7 deletions dom/base/nsDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4354,13 +4354,6 @@ nsDocument::GetChildCount() const
return mChildren.ChildCount();
}

nsIContent * const *
nsDocument::GetChildArray(uint32_t* aChildCount) const
{
return mChildren.GetChildArray(aChildCount);
}


nsresult
nsDocument::InsertChildAt(nsIContent* aKid, uint32_t aIndex,
bool aNotify)
Expand Down
1 change: 0 additions & 1 deletion dom/base/nsDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,6 @@ class nsDocument : public nsIDocument,
// nsINode
virtual bool IsNodeOfType(uint32_t aFlags) const override;
virtual nsIContent *GetChildAt(uint32_t aIndex) const override;
virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const override;
virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
virtual uint32_t GetChildCount() const override;
virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
Expand Down
7 changes: 0 additions & 7 deletions dom/base/nsGenericDOMDataNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,13 +681,6 @@ nsGenericDOMDataNode::GetChildAt(uint32_t aIndex) const
return nullptr;
}

nsIContent * const *
nsGenericDOMDataNode::GetChildArray(uint32_t* aChildCount) const
{
*aChildCount = 0;
return nullptr;
}

int32_t
nsGenericDOMDataNode::IndexOf(const nsINode* aPossibleChild) const
{
Expand Down
1 change: 0 additions & 1 deletion dom/base/nsGenericDOMDataNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class nsGenericDOMDataNode : public nsIContent
// nsINode methods
virtual uint32_t GetChildCount() const override;
virtual nsIContent *GetChildAt(uint32_t aIndex) const override;
virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const override;
virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
bool aNotify) override;
Expand Down
Loading

0 comments on commit 568a771

Please sign in to comment.