Merge mozilla-central to autoland

This commit is contained in:
Carsten "Tomcat" Book 2017-03-08 17:04:17 +01:00
commit 96fe421b34
368 changed files with 88515 additions and 29216 deletions

View File

@ -154,6 +154,7 @@ AccessibleNode::Get(JSContext* aCX, const nsAString& aAttribute,
{ {
if (!mIntl) { if (!mIntl) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
} }
nsCOMPtr<nsIPersistentProperties> attrs = mIntl->Attributes(); nsCOMPtr<nsIPersistentProperties> attrs = mIntl->Attributes();
@ -163,6 +164,7 @@ AccessibleNode::Get(JSContext* aCX, const nsAString& aAttribute,
JS::Rooted<JS::Value> jsval(aCX); JS::Rooted<JS::Value> jsval(aCX);
if (!ToJSValue(aCX, value, &jsval)) { if (!ToJSValue(aCX, value, &jsval)) {
aRv.Throw(NS_ERROR_UNEXPECTED); aRv.Throw(NS_ERROR_UNEXPECTED);
return;
} }
aValue.set(jsval); aValue.set(jsval);

View File

@ -392,7 +392,7 @@ function* testSubtreeRule(browser, target, rule, expected) {
yield ContentTask.spawn(browser, target.id, id => { yield ContentTask.spawn(browser, target.id, id => {
let elm = content.document.getElementById(id); let elm = content.document.getElementById(id);
while (elm.firstChild) { while (elm.firstChild) {
elm.removeChild(elm.firstChild); elm.firstChild.remove();
} }
}); });
yield updateAccessibleIfNeeded(onEvent, target); yield updateAccessibleIfNeeded(onEvent, target);

View File

@ -157,7 +157,7 @@ addAccessibleTask(`
yield ContentTask.spawn(browser, {}, () => { yield ContentTask.spawn(browser, {}, () => {
// Remove HTML element. // Remove HTML element.
let docNode = content.document.getElementById('iframe').contentDocument; let docNode = content.document.getElementById('iframe').contentDocument;
docNode.removeChild(docNode.firstChild); docNode.firstChild.remove();
}); });
let event = yield reorderEventPromise; let event = yield reorderEventPromise;
@ -235,7 +235,7 @@ addAccessibleTask(`
let docEl = let docEl =
content.document.getElementById('iframe').contentDocument.documentElement; content.document.getElementById('iframe').contentDocument.documentElement;
// Remove aftermath of this test before next test starts. // Remove aftermath of this test before next test starts.
docEl.removeChild(docEl.firstChild); docEl.firstChild.remove();
}); });
// Make sure reorder event was fired and that the input was removed. // Make sure reorder event was fired and that the input was removed.
yield reorderEventPromise; yield reorderEventPromise;

View File

@ -56,7 +56,7 @@ addAccessibleTask('<select id="select"></select>', function*(browser, accDoc) {
// Remove grouping from combobox // Remove grouping from combobox
yield ContentTask.spawn(browser, {}, () => { yield ContentTask.spawn(browser, {}, () => {
let contentSelect = content.document.getElementById('select'); let contentSelect = content.document.getElementById('select');
contentSelect.removeChild(contentSelect.firstChild); contentSelect.firstChild.remove();
}); });
yield onEvent; yield onEvent;

View File

@ -414,8 +414,8 @@
var l1 = doc.firstChild; var l1 = doc.firstChild;
this.target = l1.firstChild; this.target = l1.firstChild;
var l2 = doc.lastChild; var l2 = doc.lastChild;
l1.DOMNode.removeChild(l1.DOMNode.firstChild); l1.DOMNode.firstChild.remove();
l2.DOMNode.removeChild(l2.DOMNode.firstChild); l2.DOMNode.firstChild.remove();
} }
this.check = function hideHideNDestroyDoc_check() this.check = function hideHideNDestroyDoc_check()

View File

@ -51,7 +51,7 @@
this.invoke = function removeChildSpan_invoke() this.invoke = function removeChildSpan_invoke()
{ {
// remove HTML span, a first child of the node // remove HTML span, a first child of the node
this.DOMNode.removeChild(this.DOMNode.firstChild); this.DOMNode.firstChild.remove();
} }
this.getID = function removeChildSpan_getID() this.getID = function removeChildSpan_getID()
@ -162,7 +162,7 @@
this.DOMNode.removeChild(this.DOMNode.lastChild); this.DOMNode.removeChild(this.DOMNode.lastChild);
} else { } else {
while (this.DOMNode.firstChild) while (this.DOMNode.firstChild)
this.DOMNode.removeChild(this.DOMNode.firstChild); this.DOMNode.firstChild.remove();
} }
} }

View File

@ -316,7 +316,7 @@ function testNameForSubtreeRule(aElm, aRule)
waitForEvent(EVENT_REORDER, aElm, gTestIterator.iterateNext, gTestIterator); waitForEvent(EVENT_REORDER, aElm, gTestIterator.iterateNext, gTestIterator);
while (aElm.firstChild) while (aElm.firstChild)
aElm.removeChild(aElm.firstChild); aElm.firstChild.remove();
} }
/** /**

View File

@ -266,7 +266,7 @@
// Remove HTML element. // Remove HTML element.
var docNode = getDocNode(aID); var docNode = getDocNode(aID);
docNode.removeChild(docNode.firstChild); docNode.firstChild.remove();
} }
this.getID = function removeHTMLFromIFrameDoc_getID() this.getID = function removeHTMLFromIFrameDoc_getID()

View File

@ -64,7 +64,7 @@
this.invoke = function removeRemove_invoke() this.invoke = function removeRemove_invoke()
{ {
getNode(aContainer).removeChild(getNode(aContainer).firstChild); getNode(aContainer).firstChild.remove();
} }
this.finalCheck = function removeRemove_finalCheck() this.finalCheck = function removeRemove_finalCheck()

View File

@ -77,7 +77,7 @@
this.invoke = function removeOptGroup_invoke() this.invoke = function removeOptGroup_invoke()
{ {
this.option1Node = this.selectNode.firstChild.firstChild; this.option1Node = this.selectNode.firstChild.firstChild;
this.selectNode.removeChild(this.selectNode.firstChild); this.selectNode.firstChild.remove();
} }
this.eventSeq = [ this.eventSeq = [

View File

@ -241,7 +241,7 @@ var ctrlTab = {
aPreview._tab = aTab; aPreview._tab = aTab;
if (aPreview.firstChild) if (aPreview.firstChild)
aPreview.removeChild(aPreview.firstChild); aPreview.firstChild.remove();
if (aTab) { if (aTab) {
let canvasWidth = this.canvasWidth; let canvasWidth = this.canvasWidth;
let canvasHeight = this.canvasHeight; let canvasHeight = this.canvasHeight;

View File

@ -330,7 +330,7 @@ var gFxAccounts = {
populateSendTabToDevicesMenu(devicesPopup, url, title) { populateSendTabToDevicesMenu(devicesPopup, url, title) {
// remove existing menu items // remove existing menu items
while (devicesPopup.hasChildNodes()) { while (devicesPopup.hasChildNodes()) {
devicesPopup.removeChild(devicesPopup.firstChild); devicesPopup.firstChild.remove();
} }
const fragment = document.createDocumentFragment(); const fragment = document.createDocumentFragment();

View File

@ -746,7 +746,7 @@ HistoryMenu.prototype = {
// remove existing menu items // remove existing menu items
while (undoPopup.hasChildNodes()) while (undoPopup.hasChildNodes())
undoPopup.removeChild(undoPopup.firstChild); undoPopup.firstChild.remove();
// no restorable tabs, so make sure menu is disabled, and return // no restorable tabs, so make sure menu is disabled, and return
if (this._getClosedTabCount() == 0) { if (this._getClosedTabCount() == 0) {
@ -782,7 +782,7 @@ HistoryMenu.prototype = {
// remove existing menu items // remove existing menu items
while (undoPopup.hasChildNodes()) while (undoPopup.hasChildNodes())
undoPopup.removeChild(undoPopup.firstChild); undoPopup.firstChild.remove();
// no restorable windows, so make sure menu is disabled, and return // no restorable windows, so make sure menu is disabled, and return
if (SessionStore.getClosedWindowCount() == 0) { if (SessionStore.getClosedWindowCount() == 0) {

View File

@ -418,7 +418,7 @@ function resetPageInfo(args) {
/* Reset Feeds Tab */ /* Reset Feeds Tab */
var feedListbox = document.getElementById("feedListbox"); var feedListbox = document.getElementById("feedListbox");
while (feedListbox.firstChild) while (feedListbox.firstChild)
feedListbox.removeChild(feedListbox.firstChild); feedListbox.firstChild.remove();
/* Call registered overlay reset functions */ /* Call registered overlay reset functions */
onResetRegistry.forEach(function(func) { func(); }); onResetRegistry.forEach(function(func) { func(); });

View File

@ -306,7 +306,7 @@ function setText(id, value) {
element.value = value; element.value = value;
else { else {
if (element.hasChildNodes()) if (element.hasChildNodes())
element.removeChild(element.firstChild); element.firstChild.remove();
var textNode = document.createTextNode(value); var textNode = document.createTextNode(value);
element.appendChild(textNode); element.appendChild(textNode);
} }

View File

@ -490,7 +490,7 @@ function createUserContextMenu(event, {
useAccessKeys = true useAccessKeys = true
} = {}) { } = {}) {
while (event.target.hasChildNodes()) { while (event.target.hasChildNodes()) {
event.target.removeChild(event.target.firstChild); event.target.firstChild.remove();
} }
let bundle = document.getElementById("bundle_browser"); let bundle = document.getElementById("bundle_browser");

View File

@ -244,12 +244,12 @@ const CustomizableWidgets = [
let recentlyClosedTabs = doc.getElementById("PanelUI-recentlyClosedTabs"); let recentlyClosedTabs = doc.getElementById("PanelUI-recentlyClosedTabs");
while (recentlyClosedTabs.firstChild) { while (recentlyClosedTabs.firstChild) {
recentlyClosedTabs.removeChild(recentlyClosedTabs.firstChild); recentlyClosedTabs.firstChild.remove();
} }
let recentlyClosedWindows = doc.getElementById("PanelUI-recentlyClosedWindows"); let recentlyClosedWindows = doc.getElementById("PanelUI-recentlyClosedWindows");
while (recentlyClosedWindows.firstChild) { while (recentlyClosedWindows.firstChild) {
recentlyClosedWindows.removeChild(recentlyClosedWindows.firstChild); recentlyClosedWindows.firstChild.remove();
} }
let utils = RecentlyClosedTabsAndWindowsMenuUtils; let utils = RecentlyClosedTabsAndWindowsMenuUtils;

View File

@ -492,7 +492,7 @@ const PanelUI = {
// Remove all buttons from the view // Remove all buttons from the view
while (items.firstChild) { while (items.firstChild) {
items.removeChild(items.firstChild); items.firstChild.remove();
} }
// Add the current set of menuitems of the Help menu to this view // Add the current set of menuitems of the Help menu to this view

View File

@ -173,7 +173,7 @@ FeedWriter.prototype = {
let element = this._document.getElementById(id); let element = this._document.getElementById(id);
let textNode = text.createDocumentFragment(element); let textNode = text.createDocumentFragment(element);
while (element.hasChildNodes()) while (element.hasChildNodes())
element.removeChild(element.firstChild); element.firstChild.remove();
element.appendChild(textNode); element.appendChild(textNode);
if (text.base) { if (text.base) {
element.setAttributeNS(XML_NS, "base", text.base.spec); element.setAttributeNS(XML_NS, "base", text.base.spec);

View File

@ -185,7 +185,7 @@ var MigrationWizard = { /* exported MigrationWizard */
var profiles = document.getElementById("profiles"); var profiles = document.getElementById("profiles");
while (profiles.hasChildNodes()) while (profiles.hasChildNodes())
profiles.removeChild(profiles.firstChild); profiles.firstChild.remove();
// Note that this block is still reached even if the user chose 'From File' // Note that this block is still reached even if the user chose 'From File'
// and we canceled the dialog. When that happens, _migrator will be null. // and we canceled the dialog. When that happens, _migrator will be null.
@ -225,7 +225,7 @@ var MigrationWizard = { /* exported MigrationWizard */
onImportItemsPageShow() { onImportItemsPageShow() {
var dataSources = document.getElementById("dataSources"); var dataSources = document.getElementById("dataSources");
while (dataSources.hasChildNodes()) while (dataSources.hasChildNodes())
dataSources.removeChild(dataSources.firstChild); dataSources.firstChild.remove();
var items = this._migrator.getMigrateData(this._selectedProfile, this._autoMigrate); var items = this._migrator.getMigrateData(this._selectedProfile, this._autoMigrate);
for (var i = 0; i < 16; ++i) { for (var i = 0; i < 16; ++i) {
@ -367,7 +367,7 @@ var MigrationWizard = { /* exported MigrationWizard */
_listItems(aID) { _listItems(aID) {
var items = document.getElementById(aID); var items = document.getElementById(aID);
while (items.hasChildNodes()) while (items.hasChildNodes())
items.removeChild(items.firstChild); items.firstChild.remove();
var itemID; var itemID;
for (var i = 0; i < 16; ++i) { for (var i = 0; i < 16; ++i) {

View File

@ -1011,7 +1011,7 @@ PlacesToolbar.prototype = {
this._openedMenuButton = null; this._openedMenuButton = null;
while (this._rootElt.hasChildNodes()) { while (this._rootElt.hasChildNodes()) {
this._rootElt.removeChild(this._rootElt.firstChild); this._rootElt.firstChild.remove();
} }
let cc = this._resultNode.childCount; let cc = this._resultNode.childCount;
@ -1952,7 +1952,7 @@ PlacesPanelMenuView.prototype = {
// Container is the toolbar itself. // Container is the toolbar itself.
while (this._rootElt.hasChildNodes()) { while (this._rootElt.hasChildNodes()) {
this._rootElt.removeChild(this._rootElt.firstChild); this._rootElt.firstChild.remove();
} }
for (let i = 0; i < this._resultNode.childCount; ++i) { for (let i = 0; i < this._resultNode.childCount; ++i) {

View File

@ -419,7 +419,7 @@ var PlacesOrganizer = {
// Remove existing menu items. Last item is the restoreFromFile item. // Remove existing menu items. Last item is the restoreFromFile item.
while (restorePopup.childNodes.length > 1) while (restorePopup.childNodes.length > 1)
restorePopup.removeChild(restorePopup.firstChild); restorePopup.firstChild.remove();
Task.spawn(function* () { Task.spawn(function* () {
let backupFiles = yield PlacesBackups.getBackupFiles(); let backupFiles = yield PlacesBackups.getBackupFiles();
@ -1007,7 +1007,7 @@ var ViewMenu = {
return endElement; return endElement;
} }
while (popup.hasChildNodes()) { while (popup.hasChildNodes()) {
popup.removeChild(popup.firstChild); popup.firstChild.remove();
} }
return null; return null;
}, },

View File

@ -81,7 +81,7 @@ var gBlocklistManager = {
let blocklistsText = document.getElementById("blocklistsText"); let blocklistsText = document.getElementById("blocklistsText");
while (blocklistsText.hasChildNodes()) { while (blocklistsText.hasChildNodes()) {
blocklistsText.removeChild(blocklistsText.firstChild); blocklistsText.firstChild.remove();
} }
blocklistsText.appendChild(document.createTextNode(params.introText)); blocklistsText.appendChild(document.createTextNode(params.introText));

View File

@ -557,7 +557,7 @@ var gAdvancedPane = {
var list = document.getElementById("offlineAppsList"); var list = document.getElementById("offlineAppsList");
while (list.firstChild) { while (list.firstChild) {
list.removeChild(list.firstChild); list.firstChild.remove();
} }
var groups; var groups;

View File

@ -97,7 +97,7 @@ var gLanguagesDialog = {
_buildAvailableLanguageList() { _buildAvailableLanguageList() {
var availableLanguagesPopup = document.getElementById("availableLanguagesPopup"); var availableLanguagesPopup = document.getElementById("availableLanguagesPopup");
while (availableLanguagesPopup.hasChildNodes()) while (availableLanguagesPopup.hasChildNodes())
availableLanguagesPopup.removeChild(availableLanguagesPopup.firstChild); availableLanguagesPopup.firstChild.remove();
// Sort the list of languages by name // Sort the list of languages by name
this._availableLanguagesList.sort(function(a, b) { this._availableLanguagesList.sort(function(a, b) {
@ -119,7 +119,7 @@ var gLanguagesDialog = {
readAcceptLanguages() { readAcceptLanguages() {
while (this._activeLanguages.hasChildNodes()) while (this._activeLanguages.hasChildNodes())
this._activeLanguages.removeChild(this._activeLanguages.firstChild); this._activeLanguages.firstChild.remove();
var selectedIndex = 0; var selectedIndex = 0;
var preference = document.getElementById("intl.accept_languages"); var preference = document.getElementById("intl.accept_languages");

View File

@ -218,7 +218,7 @@ var gPermissionManager = {
var permissionsText = document.getElementById("permissionsText"); var permissionsText = document.getElementById("permissionsText");
while (permissionsText.hasChildNodes()) while (permissionsText.hasChildNodes())
permissionsText.removeChild(permissionsText.firstChild); permissionsText.firstChild.remove();
permissionsText.appendChild(document.createTextNode(aParams.introText)); permissionsText.appendChild(document.createTextNode(aParams.introText));
document.title = aParams.windowTitle; document.title = aParams.windowTitle;

View File

@ -100,7 +100,7 @@ SyncedTabsDeckView.prototype = {
_clearChilden() { _clearChilden() {
while (this.container.firstChild) { while (this.container.firstChild) {
this.container.removeChild(this.container.firstChild); this.container.firstChild.remove();
} }
}, },

View File

@ -169,7 +169,7 @@ TabListView.prototype = {
_clearChilden(node) { _clearChilden(node) {
let parent = node || this.container; let parent = node || this.container;
while (parent.firstChild) { while (parent.firstChild) {
parent.removeChild(parent.firstChild); parent.firstChild.remove();
} }
}, },

View File

@ -1236,7 +1236,7 @@ this.UITour = {
// Remove all the children of the notice (rating container // Remove all the children of the notice (rating container
// and the flex). // and the flex).
while (notice.firstChild) { while (notice.firstChild) {
notice.removeChild(notice.firstChild); notice.firstChild.remove();
} }
// Make sure that we have a valid URL. If we haven't, do not open the engagement page. // Make sure that we have a valid URL. If we haven't, do not open the engagement page.

View File

@ -43,6 +43,7 @@ customAPIs = {
('PPB_PDF', 'SetAccessibilityPageInfo', 'text_runs'): { 'arraySize': 'page_info->text_run_count' }, ('PPB_PDF', 'SetAccessibilityPageInfo', 'text_runs'): { 'arraySize': 'page_info->text_run_count' },
('PPB_PDF', 'SetAccessibilityPageInfo', 'chars'): { 'arraySize': 'page_info->char_count' }, ('PPB_PDF', 'SetAccessibilityPageInfo', 'chars'): { 'arraySize': 'page_info->char_count' },
('PPB_TCPSocket_Private', 'Write', 'buffer'): { 'array': True, 'arrayType': 'uint8_t', 'arraySize': 'bytes_to_write' }, ('PPB_TCPSocket_Private', 'Write', 'buffer'): { 'array': True, 'arrayType': 'uint8_t', 'arraySize': 'bytes_to_write' },
('PPP_Printing_Dev', 'PrintPages', 'page_ranges'): { 'array': True, 'arraySize': None },
} }
def getCustom(interface, member, param): def getCustom(interface, member, param):
def matches(pattern, value): def matches(pattern, value):
@ -335,7 +336,10 @@ class RPCGen(object):
for param in callnode.GetListOf('Param'): for param in callnode.GetListOf('Param'):
mode = self.cgen.GetParamMode(param) mode = self.cgen.GetParamMode(param)
ptype, pname, parray, pspec = self.cgen.GetComponents(param, release, "store") ptype, pname, parray, pspec = self.cgen.GetComponents(param, release, "store")
out += ' ' + self.cgen.Compose(ptype, pname, parray, pspec, '', func_as_ptr=True, prefix = ''
if getCustom(iface.GetName(), node.GetName(), param.GetName()).get("array"):
prefix = '*'
out += ' ' + self.cgen.Compose(ptype, pname, parray, pspec, prefix, func_as_ptr=True,
include_name=True, unsized_as_ptr=True) + ';\n' include_name=True, unsized_as_ptr=True) + ';\n'
if mode == 'out': if mode == 'out':
if len(parray) > 0: if len(parray) > 0:
@ -359,7 +363,8 @@ class RPCGen(object):
mode = self.cgen.GetParamMode(param) mode = self.cgen.GetParamMode(param)
ntype, mode = self.cgen.GetRootTypeMode(param, release, mode) ntype, mode = self.cgen.GetRootTypeMode(param, release, mode)
ptype, pname, parray, pspec = self.cgen.GetComponents(param, release, mode) ptype, pname, parray, pspec = self.cgen.GetComponents(param, release, mode)
if mode == 'out' or ntype == 'Struct' or (mode == 'constptr_in' and ntype == 'TypeValue'): isArray = getCustom(iface.GetName(), node.GetName(), param.GetName()).get("array")
if (mode == 'out' or ntype == 'Struct' or (mode == 'constptr_in' and ntype == 'TypeValue')) and not isArray:
pname = '&' + pname pname = '&' + pname
pname = '(' + self.cgen.Compose(ptype, pname, parray, pspec, '', func_as_ptr=True, pname = '(' + self.cgen.Compose(ptype, pname, parray, pspec, '', func_as_ptr=True,
include_name=False, unsized_as_ptr=True) + ')' + pname include_name=False, unsized_as_ptr=True) + ')' + pname

View File

@ -237,74 +237,6 @@ inline bool PP_ToBool(PP_Bool b) {
#endif /* __cplusplus */ #endif /* __cplusplus */
/* pp_point.idl */
/**
* @addtogroup Structs
* @{
*/
/**
* The PP_Point structure defines the integer x and y coordinates of a point.
*/
struct PP_Point {
/**
* This value represents the horizontal coordinate of a point, starting with 0
* as the left-most coordinate.
*/
int32_t x;
/**
* This value represents the vertical coordinate of a point, starting with 0
* as the top-most coordinate.
*/
int32_t y;
};
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Point, 8);
/**
* The PP_FloatPoint structure defines the floating-point x and y coordinates
* of a point.
*/
struct PP_FloatPoint {
float x;
float y;
};
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FloatPoint, 8);
/**
* @}
*/
/**
* @addtogroup Functions
* @{
*/
/**
* PP_MakePoint() creates a <code>PP_Point</code> given the x and y coordinates
* as int32_t values.
*
* @param[in] x An int32_t value representing a horizontal coordinate of a
* point, starting with 0 as the left-most coordinate.
* @param[in] y An int32_t value representing a vertical coordinate of a point,
* starting with 0 as the top-most coordinate.
*
* @return A <code>PP_Point</code> structure.
*/
PP_INLINE struct PP_Point PP_MakePoint(int32_t x, int32_t y) {
struct PP_Point ret;
ret.x = x;
ret.y = y;
return ret;
}
PP_INLINE struct PP_FloatPoint PP_MakeFloatPoint(float x, float y) {
struct PP_FloatPoint ret;
ret.x = x;
ret.y = y;
return ret;
}
/**
* @}
*/
/* pp_size.idl */ /* pp_size.idl */
/** /**
* @addtogroup Structs * @addtogroup Structs
@ -373,6 +305,74 @@ PP_INLINE struct PP_FloatSize PP_MakeFloatSize(float w, float h) {
/** /**
* @} * @}
*/ */
/* pp_point.idl */
/**
* @addtogroup Structs
* @{
*/
/**
* The PP_Point structure defines the integer x and y coordinates of a point.
*/
struct PP_Point {
/**
* This value represents the horizontal coordinate of a point, starting with 0
* as the left-most coordinate.
*/
int32_t x;
/**
* This value represents the vertical coordinate of a point, starting with 0
* as the top-most coordinate.
*/
int32_t y;
};
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Point, 8);
/**
* The PP_FloatPoint structure defines the floating-point x and y coordinates
* of a point.
*/
struct PP_FloatPoint {
float x;
float y;
};
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FloatPoint, 8);
/**
* @}
*/
/**
* @addtogroup Functions
* @{
*/
/**
* PP_MakePoint() creates a <code>PP_Point</code> given the x and y coordinates
* as int32_t values.
*
* @param[in] x An int32_t value representing a horizontal coordinate of a
* point, starting with 0 as the left-most coordinate.
* @param[in] y An int32_t value representing a vertical coordinate of a point,
* starting with 0 as the top-most coordinate.
*
* @return A <code>PP_Point</code> structure.
*/
PP_INLINE struct PP_Point PP_MakePoint(int32_t x, int32_t y) {
struct PP_Point ret;
ret.x = x;
ret.y = y;
return ret;
}
PP_INLINE struct PP_FloatPoint PP_MakeFloatPoint(float x, float y) {
struct PP_FloatPoint ret;
ret.x = x;
ret.y = y;
return ret;
}
/**
* @}
*/
/* pp_rect.idl */ /* pp_rect.idl */
/** /**
* @addtogroup Structs * @addtogroup Structs
@ -49238,14 +49238,22 @@ char* Call_PPP_Printing_Dev_PrintPages(const PPP_Printing_Dev* _interface, JSONI
PP_Instance instance; PP_Instance instance;
iterator.skip(); iterator.skip();
FromJSON_PP_Instance(iterator, instance); FromJSON_PP_Instance(iterator, instance);
struct PP_PrintPageNumberRange_Dev page_ranges; struct PP_PrintPageNumberRange_Dev *page_ranges;
iterator.skip(); iterator.skip();
FromJSON_PP_PrintPageNumberRange_Dev(iterator, page_ranges);
{
size_t children = iterator.expectArrayAndGotoFirstItem();
page_ranges = new struct PP_PrintPageNumberRange_Dev[children];
for (uint32_t _n = 0; _n < children; ++_n) {
FromJSON_PP_PrintPageNumberRange_Dev(iterator, (page_ranges)[_n]);
}
// FIXME Null out remaining items?
}
uint32_t page_range_count; uint32_t page_range_count;
iterator.skip(); iterator.skip();
FromJSON_uint32_t(iterator, page_range_count); FromJSON_uint32_t(iterator, page_range_count);
int32_t rval; int32_t rval;
rval = _interface->PrintPages((PP_Instance )instance, (const struct PP_PrintPageNumberRange_Dev* )&page_ranges, (uint32_t )page_range_count); rval = _interface->PrintPages((PP_Instance )instance, (const struct PP_PrintPageNumberRange_Dev* )page_ranges, (uint32_t )page_range_count);
return strdup(ToString_PP_Resource(rval).c_str()); return strdup(ToString_PP_Resource(rval).c_str());
} }
char* Call_PPP_Printing_Dev_End(const PPP_Printing_Dev* _interface, JSONIterator& iterator) { char* Call_PPP_Printing_Dev_End(const PPP_Printing_Dev* _interface, JSONIterator& iterator) {

View File

@ -3898,7 +3898,7 @@ var PDFAttachmentViewer = function PDFAttachmentViewerClosure() {
this.attachments = null; this.attachments = null;
var container = this.container; var container = this.container;
while (container.firstChild) { while (container.firstChild) {
container.removeChild(container.firstChild); container.firstChild.remove();
} }
if (!keepRenderedCapability) { if (!keepRenderedCapability) {
this._renderedCapability = pdfjsLib.createPromiseCapability(); this._renderedCapability = pdfjsLib.createPromiseCapability();
@ -4598,7 +4598,7 @@ var PDFOutlineViewer = function PDFOutlineViewerClosure() {
this.lastToggleIsShow = true; this.lastToggleIsShow = true;
var container = this.container; var container = this.container;
while (container.firstChild) { while (container.firstChild) {
container.removeChild(container.firstChild); container.firstChild.remove();
} }
}, },
_dispatchEvent: function PDFOutlineViewer_dispatchEvent(outlineCount) { _dispatchEvent: function PDFOutlineViewer_dispatchEvent(outlineCount) {

View File

@ -10,6 +10,7 @@ CHECK(ExplicitImplicitChecker, "implicit-constructor")
CHECK(ExplicitOperatorBoolChecker, "explicit-operator-bool") CHECK(ExplicitOperatorBoolChecker, "explicit-operator-bool")
CHECK(KungFuDeathGripChecker, "kungfu-death-grip") CHECK(KungFuDeathGripChecker, "kungfu-death-grip")
CHECK(MustOverrideChecker, "must-override") CHECK(MustOverrideChecker, "must-override")
CHECK(MustReturnFromCallerChecker, "must-return-from-caller")
CHECK(MustUseChecker, "must-use") CHECK(MustUseChecker, "must-use")
CHECK(NaNExprChecker, "nan-expr") CHECK(NaNExprChecker, "nan-expr")
CHECK(NeedsNoVTableTypeChecker, "needs-no-vtable-type") CHECK(NeedsNoVTableTypeChecker, "needs-no-vtable-type")

View File

@ -11,6 +11,7 @@
#include "ExplicitOperatorBoolChecker.h" #include "ExplicitOperatorBoolChecker.h"
#include "KungFuDeathGripChecker.h" #include "KungFuDeathGripChecker.h"
#include "MustOverrideChecker.h" #include "MustOverrideChecker.h"
#include "MustReturnFromCallerChecker.h"
#include "MustUseChecker.h" #include "MustUseChecker.h"
#include "NaNExprChecker.h" #include "NaNExprChecker.h"
#include "NeedsNoVTableTypeChecker.h" #include "NeedsNoVTableTypeChecker.h"

View File

@ -231,6 +231,11 @@ AST_MATCHER(CXXMethodDecl, isNonVirtual) {
const CXXMethodDecl *Decl = Node.getCanonicalDecl(); const CXXMethodDecl *Decl = Node.getCanonicalDecl();
return Decl && !Decl->isVirtual(); return Decl && !Decl->isVirtual();
} }
AST_MATCHER(FunctionDecl, isMozMustReturnFromCaller) {
const FunctionDecl *Decl = Node.getCanonicalDecl();
return Decl && hasCustomAnnotation(Decl, "moz_must_return_from_caller");
}
} }
} }

View File

@ -0,0 +1,105 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "MustReturnFromCallerChecker.h"
#include "CustomMatchers.h"
void MustReturnFromCallerChecker::registerMatchers(MatchFinder* AstMatcher) {
// Look for a call to a MOZ_MUST_RETURN_FROM_CALLER function
AstMatcher->addMatcher(callExpr(callee(functionDecl(isMozMustReturnFromCaller())),
anyOf(hasAncestor(lambdaExpr().bind("containing-lambda")),
hasAncestor(functionDecl().bind("containing-func")))).bind("call"),
this);
}
void MustReturnFromCallerChecker::check(
const MatchFinder::MatchResult& Result) {
const auto *ContainingLambda =
Result.Nodes.getNodeAs<LambdaExpr>("containing-lambda");
const auto *ContainingFunc =
Result.Nodes.getNodeAs<FunctionDecl>("containing-func");
const auto *Call = Result.Nodes.getNodeAs<CallExpr>("call");
Stmt *Body = nullptr;
if (ContainingLambda) {
Body = ContainingLambda->getBody();
} else if (ContainingFunc) {
Body = ContainingFunc->getBody();
} else {
return;
}
assert(Body && "Should have a body by this point");
// Generate the CFG for the enclosing function or decl.
CFG::BuildOptions Options;
std::unique_ptr<CFG> TheCFG =
CFG::buildCFG(nullptr, Body, Result.Context, Options);
if (!TheCFG) {
return;
}
// Determine which block in the CFG we want to look at the successors of.
StmtToBlockMap BlockMap(TheCFG.get(), Result.Context);
size_t CallIndex;
const auto *Block = BlockMap.blockContainingStmt(Call, &CallIndex);
assert(Block && "This statement should be within the CFG!");
if (!immediatelyReturns(Block, Result.Context, CallIndex + 1)) {
diag(Call->getLocStart(),
"You must immediately return after calling this function",
DiagnosticIDs::Error);
}
}
bool
MustReturnFromCallerChecker::immediatelyReturns(RecurseGuard<const CFGBlock *> Block,
ASTContext *TheContext,
size_t FromIdx) {
if (Block.isRepeat()) {
return false;
}
for (size_t I = FromIdx; I < Block->size(); ++I) {
Optional<CFGStmt> S = (*Block)[I].getAs<CFGStmt>();
if (!S) {
continue;
}
auto AfterTrivials = IgnoreTrivials(S->getStmt());
// If we are looking at a ConstructExpr, a DeclRefExpr or a MemberExpr it's
// OK to use them after a call to a MOZ_MUST_RETURN_FROM_CALLER function.
// It is also, of course, OK to look at a ReturnStmt.
if (isa<ReturnStmt>(AfterTrivials) ||
isa<CXXConstructExpr>(AfterTrivials) ||
isa<DeclRefExpr>(AfterTrivials) ||
isa<MemberExpr>(AfterTrivials)) {
continue;
}
// It's also OK to call any function or method which is annotated with
// MOZ_MAY_CALL_AFTER_MUST_RETURN. We consider all CXXConversionDecls
// to be MOZ_MAY_CALL_AFTER_MUST_RETURN (like operator T*()).
if (auto CE = dyn_cast<CallExpr>(AfterTrivials)) {
auto Callee = CE->getDirectCallee();
if (Callee && hasCustomAnnotation(Callee, "moz_may_call_after_must_return")) {
continue;
}
if (Callee && isa<CXXConversionDecl>(Callee)) {
continue;
}
}
// Otherwise, this expression is problematic.
return false;
}
for (auto Succ = Block->succ_begin(); Succ != Block->succ_end(); ++Succ) {
if (!immediatelyReturns(Block.recurse(*Succ), TheContext, 0)) {
return false;
}
}
return true;
}

View File

@ -0,0 +1,26 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MustReturnFromCallerChecker_h__
#define MustReturnFromCallerChecker_h__
#include "plugin.h"
#include "Utils.h"
#include "RecurseGuard.h"
#include "StmtToBlockMap.h"
class MustReturnFromCallerChecker : public BaseCheck {
public:
MustReturnFromCallerChecker(StringRef CheckName,
ContextType *Context = nullptr)
: BaseCheck(CheckName, Context) {}
void registerMatchers(MatchFinder* AstMatcher) override;
void check(const MatchFinder::MatchResult &Result) override;
private:
bool immediatelyReturns(RecurseGuard<const CFGBlock *> Block,
ASTContext *TheContext,
size_t FromIdx);
};
#endif

View File

@ -0,0 +1,63 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef RecurseGuard_h__
#define RecurseGuard_h__
#include "Utils.h"
// This class acts as a tracker for avoiding infinite recursion when traversing
// chains in CFGs etc.
//
// Constructing a RecurseGuard sets up a shared backing store which tracks the
// currently observed objects. Whenever recursing, use RecurseGuard.recurse(T)
// to construct another RecurseGuard with the same backing store.
//
// The RecurseGuard object will unregister its object when it is destroyed, and
// has a method `isRepeat()` which will return `true` if the item was already
// seen.
template<typename T>
class RecurseGuard {
public:
RecurseGuard(T Thing) : Thing(Thing), Set(new DenseSet<T>()), Repeat(false) {
Set->insert(Thing);
}
RecurseGuard(T Thing, std::shared_ptr<DenseSet<T>>& Set)
: Thing(Thing), Set(Set), Repeat(false) {
Repeat = !Set->insert(Thing).second;
}
RecurseGuard(const RecurseGuard &) = delete;
RecurseGuard(RecurseGuard && Other)
: Thing(Other.Thing), Set(Other.Set), Repeat(Other.Repeat) {
Other.Repeat = true;
}
~RecurseGuard() {
if (!Repeat) {
Set->erase(Thing);
}
}
bool isRepeat() { return Repeat; }
T get() { return Thing; }
operator T() {
return Thing;
}
T operator ->() {
return Thing;
}
RecurseGuard recurse(T NewThing) {
return RecurseGuard(NewThing, Set);
}
private:
T Thing;
std::shared_ptr<DenseSet<T>> Set;
bool Repeat;
};
#endif // RecurseGuard_h__

View File

@ -0,0 +1,86 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef StmtToBlockMap_h__
#define StmtToBlockMap_h__
#include "Utils.h"
// This method is copied from clang-tidy's ExprSequence.cpp.
//
// Returns the Stmt nodes that are parents of 'S', skipping any potential
// intermediate non-Stmt nodes.
//
// In almost all cases, this function returns a single parent or no parents at
// all.
inline SmallVector<const Stmt *, 1> getParentStmts(const Stmt *S,
ASTContext *Context) {
SmallVector<const Stmt *, 1> Result;
ASTContext::DynTypedNodeList Parents = Context->getParents(*S);
SmallVector<ast_type_traits::DynTypedNode, 1> NodesToProcess(Parents.begin(),
Parents.end());
while (!NodesToProcess.empty()) {
ast_type_traits::DynTypedNode Node = NodesToProcess.back();
NodesToProcess.pop_back();
if (const auto *S = Node.get<Stmt>()) {
Result.push_back(S);
} else {
Parents = Context->getParents(Node);
NodesToProcess.append(Parents.begin(), Parents.end());
}
}
return Result;
}
// This class is a modified version of the class from clang-tidy's ExprSequence.cpp
//
// Maps `Stmt`s to the `CFGBlock` that contains them. Some `Stmt`s may be
// contained in more than one `CFGBlock`; in this case, they are mapped to the
// innermost block (i.e. the one that is furthest from the root of the tree).
// An optional outparameter provides the index into the block where the `Stmt`
// was found.
class StmtToBlockMap {
public:
// Initializes the map for the given `CFG`.
StmtToBlockMap(const CFG *TheCFG, ASTContext *TheContext) : Context(TheContext) {
for (const auto *B : *TheCFG) {
for (size_t I = 0; I < B->size(); ++I) {
if (Optional<CFGStmt> S = (*B)[I].getAs<CFGStmt>()) {
Map[S->getStmt()] = std::make_pair(B, I);
}
}
}
}
// Returns the block that S is contained in. Some `Stmt`s may be contained
// in more than one `CFGBlock`; in this case, this function returns the
// innermost block (i.e. the one that is furthest from the root of the tree).
//
// The optional outparameter `Index` is set to the index into the block where
// the `Stmt` was found.
const CFGBlock *blockContainingStmt(const Stmt *S, size_t *Index = nullptr) const {
while (!Map.count(S)) {
SmallVector<const Stmt *, 1> Parents = getParentStmts(S, Context);
if (Parents.empty())
return nullptr;
S = Parents[0];
}
const auto &E = Map.lookup(S);
if (Index) *Index = E.second;
return E.first;
}
private:
ASTContext *Context;
llvm::DenseMap<const Stmt *, std::pair<const CFGBlock *, size_t>> Map;
};
#endif // StmtToBlockMap_h__

View File

@ -16,6 +16,7 @@ UNIFIED_SOURCES += [
'KungFuDeathGripChecker.cpp', 'KungFuDeathGripChecker.cpp',
'MozCheckAction.cpp', 'MozCheckAction.cpp',
'MustOverrideChecker.cpp', 'MustOverrideChecker.cpp',
'MustReturnFromCallerChecker.cpp',
'MustUseChecker.cpp', 'MustUseChecker.cpp',
'NaNExprChecker.cpp', 'NaNExprChecker.cpp',
'NeedsNoVTableTypeChecker.cpp', 'NeedsNoVTableTypeChecker.cpp',

View File

@ -5,6 +5,7 @@
#ifndef plugin_h__ #ifndef plugin_h__
#define plugin_h__ #define plugin_h__
#include "clang/Analysis/CFG.h"
#include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h" #include "clang/AST/ASTContext.h"
#include "clang/AST/RecursiveASTVisitor.h" #include "clang/AST/RecursiveASTVisitor.h"

View File

@ -0,0 +1,183 @@
#include <cstddef>
#define MOZ_MUST_RETURN_FROM_CALLER __attribute__((annotate("moz_must_return_from_caller")))
#define MOZ_MAY_CALL_AFTER_MUST_RETURN __attribute__((annotate("moz_may_call_after_must_return")))
void MOZ_MUST_RETURN_FROM_CALLER Throw() {}
void DoAnythingElse();
int MakeAnInt();
int MOZ_MAY_CALL_AFTER_MUST_RETURN SafeMakeInt();
bool Condition();
class Foo {
public:
__attribute__((annotate("moz_implicit"))) Foo(std::nullptr_t);
Foo();
};
void a1() {
Throw();
}
int a2() {
Throw(); // expected-error {{You must immediately return after calling this function}}
return MakeAnInt();
}
int a3() {
Throw();
return 5;
}
int a4() {
Throw(); // expected-error {{You must immediately return after calling this function}}
return Condition() ? MakeAnInt() : MakeAnInt();
}
void a5() {
Throw(); // expected-error {{You must immediately return after calling this function}}
DoAnythingElse();
}
int a6() {
Throw(); // expected-error {{You must immediately return after calling this function}}
DoAnythingElse();
return MakeAnInt();
}
int a7() {
Throw(); // expected-error {{You must immediately return after calling this function}}
DoAnythingElse();
return Condition() ? MakeAnInt() : MakeAnInt();
}
int a8() {
Throw();
return SafeMakeInt();
}
int a9() {
if (Condition()) {
Throw();
}
return SafeMakeInt();
}
void b1() {
if (Condition()) {
Throw();
}
}
int b2() {
if (Condition()) {
Throw(); // expected-error {{You must immediately return after calling this function}}
}
return MakeAnInt();
}
int b3() {
if (Condition()) {
Throw();
}
return 5;
}
int b4() {
if (Condition()) {
Throw(); // expected-error {{You must immediately return after calling this function}}
}
return Condition() ? MakeAnInt() : MakeAnInt();
}
void b5() {
if (Condition()) {
Throw(); // expected-error {{You must immediately return after calling this function}}
}
DoAnythingElse();
}
void b6() {
if (Condition()) {
Throw(); // expected-error {{You must immediately return after calling this function}}
DoAnythingElse();
}
}
void b7() {
if (Condition()) {
Throw();
return;
}
DoAnythingElse();
}
void b8() {
if (Condition()) {
Throw(); // expected-error {{You must immediately return after calling this function}}
DoAnythingElse();
return;
}
DoAnythingElse();
}
void b9() {
while (Condition()) {
Throw(); // expected-error {{You must immediately return after calling this function}}
}
}
void b10() {
while (Condition()) {
Throw();
return;
}
}
void b11() {
Throw(); // expected-error {{You must immediately return after calling this function}}
if (Condition()) {
return;
} else {
return;
}
}
void b12() {
switch (MakeAnInt()) {
case 1:
break;
default:
Throw();
return;
}
}
void b13() {
if (Condition()) {
Throw();
}
return;
}
Foo b14() {
if (Condition()) {
Throw();
return nullptr;
}
return nullptr;
}
Foo b15() {
if (Condition()) {
Throw();
}
return nullptr;
}
Foo b16() {
if (Condition()) {
Throw();
}
return Foo();
}

View File

@ -18,6 +18,7 @@ SOURCES += [
'TestKungFuDeathGrip.cpp', 'TestKungFuDeathGrip.cpp',
'TestMultipleAnnotations.cpp', 'TestMultipleAnnotations.cpp',
'TestMustOverride.cpp', 'TestMustOverride.cpp',
'TestMustReturnFromCaller.cpp',
'TestMustUse.cpp', 'TestMustUse.cpp',
'TestNANTestingExpr.cpp', 'TestNANTestingExpr.cpp',
'TestNANTestingExprC.c', 'TestNANTestingExprC.c',

View File

@ -50,19 +50,6 @@ OriginAttributes::InitPrefs()
} }
} }
void
OriginAttributes::Inherit(const OriginAttributes& aAttrs)
{
mAppId = aAttrs.mAppId;
mInIsolatedMozBrowser = aAttrs.mInIsolatedMozBrowser;
mUserContextId = aAttrs.mUserContextId;
mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
mFirstPartyDomain = aAttrs.mFirstPartyDomain;
}
void void
OriginAttributes::SetFirstPartyDomain(const bool aIsTopLevelDocument, OriginAttributes::SetFirstPartyDomain(const bool aIsTopLevelDocument,
nsIURI* aURI) nsIURI* aURI)

View File

@ -40,10 +40,6 @@ public:
: OriginAttributesDictionary(aOther) : OriginAttributesDictionary(aOther)
{} {}
// This method 'clones' the OriginAttributes ignoring the addonId value becaue
// this is computed from the principal URI and never propagated.
void Inherit(const OriginAttributes& aAttrs);
void SetFirstPartyDomain(const bool aIsTopLevelDocument, nsIURI* aURI); void SetFirstPartyDomain(const bool aIsTopLevelDocument, nsIURI* aURI);
enum { enum {

View File

@ -48,11 +48,9 @@ nsNullPrincipal::CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom)
/* static */ already_AddRefed<nsNullPrincipal> /* static */ already_AddRefed<nsNullPrincipal>
nsNullPrincipal::CreateWithInheritedAttributes(nsIDocShell* aDocShell) nsNullPrincipal::CreateWithInheritedAttributes(nsIDocShell* aDocShell)
{ {
OriginAttributes attrs;
attrs.Inherit(nsDocShell::Cast(aDocShell)->GetOriginAttributes());
RefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal(); RefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal();
nsresult rv = nullPrin->Init(attrs); nsresult rv =
nullPrin->Init(nsDocShell::Cast(aDocShell)->GetOriginAttributes());
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv)); MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
return nullPrin.forget(); return nullPrin.forget();
} }

View File

@ -379,9 +379,11 @@ nsScriptSecurityManager::GetChannelURIPrincipal(nsIChannel* aChannel,
// For addons loadInfo might be null. // For addons loadInfo might be null.
if (loadInfo) { if (loadInfo) {
attrs.Inherit(loadInfo->GetOriginAttributes()); attrs = loadInfo->GetOriginAttributes();
} }
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
nsCOMPtr<nsIPrincipal> prin =
BasePrincipal::CreateCodebasePrincipal(uri, attrs);
prin.forget(aPrincipal); prin.forget(aPrincipal);
return *aPrincipal ? NS_OK : NS_ERROR_FAILURE; return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
} }
@ -1143,13 +1145,11 @@ nsScriptSecurityManager::
{ {
NS_ENSURE_STATE(aLoadContext); NS_ENSURE_STATE(aLoadContext);
OriginAttributes docShellAttrs; OriginAttributes docShellAttrs;
bool result = aLoadContext->GetOriginAttributes(docShellAttrs);; bool result = aLoadContext->GetOriginAttributes(docShellAttrs);
NS_ENSURE_TRUE(result, NS_ERROR_FAILURE); NS_ENSURE_TRUE(result, NS_ERROR_FAILURE);
OriginAttributes attrs; nsCOMPtr<nsIPrincipal> prin =
attrs.Inherit(docShellAttrs); BasePrincipal::CreateCodebasePrincipal(aURI, docShellAttrs);
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
prin.forget(aPrincipal); prin.forget(aPrincipal);
return *aPrincipal ? NS_OK : NS_ERROR_FAILURE; return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
} }
@ -1159,10 +1159,8 @@ nsScriptSecurityManager::GetDocShellCodebasePrincipal(nsIURI* aURI,
nsIDocShell* aDocShell, nsIDocShell* aDocShell,
nsIPrincipal** aPrincipal) nsIPrincipal** aPrincipal)
{ {
OriginAttributes attrs; nsCOMPtr<nsIPrincipal> prin =
attrs.Inherit(nsDocShell::Cast(aDocShell)->GetOriginAttributes()); BasePrincipal::CreateCodebasePrincipal(aURI, nsDocShell::Cast(aDocShell)->GetOriginAttributes());
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
prin.forget(aPrincipal); prin.forget(aPrincipal);
return *aPrincipal ? NS_OK : NS_ERROR_FAILURE; return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
} }

View File

@ -36082,7 +36082,7 @@ return /******/ (function(modules) { // webpackBootstrap
function removeChildren(e) { function removeChildren(e) {
for (var count = e.childNodes.length; count > 0; --count) for (var count = e.childNodes.length; count > 0; --count)
{ e.removeChild(e.firstChild) } { e.firstChild.remove() }
return e return e
} }

View File

@ -576,7 +576,7 @@ ToolSidebar.prototype = {
} }
while (this._tabbox.tabs && this._tabbox.tabs.hasChildNodes()) { while (this._tabbox.tabs && this._tabbox.tabs.hasChildNodes()) {
this._tabbox.tabs.removeChild(this._tabbox.tabs.firstChild); this._tabbox.tabs.firstChild.remove();
} }
if (this._currentTool && this._telemetry) { if (this._currentTool && this._telemetry) {

View File

@ -1604,7 +1604,7 @@ MarkupView.prototype = {
// this container will do double duty as the container for the single // this container will do double duty as the container for the single
// text child. // text child.
while (container.children.firstChild) { while (container.children.firstChild) {
container.children.removeChild(container.children.firstChild); container.children.firstChild.remove();
} }
container.setInlineTextChild(container.node.inlineTextChild); container.setInlineTextChild(container.node.inlineTextChild);
@ -1616,7 +1616,7 @@ MarkupView.prototype = {
if (!container.hasChildren) { if (!container.hasChildren) {
while (container.children.firstChild) { while (container.children.firstChild) {
container.children.removeChild(container.children.firstChild); container.children.firstChild.remove();
} }
container.childrenDirty = false; container.childrenDirty = false;
container.setExpanded(false); container.setExpanded(false);
@ -1659,7 +1659,7 @@ MarkupView.prototype = {
} }
while (container.children.firstChild) { while (container.children.firstChild) {
container.children.removeChild(container.children.firstChild); container.children.firstChild.remove();
} }
if (!(children.hasFirst && children.hasLast)) { if (!(children.hasFirst && children.hasLast)) {

View File

@ -161,6 +161,7 @@ skip-if = e10s # Bug 1036409 - The last selected node isn't reselected
[browser_markup_tag_edit_11.js] [browser_markup_tag_edit_11.js]
[browser_markup_tag_edit_12.js] [browser_markup_tag_edit_12.js]
[browser_markup_tag_edit_13-other.js] [browser_markup_tag_edit_13-other.js]
[browser_markup_tag_edit_avoid_refocus.js]
[browser_markup_tag_edit_long-classname.js] [browser_markup_tag_edit_long-classname.js]
[browser_markup_textcontent_display.js] [browser_markup_textcontent_display.js]
[browser_markup_textcontent_edit_01.js] [browser_markup_textcontent_edit_01.js]

View File

@ -0,0 +1,43 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Bug 1327683 - Tests that an editable attribute is not refocused
// when the focus has been moved to an other element than the editor.
const TEST_URL = 'data:text/html,<body class="abcd"></body>';
add_task(function* () {
let {inspector} = yield openInspectorForURL(TEST_URL);
yield selectNode(".abcd", inspector);
yield clickContainer(".abcd", inspector);
let container = yield focusNode(".abcd", inspector);
ok(container && container.editor, "The markup-container was found");
info("Listening for the markupmutation event");
let nodeMutated = inspector.once("markupmutation");
let attr = container.editor.attrElements.get("class").querySelector(".editable");
attr.focus();
EventUtils.sendKey("return", inspector.panelWin);
let input = inplaceEditor(attr).input;
ok(input, "Found editable field for class attribute");
input.value = "class=\"wxyz\"";
let onFocus = once(inspector.searchBox, "focus");
EventUtils.synthesizeMouseAtCenter(inspector.searchBox, {}, inspector.panelWin);
info("Wait for the focus event on search box");
yield onFocus;
info("Wait for the markup-mutation event");
yield nodeMutated;
is(inspector.panelDoc.activeElement, inspector.searchBox,
"The currently focused element is the search box");
});

View File

@ -447,6 +447,13 @@ ElementEditor.prototype = {
this._editedAttributeObserver = null; this._editedAttributeObserver = null;
} }
let activeElement = this.markup.doc.activeElement;
if (!activeElement || !activeElement.inplaceEditor) {
// The focus was already removed from the current inplace editor, we should not
// refocus the editable attribute.
return;
}
let container = this.markup.getContainer(this.node); let container = this.markup.getContainer(this.node);
let activeAttrs = [...this.attrList.childNodes] let activeAttrs = [...this.attrList.childNodes]

View File

@ -1367,7 +1367,7 @@ var Scratchpad = {
recentFilesMenu.setAttribute("disabled", true); recentFilesMenu.setAttribute("disabled", true);
while (recentFilesPopup.hasChildNodes()) { while (recentFilesPopup.hasChildNodes()) {
recentFilesPopup.removeChild(recentFilesPopup.firstChild); recentFilesPopup.firstChild.remove();
} }
if (filePaths.length > 0) { if (filePaths.length > 0) {

View File

@ -1019,7 +1019,7 @@ OutputPanel.prototype._update = function () {
// Empty this._div // Empty this._div
while (this._div.hasChildNodes()) { while (this._div.hasChildNodes()) {
this._div.removeChild(this._div.firstChild); this._div.firstChild.remove();
} }
if (this.displayedOutput.data != null) { if (this.displayedOutput.data != null) {
@ -1030,7 +1030,7 @@ OutputPanel.prototype._update = function () {
} }
while (this._div.hasChildNodes()) { while (this._div.hasChildNodes()) {
this._div.removeChild(this._div.firstChild); this._div.firstChild.remove();
} }
let links = node.querySelectorAll("*[href]"); let links = node.querySelectorAll("*[href]");

View File

@ -1554,7 +1554,7 @@ Cell.prototype = {
this.label.removeAttribute("value"); this.label.removeAttribute("value");
while (this.label.firstChild) { while (this.label.firstChild) {
this.label.removeChild(this.label.firstChild); this.label.firstChild.remove();
} }
this.label.appendChild(value); this.label.appendChild(value);

View File

@ -201,7 +201,7 @@ Tooltip.prototype = {
*/ */
empty: function () { empty: function () {
while (this.panel.hasChildNodes()) { while (this.panel.hasChildNodes()) {
this.panel.removeChild(this.panel.firstChild); this.panel.firstChild.remove();
} }
}, },

View File

@ -865,7 +865,7 @@ StyleEditorUI.prototype = {
let list = details.querySelector(".stylesheet-media-list"); let list = details.querySelector(".stylesheet-media-list");
while (list.firstChild) { while (list.firstChild) {
list.removeChild(list.firstChild); list.firstChild.remove();
} }
let rules = editor.mediaRules; let rules = editor.mediaRules;

View File

@ -156,7 +156,7 @@ exports.items = [
onback: () => { onback: () => {
// The back button clears and hides .csscoverage-report // The back button clears and hides .csscoverage-report
while (host.hasChildNodes()) { while (host.hasChildNodes()) {
host.removeChild(host.firstChild); host.firstChild.remove();
} }
host.hidden = true; host.hidden = true;
} }

View File

@ -388,7 +388,7 @@ exports.createElement = function(doc, tag) {
*/ */
exports.clearElement = function(elem) { exports.clearElement = function(elem) {
while (elem.hasChildNodes()) { while (elem.hasChildNodes()) {
elem.removeChild(elem.firstChild); elem.firstChild.remove();
} }
}; };

View File

@ -51,7 +51,7 @@ LoadContext::LoadContext(nsIPrincipal* aPrincipal,
, mIsNotNull(true) , mIsNotNull(true)
#endif #endif
{ {
mOriginAttributes.Inherit(aPrincipal->OriginAttributesRef()); mOriginAttributes = aPrincipal->OriginAttributesRef();
if (!aOptionalBase) { if (!aOptionalBase) {
return; return;
} }

View File

@ -5003,8 +5003,6 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
// 12.1, HPKP draft spec section 2.6). // 12.1, HPKP draft spec section 2.6).
uint32_t flags = uint32_t flags =
UsePrivateBrowsing() ? nsISocketProvider::NO_PERMANENT_STORAGE : 0; UsePrivateBrowsing() ? nsISocketProvider::NO_PERMANENT_STORAGE : 0;
OriginAttributes originAttributes;
originAttributes.Inherit(mOriginAttributes);
bool isStsHost = false; bool isStsHost = false;
bool isPinnedHost = false; bool isPinnedHost = false;
if (XRE_IsParentProcess()) { if (XRE_IsParentProcess()) {
@ -5012,10 +5010,10 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
do_GetService(NS_SSSERVICE_CONTRACTID, &rv); do_GetService(NS_SSSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = sss->IsSecureURI(nsISiteSecurityService::HEADER_HSTS, aURI, rv = sss->IsSecureURI(nsISiteSecurityService::HEADER_HSTS, aURI,
flags, originAttributes, nullptr, &isStsHost); flags, mOriginAttributes, nullptr, &isStsHost);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = sss->IsSecureURI(nsISiteSecurityService::HEADER_HPKP, aURI, rv = sss->IsSecureURI(nsISiteSecurityService::HEADER_HPKP, aURI,
flags, originAttributes, nullptr, flags, mOriginAttributes, nullptr,
&isPinnedHost); &isPinnedHost);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} else { } else {
@ -5024,9 +5022,9 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
mozilla::ipc::URIParams uri; mozilla::ipc::URIParams uri;
SerializeURI(aURI, uri); SerializeURI(aURI, uri);
cc->SendIsSecureURI(nsISiteSecurityService::HEADER_HSTS, uri, flags, cc->SendIsSecureURI(nsISiteSecurityService::HEADER_HSTS, uri, flags,
originAttributes, &isStsHost); mOriginAttributes, &isStsHost);
cc->SendIsSecureURI(nsISiteSecurityService::HEADER_HPKP, uri, flags, cc->SendIsSecureURI(nsISiteSecurityService::HEADER_HPKP, uri, flags,
originAttributes, &isPinnedHost); mOriginAttributes, &isPinnedHost);
} }
if (Preferences::GetBool( if (Preferences::GetBool(
@ -9736,10 +9734,8 @@ nsresult
nsDocShell::CreatePrincipalFromReferrer(nsIURI* aReferrer, nsDocShell::CreatePrincipalFromReferrer(nsIURI* aReferrer,
nsIPrincipal** aResult) nsIPrincipal** aResult)
{ {
OriginAttributes attrs;
attrs.Inherit(mOriginAttributes);
nsCOMPtr<nsIPrincipal> prin = nsCOMPtr<nsIPrincipal> prin =
BasePrincipal::CreateCodebasePrincipal(aReferrer, attrs); BasePrincipal::CreateCodebasePrincipal(aReferrer, mOriginAttributes);
prin.forget(aResult); prin.forget(aResult);
return *aResult ? NS_OK : NS_ERROR_FAILURE; return *aResult ? NS_OK : NS_ERROR_FAILURE;
@ -10729,11 +10725,11 @@ nsDocShell::InternalLoad(nsIURI* aURI,
srcdoc = NullString(); srcdoc = NullString();
} }
OriginAttributes attrs;
bool isTopLevelDoc = mItemType == typeContent && bool isTopLevelDoc = mItemType == typeContent &&
(isTargetTopLevelDocShell || (isTargetTopLevelDocShell ||
GetIsMozBrowser()); GetIsMozBrowser());
attrs.Inherit(GetOriginAttributes());
OriginAttributes attrs = GetOriginAttributes();
attrs.SetFirstPartyDomain(isTopLevelDoc, aURI); attrs.SetFirstPartyDomain(isTopLevelDoc, aURI);
net::PredictorLearn(aURI, nullptr, net::PredictorLearn(aURI, nullptr,
@ -10985,9 +10981,9 @@ nsDocShell::DoURILoad(nsIURI* aURI,
(aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT || (aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT ||
GetIsMozBrowser()); GetIsMozBrowser());
OriginAttributes attrs; OriginAttributes attrs = GetOriginAttributes();
attrs.Inherit(GetOriginAttributes());
attrs.SetFirstPartyDomain(isTopLevelDoc, aURI); attrs.SetFirstPartyDomain(isTopLevelDoc, aURI);
rv = loadInfo->SetOriginAttributes(attrs); rv = loadInfo->SetOriginAttributes(attrs);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
@ -12602,9 +12598,6 @@ nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType)
srcdoc = NullString(); srcdoc = NullString();
} }
// If there is no valid triggeringPrincipal, we deny the load
MOZ_ASSERT(triggeringPrincipal,
"need a valid triggeringPrincipal to load from history");
if (!triggeringPrincipal) { if (!triggeringPrincipal) {
triggeringPrincipal = nsContentUtils::GetSystemPrincipal(); triggeringPrincipal = nsContentUtils::GetSystemPrincipal();
} }
@ -14231,12 +14224,10 @@ nsDocShell::OnOverLink(nsIContent* aContent,
rv = textToSubURI->UnEscapeURIForUI(charset, spec, uStr); rv = textToSubURI->UnEscapeURIForUI(charset, spec, uStr);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
OriginAttributes attrs;
attrs.Inherit(aContent->NodePrincipal()->OriginAttributesRef());
mozilla::net::PredictorPredict(aURI, mCurrentURI, mozilla::net::PredictorPredict(aURI, mCurrentURI,
nsINetworkPredictor::PREDICT_LINK, nsINetworkPredictor::PREDICT_LINK,
attrs, nullptr); aContent->NodePrincipal()->OriginAttributesRef(),
nullptr);
if (browserChrome2) { if (browserChrome2) {
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aContent); nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aContent);
@ -14748,10 +14739,8 @@ nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNonSubresourceReques
} }
if (aIsNonSubresourceRequest) { if (aIsNonSubresourceRequest) {
OriginAttributes attrs;
attrs.Inherit(mOriginAttributes);
nsCOMPtr<nsIPrincipal> principal = nsCOMPtr<nsIPrincipal> principal =
BasePrincipal::CreateCodebasePrincipal(aURI, attrs); BasePrincipal::CreateCodebasePrincipal(aURI, mOriginAttributes);
*aShouldIntercept = swm->IsAvailable(principal, aURI); *aShouldIntercept = swm->IsAvailable(principal, aURI);
return NS_OK; return NS_OK;
} }
@ -14800,12 +14789,9 @@ nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel)
bool isReload = mLoadType & LOAD_CMD_RELOAD; bool isReload = mLoadType & LOAD_CMD_RELOAD;
OriginAttributes attrs;
attrs.Inherit(mOriginAttributes);
ErrorResult error; ErrorResult error;
swm->DispatchFetchEvent(attrs, doc, mInterceptedDocumentId, aChannel, swm->DispatchFetchEvent(mOriginAttributes, doc, mInterceptedDocumentId,
isReload, isSubresourceLoad, error); aChannel, isReload, isSubresourceLoad, error);
if (NS_WARN_IF(error.Failed())) { if (NS_WARN_IF(error.Failed())) {
return error.StealNSResult(); return error.StealNSResult();
} }

View File

@ -513,10 +513,6 @@ nsSHEntry::GetTriggeringPrincipal(nsIPrincipal** aTriggeringPrincipal)
NS_IMETHODIMP NS_IMETHODIMP
nsSHEntry::SetTriggeringPrincipal(nsIPrincipal* aTriggeringPrincipal) nsSHEntry::SetTriggeringPrincipal(nsIPrincipal* aTriggeringPrincipal)
{ {
MOZ_ASSERT(aTriggeringPrincipal, "need a valid triggeringPrincipal");
if (!aTriggeringPrincipal) {
return NS_ERROR_FAILURE;
}
mShared->mTriggeringPrincipal = aTriggeringPrincipal; mShared->mTriggeringPrincipal = aTriggeringPrincipal;
return NS_OK; return NS_OK;
} }

View File

@ -13,7 +13,7 @@ function showpageshowcount()
var div1 = document.getElementById("div1"); var div1 = document.getElementById("div1");
while (div1.firstChild) while (div1.firstChild)
{ {
div1.removeChild(div1.firstChild); div1.firstChild.remove();
} }
div1.appendChild(document.createTextNode( div1.appendChild(document.createTextNode(
"pageshowcount: " + pageshowcount)); "pageshowcount: " + pageshowcount));

View File

@ -3,7 +3,7 @@
<script> <script>
function testDone() { function testDone() {
document.body.removeChild(document.body.firstChild); document.body.firstChild.remove();
var isOK = false; var isOK = false;
try { try {
isOK = history.previous != location; isOK = history.previous != location;

View File

@ -31,7 +31,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=570341
function showSequence(node){ function showSequence(node){
while(node.firstChild) { while(node.firstChild) {
node.removeChild(node.firstChild); node.firstChild.remove();
} }
var sequence = []; var sequence = [];
for (var p in moments) { for (var p in moments) {

View File

@ -416,7 +416,9 @@ Animation::GetReady(ErrorResult& aRv)
} }
if (!mReady) { if (!mReady) {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
} else if (PlayState() != AnimationPlayState::Pending) { return nullptr;
}
if (PlayState() != AnimationPlayState::Pending) {
mReady->MaybeResolve(this); mReady->MaybeResolve(this);
} }
return mReady; return mReady;
@ -431,7 +433,9 @@ Animation::GetFinished(ErrorResult& aRv)
} }
if (!mFinished) { if (!mFinished) {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
} else if (mFinishedIsResolved) { return nullptr;
}
if (mFinishedIsResolved) {
MaybeResolveFinishedPromise(); MaybeResolveFinishedPromise();
} }
return mFinished; return mFinished;

View File

@ -473,8 +473,8 @@ KeyframeUtils::GetKeyframesFromObject(JSContext* aCx,
if ((!AnimationUtils::IsCoreAPIEnabled() || if ((!AnimationUtils::IsCoreAPIEnabled() ||
aDocument->IsStyledByServo()) && aDocument->IsStyledByServo()) &&
RequiresAdditiveAnimation(keyframes, aDocument)) { RequiresAdditiveAnimation(keyframes, aDocument)) {
aRv.Throw(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR);
keyframes.Clear(); keyframes.Clear();
aRv.Throw(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR);
} }
return keyframes; return keyframes;
@ -770,8 +770,8 @@ GetKeyframeListFromKeyframeSequence(JSContext* aCx,
// Convert the object in aIterator to a sequence of keyframes producing // Convert the object in aIterator to a sequence of keyframes producing
// an array of Keyframe objects. // an array of Keyframe objects.
if (!ConvertKeyframeSequence(aCx, aDocument, aIterator, aResult)) { if (!ConvertKeyframeSequence(aCx, aDocument, aIterator, aResult)) {
aRv.Throw(NS_ERROR_FAILURE);
aResult.Clear(); aResult.Clear();
aRv.Throw(NS_ERROR_FAILURE);
return; return;
} }

View File

@ -302,6 +302,7 @@ StructuredCloneHolder::Read(nsISupports* aParent,
if (!StructuredCloneHolderBase::Read(aCx, aValue)) { if (!StructuredCloneHolderBase::Read(aCx, aValue)) {
JS_ClearPendingException(aCx); JS_ClearPendingException(aCx);
aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR); aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
return;
} }
// If we are tranferring something, we cannot call 'Read()' more than once. // If we are tranferring something, we cannot call 'Read()' more than once.

View File

@ -698,6 +698,13 @@ TextInputProcessor::NotifyIME(TextEventDispatcher* aTextEventDispatcher,
} }
} }
NS_IMETHODIMP_(nsIMEUpdatePreference)
TextInputProcessor::GetIMEUpdatePreference()
{
// TextInputProcessor::NotifyIME does not require extra change notifications.
return nsIMEUpdatePreference();
}
NS_IMETHODIMP_(void) NS_IMETHODIMP_(void)
TextInputProcessor::OnRemovedFrom(TextEventDispatcher* aTextEventDispatcher) TextInputProcessor::OnRemovedFrom(TextEventDispatcher* aTextEventDispatcher)
{ {

View File

@ -32,6 +32,9 @@ public:
// TextEventDispatcherListener // TextEventDispatcherListener
NS_IMETHOD NotifyIME(TextEventDispatcher* aTextEventDispatcher, NS_IMETHOD NotifyIME(TextEventDispatcher* aTextEventDispatcher,
const IMENotification& aNotification) override; const IMENotification& aNotification) override;
NS_IMETHOD_(nsIMEUpdatePreference) GetIMEUpdatePreference() override;
NS_IMETHOD_(void) NS_IMETHOD_(void)
OnRemovedFrom(TextEventDispatcher* aTextEventDispatcher) override; OnRemovedFrom(TextEventDispatcher* aTextEventDispatcher) override;

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<script> <script>
var root = document.documentElement; var root = document.documentElement;
while(root.firstChild) { root.removeChild(root.firstChild); } while(root.firstChild) { root.firstChild.remove(); }
var div = document.createElement("div"); var div = document.createElement("div");
root.appendChild(div); root.appendChild(div);

View File

@ -319,8 +319,9 @@ nsDOMAttributeMap::SetNamedItemNS(Attr& aAttr, ErrorResult& aError)
rv = mContent->SetAttr(ni->NamespaceID(), ni->NameAtom(), rv = mContent->SetAttr(ni->NamespaceID(), ni->NameAtom(),
ni->GetPrefixAtom(), value, true); ni->GetPrefixAtom(), value, true);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
aError.Throw(rv);
DropAttribute(ni->NamespaceID(), ni->NameAtom()); DropAttribute(ni->NamespaceID(), ni->NameAtom());
aError.Throw(rv);
return nullptr;
} }
return oldAttr.forget(); return oldAttr.forget();

View File

@ -2452,7 +2452,7 @@ nsFrameLoader::MaybeCreateDocShell()
MOZ_ASSERT(attrs.mPrivateBrowsingId == oa.mPrivateBrowsingId, MOZ_ASSERT(attrs.mPrivateBrowsingId == oa.mPrivateBrowsingId,
"docshell and document should have the same privateBrowsingId attribute."); "docshell and document should have the same privateBrowsingId attribute.");
attrs.Inherit(oa); attrs = oa;
} }
if (OwnerIsMozBrowserFrame()) { if (OwnerIsMozBrowserFrame()) {

View File

@ -3267,7 +3267,11 @@ nsGlobalWindow::DispatchDOMWindowCreated()
nsCOMPtr<nsIObserverService> observerService = nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService(); mozilla::services::GetObserverService();
if (observerService) {
// The event dispatching could possibly cause docshell destory, and
// consequently cause mDoc to be set to nullptr by DropOuterWindowDocs(),
// so check it again here.
if (observerService && mDoc) {
nsAutoString origin; nsAutoString origin;
nsIPrincipal* principal = mDoc->NodePrincipal(); nsIPrincipal* principal = mDoc->NodePrincipal();
nsContentUtils::GetUTFOrigin(principal, origin); nsContentUtils::GetUTFOrigin(principal, origin);

View File

@ -1313,11 +1313,9 @@ nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest)
} }
} }
OriginAttributes attrs;
attrs.Inherit(mDocument->NodePrincipal()->OriginAttributesRef());
mozilla::net::PredictorLearn(aRequest->mURI, mDocument->GetDocumentURI(), mozilla::net::PredictorLearn(aRequest->mURI, mDocument->GetDocumentURI(),
nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE, attrs); nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE,
mDocument->NodePrincipal()->OriginAttributesRef());
// Set the initiator type // Set the initiator type
nsCOMPtr<nsITimedChannel> timedChannel(do_QueryInterface(httpChannel)); nsCOMPtr<nsITimedChannel> timedChannel(do_QueryInterface(httpChannel));

View File

@ -72,3 +72,4 @@ support-files = ../file_bug357450.js
[test_windowroot.xul] [test_windowroot.xul]
[test_swapFrameLoaders.xul] [test_swapFrameLoaders.xul]
[test_groupedSHistory.xul] [test_groupedSHistory.xul]
[test_bug1339722.html]

View File

@ -0,0 +1,67 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1339722
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1339722</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/**
* Test for Bug 1339722
* 1. Wait for "http-on-useragent-request" for the iframe load.
* 2. In the observer, access it's window proxy to trigger DOMWindowCreated.
* 3. In the event handler, delete the iframe so that the frameloader would be
* destoryed in the middle of ReallyStartLoading.
* 4. Verify that it doesn't crash.
**/
const {interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/Services.jsm");
const TOPIC = 'http-on-useragent-request';
Services.obs.addObserver({
observe(subject, topic, data) {
info('Got ' + topic);
Services.obs.removeObserver(this, TOPIC);
// Query window proxy so it triggers DOMWindowCreated.
let channel = subject.QueryInterface(Ci.nsIHttpChannel);
let win = channel.notificationCallbacks.getInterface(Ci.mozIDOMWindowProxy);
}
}, TOPIC, false);
let docShell = SpecialPowers.wrap(window)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell);
docShell.chromeEventHandler.addEventListener('DOMWindowCreated', function handler(e) {
docShell.chromeEventHandler.removeEventListener('DOMWindowCreated', handler);
let iframe = document.getElementById('testFrame');
is(e.target, iframe.contentDocument, 'verify event target');
// Remove the iframe to cause frameloader destroy.
iframe.remove();
setTimeout($ => {
ok(!document.getElementById('testFrame'), 'verify iframe removed');
SimpleTest.finish();
}, 0);
});
SimpleTest.waitForExplicitFinish();
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1339722">Mozilla Bug 1339722</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
<div id="frameContainer">
<iframe id="testFrame" src="http://www.example.com"></iframe>
</div>
</pre>
</body>
</html>

View File

@ -26,7 +26,7 @@ function runTest() {
ok(attrs != null, "Element should have attributes!"); ok(attrs != null, "Element should have attributes!");
var attr = testParent.firstChild.getAttributeNode("someattr"); var attr = testParent.firstChild.getAttributeNode("someattr");
ok(attr.value == "foo", "The value of the attribute should be 'foo'!"); ok(attr.value == "foo", "The value of the attribute should be 'foo'!");
testParent.removeChild(testParent.firstChild); testParent.firstChild.remove();
SpecialPowers.gc(); SpecialPowers.gc();
ok(true, "Browser should not crash!") ok(true, "Browser should not crash!")

View File

@ -246,7 +246,7 @@ function testChildList() {
m = null; m = null;
}); });
m.observe(div, { childList: true}); m.observe(div, { childList: true});
div.removeChild(div.firstChild); div.firstChild.remove();
} }
function testChildList2() { function testChildList2() {

View File

@ -334,7 +334,7 @@ CallbackObject::CallSetup::~CallSetup()
// IsJSContextException shouldn't be true anymore because we will report // IsJSContextException shouldn't be true anymore because we will report
// the exception on the JSContext ... so throw something else. // the exception on the JSContext ... so throw something else.
mErrorResult.Throw(NS_ERROR_UNEXPECTED); mErrorResult.ThrowWithCustomCleanup(NS_ERROR_UNEXPECTED);
} }
} }
} }

View File

@ -5468,7 +5468,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
nsCOMPtr<nsIGlobalObject> global = nsCOMPtr<nsIGlobalObject> global =
do_QueryInterface(promiseGlobal.GetAsSupports()); do_QueryInterface(promiseGlobal.GetAsSupports());
if (!global) { if (!global) {
promiseRv.Throw(NS_ERROR_UNEXPECTED); promiseRv.ThrowWithCustomCleanup(NS_ERROR_UNEXPECTED);
promiseRv.MaybeSetPendingException(cx); promiseRv.MaybeSetPendingException(cx);
$*{exceptionCode} $*{exceptionCode}
} }

View File

@ -165,11 +165,48 @@ public:
operator ErrorResult&(); operator ErrorResult&();
operator OOMReporter&(); operator OOMReporter&();
void Throw(nsresult rv) { void MOZ_MUST_RETURN_FROM_CALLER Throw(nsresult rv) {
MOZ_ASSERT(NS_FAILED(rv), "Please don't try throwing success"); MOZ_ASSERT(NS_FAILED(rv), "Please don't try throwing success");
AssignErrorCode(rv); AssignErrorCode(rv);
} }
// This method acts identically to the `Throw` method, however, it does not
// have the MOZ_MUST_RETURN_FROM_CALLER static analysis annotation. It is
// intended to be used in situations when additional work needs to be
// performed in the calling function after the Throw method is called.
//
// In general you should prefer using `Throw`, and returning after an error,
// for example:
//
// if (condition) {
// aRv.Throw(NS_ERROR_FAILURE);
// return;
// }
//
// or
//
// if (condition) {
// aRv.Throw(NS_ERROR_FAILURE);
// }
// return;
//
// However, if you need to do some other work after throwing, such as:
//
// if (condition) {
// aRv.ThrowWithCustomCleanup(NS_ERROR_FAILURE);
// }
// // Do some important clean-up work which couldn't happen earlier.
// // We want to do this clean-up work in both the success and failure cases.
// CleanUpImportantState();
// return;
//
// Then you'll need to use ThrowWithCustomCleanup to get around the static
// analysis, which would complain that you are doing work after the call to
// `Throw()`.
void ThrowWithCustomCleanup(nsresult rv) {
Throw(rv);
}
// Duplicate our current state on the given TErrorResult object. Any // Duplicate our current state on the given TErrorResult object. Any
// existing errors or messages on the target will be suppressed before // existing errors or messages on the target will be suppressed before
// cloning. Our own error state remains unchanged. // cloning. Our own error state remains unchanged.
@ -307,7 +344,7 @@ public:
} }
// Support for uncatchable exceptions. // Support for uncatchable exceptions.
void ThrowUncatchableException() { void MOZ_MUST_RETURN_FROM_CALLER ThrowUncatchableException() {
Throw(NS_ERROR_UNCATCHABLE_EXCEPTION); Throw(NS_ERROR_UNCATCHABLE_EXCEPTION);
} }
bool IsUncatchableException() const { bool IsUncatchableException() const {

View File

@ -1482,6 +1482,7 @@ ImageBitmap::Create(nsIGlobalObject* aGlobal, const ImageBitmapSource& aSrc,
return promise.forget(); return promise.forget();
} else { } else {
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
return nullptr;
} }
if (!aRv.Failed()) { if (!aRv.Failed()) {
@ -1691,13 +1692,13 @@ protected:
} else if (JS_IsArrayBufferViewObject(mBuffer)) { } else if (JS_IsArrayBufferViewObject(mBuffer)) {
js::GetArrayBufferViewLengthAndData(mBuffer, &bufferLength, &isSharedMemory, &bufferData); js::GetArrayBufferViewLengthAndData(mBuffer, &bufferLength, &isSharedMemory, &bufferData);
} else { } else {
error.Throw(NS_ERROR_NOT_IMPLEMENTED); error.ThrowWithCustomCleanup(NS_ERROR_NOT_IMPLEMENTED);
mPromise->MaybeReject(error); mPromise->MaybeReject(error);
return; return;
} }
if (NS_WARN_IF(!bufferData) || NS_WARN_IF(!bufferLength)) { if (NS_WARN_IF(!bufferData) || NS_WARN_IF(!bufferLength)) {
error.Throw(NS_ERROR_NOT_AVAILABLE); error.ThrowWithCustomCleanup(NS_ERROR_NOT_AVAILABLE);
mPromise->MaybeReject(error); mPromise->MaybeReject(error);
return; return;
} }
@ -1707,7 +1708,7 @@ protected:
mImageBitmap->MappedDataLength(mFormat, error); mImageBitmap->MappedDataLength(mFormat, error);
if (((int32_t)bufferLength - mOffset) < neededBufferLength) { if (((int32_t)bufferLength - mOffset) < neededBufferLength) {
error.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); error.ThrowWithCustomCleanup(NS_ERROR_DOM_INDEX_SIZE_ERR);
mPromise->MaybeReject(error); mPromise->MaybeReject(error);
return; return;
} }

View File

@ -250,9 +250,11 @@ WebGLContext::GetVertexAttrib(JSContext* cx, GLuint index, GLenum pname,
break; break;
} }
if (!obj) if (!obj) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY); rv.Throw(NS_ERROR_OUT_OF_MEMORY);
return JS::ObjectOrNullValue(obj); return JS::NullValue();
}
return JS::ObjectValue(*obj);
} }
case LOCAL_GL_VERTEX_ATTRIB_ARRAY_ENABLED: case LOCAL_GL_VERTEX_ATTRIB_ARRAY_ENABLED:

View File

@ -67,6 +67,7 @@ TextEncoder::Encode(JSContext* aCx,
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
aRv.Throw(rv); aRv.Throw(rv);
return;
} }
aRetval.set(outView); aRetval.set(outView);
} }

View File

@ -332,8 +332,11 @@ DataTransfer::GetTypes(nsTArray<nsString>& aTypes, CallerType aCallerType) const
continue; continue;
} }
// NOTE: The reason why we get the internal type here is because we want
// kFileMime to appear in the types list for backwards compatibility
// reasons.
nsAutoString type; nsAutoString type;
item->GetType(type); item->GetInternalType(type);
if (item->Kind() == DataTransferItem::KIND_STRING || type.EqualsASCII(kFileMime)) { if (item->Kind() == DataTransferItem::KIND_STRING || type.EqualsASCII(kFileMime)) {
// If the entry has kind KIND_STRING, we want to add it to the list. // If the entry has kind KIND_STRING, we want to add it to the list.
aTypes.AppendElement(type); aTypes.AppendElement(type);
@ -521,8 +524,11 @@ DataTransfer::MozTypesAt(uint32_t aIndex, CallerType aCallerType,
continue; continue;
} }
// NOTE: The reason why we get the internal type here is because we want
// kFileMime to appear in the types list for backwards compatibility
// reasons.
nsAutoString type; nsAutoString type;
items[i]->GetType(type); items[i]->GetInternalType(type);
if (NS_WARN_IF(!types->Add(type))) { if (NS_WARN_IF(!types->Add(type))) {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
return nullptr; return nullptr;
@ -981,7 +987,7 @@ DataTransfer::GetTransferable(uint32_t aIndex, nsILoadContext* aLoadContext)
} }
nsAutoString type; nsAutoString type;
formatitem->GetType(type); formatitem->GetInternalType(type);
// If the data is of one of the well-known formats, use it directly. // If the data is of one of the well-known formats, use it directly.
bool isCustomFormat = true; bool isCustomFormat = true;

View File

@ -230,6 +230,37 @@ DataTransferItem::FillInExternalData()
} }
} }
void
DataTransferItem::GetType(nsAString& aType)
{
// If we don't have a File, we can just put whatever our recorded internal
// type is.
if (Kind() != KIND_FILE) {
aType = mType;
return;
}
// If we do have a File, then we need to look at our File object to discover
// what its mime type is. We can use the System Principal here, as this
// information should be avaliable even if the data is currently inaccessible
// (for example during a dragover).
//
// XXX: This seems inefficient, as it seems like we should be able to get this
// data without getting the entire File object, which may require talking to
// the OS.
ErrorResult rv;
RefPtr<File> file = GetAsFile(*nsContentUtils::GetSystemPrincipal(), rv);
MOZ_ASSERT(!rv.Failed(), "Failed to get file data with system principal");
// If we don't actually have a file, fall back to returning the internal type.
if (NS_WARN_IF(!file)) {
aType = mType;
return;
}
file->GetType(aType);
}
already_AddRefed<File> already_AddRefed<File>
DataTransferItem::GetAsFile(nsIPrincipal& aSubjectPrincipal, DataTransferItem::GetAsFile(nsIPrincipal& aSubjectPrincipal,
ErrorResult& aRv) ErrorResult& aRv)

View File

@ -69,11 +69,13 @@ public:
} }
} }
void GetType(nsAString& aType) const void GetInternalType(nsAString& aType) const
{ {
aType = mType; aType = mType;
} }
void GetType(nsAString& aType);
eKind Kind() const eKind Kind() const
{ {
return mKind; return mKind;

View File

@ -294,8 +294,9 @@ DataTransferItemList::MozRemoveByTypeAt(const nsAString& aType,
} }
for (uint32_t i = 0; i < count; ++i) { for (uint32_t i = 0; i < count; ++i) {
// NOTE: As this is a moz-prefixed API, it works based on internal types.
nsAutoString type; nsAutoString type;
items[i]->GetType(type); items[i]->GetInternalType(type);
if (type == aType) { if (type == aType) {
ClearDataHelper(items[i], -1, i, aSubjectPrincipal, aRv); ClearDataHelper(items[i], -1, i, aSubjectPrincipal, aRv);
return; return;
@ -313,8 +314,9 @@ DataTransferItemList::MozItemByTypeAt(const nsAString& aType, uint32_t aIndex)
uint32_t count = mIndexedItems[aIndex].Length(); uint32_t count = mIndexedItems[aIndex].Length();
for (uint32_t i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
RefPtr<DataTransferItem> item = mIndexedItems[aIndex][i]; RefPtr<DataTransferItem> item = mIndexedItems[aIndex][i];
// NOTE: As this is a moz-prefixed API it works on internal types
nsString type; nsString type;
item->GetType(type); item->GetInternalType(type);
if (type.Equals(aType)) { if (type.Equals(aType)) {
return item; return item;
} }
@ -338,7 +340,7 @@ DataTransferItemList::SetDataWithPrincipal(const nsAString& aType,
for (uint32_t i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
RefPtr<DataTransferItem> item = items[i]; RefPtr<DataTransferItem> item = items[i];
nsString type; nsString type;
item->GetType(type); item->GetInternalType(type);
if (type.Equals(aType)) { if (type.Equals(aType)) {
if (NS_WARN_IF(aInsertOnly)) { if (NS_WARN_IF(aInsertOnly)) {
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);

View File

@ -98,7 +98,7 @@
is(oldLength + 1, dtList.length, is(oldLength + 1, dtList.length,
"Replacing the entry with a file should add it to the list!"); "Replacing the entry with a file should add it to the list!");
is(dtList[oldLength].getAsFile(), file3, "It should be stored in the last index as a file"); is(dtList[oldLength].getAsFile(), file3, "It should be stored in the last index as a file");
is(dtList[oldLength].type, "random/string", "It should have the correct type"); is(dtList[oldLength].type, "text/html", "It should have the correct type");
is(dtList[oldLength].kind, "file", "It should have the correct kind"); is(dtList[oldLength].kind, "file", "It should have the correct kind");
todo(files.length == 3, "This test has chrome privileges, so the FileList objects aren't updated live"); todo(files.length == 3, "This test has chrome privileges, so the FileList objects aren't updated live");

View File

@ -202,8 +202,8 @@ GetFilesTaskParent::GetSuccessRequestResult(ErrorResult& aRv) const
FallibleTArray<FileSystemFileResponse> inputs; FallibleTArray<FileSystemFileResponse> inputs;
if (!inputs.SetLength(mTargetBlobImplArray.Length(), mozilla::fallible_t())) { if (!inputs.SetLength(mTargetBlobImplArray.Length(), mozilla::fallible_t())) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
FileSystemFilesResponse response; FileSystemFilesResponse response;
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return response; return response;
} }

View File

@ -1193,7 +1193,7 @@ FlyWebService::PairWithService(const nsAString& aServiceId,
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
ErrorResult result; ErrorResult result;
result.Throw(rv); result.ThrowWithCustomCleanup(rv);
const nsAString& reason = NS_LITERAL_STRING("Error pairing."); const nsAString& reason = NS_LITERAL_STRING("Error pairing.");
aCallback.PairingFailed(reason, result); aCallback.PairingFailed(reason, result);
ENSURE_SUCCESS_VOID(result); ENSURE_SUCCESS_VOID(result);

View File

@ -192,9 +192,8 @@ HttpServer::AcceptWebSocket(InternalRequest* aConnectRequest,
return provider.forget(); return provider.forget();
} }
aRv.Throw(NS_ERROR_UNEXPECTED);
MOZ_ASSERT(false, "Unknown request"); MOZ_ASSERT(false, "Unknown request");
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr; return nullptr;
} }

View File

@ -2701,6 +2701,7 @@ HTMLMediaElement::Seek(double aTime,
nsresult rv = mDecoder->Seek(aTime, aSeekType, promise); nsresult rv = mDecoder->Seek(aTime, aSeekType, promise);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
aRv.Throw(rv); aRv.Throw(rv);
return nullptr;
} }
// We changed whether we're seeking so we need to AddRemoveSelfReference. // We changed whether we're seeking so we need to AddRemoveSelfReference.

View File

@ -5,7 +5,7 @@ function boom()
{ {
var r = document.documentElement; var r = document.documentElement;
while (r.firstChild) while (r.firstChild)
r.removeChild(r.firstChild); r.firstChild.remove();
var b = document.createElement("BODY"); var b = document.createElement("BODY");
var s = document.createElement("SCRIPT"); var s = document.createElement("SCRIPT");

View File

@ -11,7 +11,7 @@
function boom() function boom()
{ {
while (document.documentElement.firstChild) document.documentElement.removeChild(document.documentElement.firstChild); while (document.documentElement.firstChild) document.documentElement.firstChild.remove();
document.addEventListener("DOMSubtreeModified", function(){}); document.addEventListener("DOMSubtreeModified", function(){});
document.addEventListener("DOMNodeInsertedIntoDocument", function(){}); document.addEventListener("DOMNodeInsertedIntoDocument", function(){});

View File

@ -424,7 +424,7 @@ for (var name of elementNames) {
for (var func of functions) { for (var func of functions) {
// Clean-up. // Clean-up.
while (content.firstChild) { while (content.firstChild) {
content.removeChild(content.firstChild); content.firstChild.remove();
} }
for (form of forms) { for (form of forms) {
content.appendChild(form); content.appendChild(form);

View File

@ -95,7 +95,7 @@ valueIs("abcdeTesth",
"Modifying textnode text shouldn't affect value in edited textarea"); "Modifying textnode text shouldn't affect value in edited textarea");
defValueIs("abcdefghlmno", "Modified textnode text 3"); defValueIs("abcdefghlmno", "Modified textnode text 3");
t.removeChild(t.firstChild); t.firstChild.remove();
valueIs("abcdeTesth", valueIs("abcdeTesth",
"Removing child textnode shouldn't affect value in edited textarea"); "Removing child textnode shouldn't affect value in edited textarea");
defValueIs("defghlmno", "Removed textnode 3"); defValueIs("defghlmno", "Removed textnode 3");

View File

@ -78,7 +78,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=311681
function clear(node) { function clear(node) {
while (node.hasChildNodes()) { while (node.hasChildNodes()) {
node.removeChild(node.firstChild); node.firstChild.remove();
} }
} }

Some files were not shown because too many files have changed in this diff Show More