Merge mozilla-central to autoland

This commit is contained in:
Carsten "Tomcat" Book 2017-01-27 11:26:26 +01:00
Родитель c3aa41c06b a516a86a24
Коммит 9af2aa6b47
246 изменённых файлов: 2561 добавлений и 2271 удалений

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

@ -38,7 +38,7 @@ support-files =
[browser_treeupdate_gencontent.js]
[browser_treeupdate_hidden.js]
[browser_treeupdate_imagemap.js]
skip-if = (os == 'mac' && debug && e10s) # Bug 1318569
skip-if = e10s # Bug 1318569
[browser_treeupdate_list.js]
[browser_treeupdate_list_editabledoc.js]
[browser_treeupdate_listener.js]

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

@ -1029,8 +1029,12 @@ pref("security.sandbox.content.tempDirSuffix", "");
#if defined(MOZ_SANDBOX)
// This pref determines if messages relevant to sandbox violations are
// logged.
#if defined(XP_WIN)
pref("security.sandbox.logging.enabled", false);
#else
pref("security.sandbox.logging.enabled", true);
#endif
#endif
// This pref governs whether we attempt to work around problems caused by
// plugins using OS calls to manipulate the cursor while running out-of-

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

@ -1,3 +1,3 @@
This is the pdf.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 1.6.467
Current extension version is: 1.7.227

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

@ -21,30 +21,14 @@ Components.utils.import('resource://gre/modules/Services.jsm');
var EXPORTED_SYMBOLS = ['NetworkManager'];
function log(aMsg) {
var msg = 'network.js: ' + (aMsg.join ? aMsg.join('') : aMsg);
var msg = 'PdfJsNetwork.jsm: ' + (aMsg.join ? aMsg.join('') : aMsg);
Services.console.logStringMessage(msg);
}
var NetworkManager = (function NetworkManagerClosure() {
var OK_RESPONSE = 200;
var PARTIAL_CONTENT_RESPONSE = 206;
function NetworkManager(url, args) {
this.url = url;
args = args || {};
this.isHttp = /^https?:/i.test(url);
this.httpHeaders = (this.isHttp && args.httpHeaders) || {};
this.withCredentials = args.withCredentials || false;
this.getXhr = args.getXhr ||
function NetworkManager_getXhr() {
return new XMLHttpRequest();
};
this.currXhrId = 0;
this.pendingRequests = Object.create(null);
this.loadedRequests = Object.create(null);
}
const OK_RESPONSE = 200;
const PARTIAL_CONTENT_RESPONSE = 206;
function getArrayBuffer(xhr) {
var data = xhr.response;
@ -59,27 +43,43 @@ var NetworkManager = (function NetworkManagerClosure() {
return array.buffer;
}
NetworkManager.prototype = {
requestRange: function NetworkManager_requestRange(begin, end, listeners) {
class NetworkManagerClass {
constructor(url, args) {
this.url = url;
args = args || {};
this.isHttp = /^https?:/i.test(url);
this.httpHeaders = (this.isHttp && args.httpHeaders) || {};
this.withCredentials = args.withCredentials || false;
this.getXhr = args.getXhr ||
function NetworkManager_getXhr() {
return new XMLHttpRequest();
};
this.currXhrId = 0;
this.pendingRequests = Object.create(null);
this.loadedRequests = Object.create(null);
}
requestRange(begin, end, listeners) {
var args = {
begin: begin,
end: end
begin,
end,
};
for (var prop in listeners) {
args[prop] = listeners[prop];
}
return this.request(args);
},
}
requestFull: function NetworkManager_requestFull(listeners) {
requestFull(listeners) {
return this.request(listeners);
},
}
request: function NetworkManager_request(args) {
request(args) {
var xhr = this.getXhr();
var xhrId = this.currXhrId++;
var pendingRequest = this.pendingRequests[xhrId] = {
xhr: xhr
xhr,
};
xhr.open('GET', this.url);
@ -124,9 +124,9 @@ var NetworkManager = (function NetworkManagerClosure() {
xhr.send(null);
return xhrId;
},
}
onProgress: function NetworkManager_onProgress(xhrId, evt) {
onProgress(xhrId, evt) {
var pendingRequest = this.pendingRequests[xhrId];
if (!pendingRequest) {
// Maybe abortRequest was called...
@ -142,9 +142,9 @@ var NetworkManager = (function NetworkManagerClosure() {
if (onProgress) {
onProgress(evt);
}
},
}
onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
onStateChange(xhrId, evt) {
var pendingRequest = this.pendingRequests[xhrId];
if (!pendingRequest) {
// Maybe abortRequest was called...
@ -201,57 +201,57 @@ var NetworkManager = (function NetworkManagerClosure() {
var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
var begin = parseInt(matches[1], 10);
pendingRequest.onDone({
begin: begin,
chunk: chunk
begin,
chunk,
});
} else if (pendingRequest.onProgressiveData) {
pendingRequest.onDone(null);
} else if (chunk) {
pendingRequest.onDone({
begin: 0,
chunk: chunk
chunk,
});
} else if (pendingRequest.onError) {
pendingRequest.onError(xhr.status);
}
},
}
hasPendingRequests: function NetworkManager_hasPendingRequests() {
hasPendingRequests() {
for (var xhrId in this.pendingRequests) {
return true;
}
return false;
},
}
getRequestXhr: function NetworkManager_getXhr(xhrId) {
getRequestXhr(xhrId) {
return this.pendingRequests[xhrId].xhr;
},
}
isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
isStreamingRequest(xhrId) {
return !!(this.pendingRequests[xhrId].onProgressiveData);
},
}
isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
isPendingRequest(xhrId) {
return xhrId in this.pendingRequests;
},
}
isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
isLoadedRequest(xhrId) {
return xhrId in this.loadedRequests;
},
}
abortAllRequests: function NetworkManager_abortAllRequests() {
abortAllRequests() {
for (var xhrId in this.pendingRequests) {
this.abortRequest(xhrId | 0);
}
},
}
abortRequest: function NetworkManager_abortRequest(xhrId) {
abortRequest(xhrId) {
var xhr = this.pendingRequests[xhrId].xhr;
delete this.pendingRequests[xhrId];
xhr.abort();
}
};
}
return NetworkManager;
return NetworkManagerClass;
})();

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

@ -23,47 +23,47 @@ const Cu = Components.utils;
Cu.import('resource://gre/modules/Services.jsm');
this.PdfJsTelemetry = {
onViewerIsUsed: function () {
onViewerIsUsed() {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_USED');
histogram.add(true);
},
onFallback: function () {
onFallback() {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_FALLBACK_SHOWN');
histogram.add(true);
},
onDocumentSize: function (size) {
onDocumentSize(size) {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_DOCUMENT_SIZE_KB');
histogram.add(size / 1024);
},
onDocumentVersion: function (versionId) {
onDocumentVersion(versionId) {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_DOCUMENT_VERSION');
histogram.add(versionId);
},
onDocumentGenerator: function (generatorId) {
onDocumentGenerator(generatorId) {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_DOCUMENT_GENERATOR');
histogram.add(generatorId);
},
onEmbed: function (isObject) {
onEmbed(isObject) {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_EMBED');
histogram.add(isObject);
},
onFontType: function (fontTypeId) {
onFontType(fontTypeId) {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_FONT_TYPES');
histogram.add(fontTypeId);
},
onForm: function (isAcroform) {
onForm(isAcroform) {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_FORM');
histogram.add(isAcroform);
},
onPrint: function () {
onPrint() {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_PRINT');
histogram.add(true);
},
onStreamType: function (streamTypeId) {
onStreamType(streamTypeId) {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_STREAM_TYPES');
histogram.add(streamTypeId);
},
onTimeToView: function (ms) {
onTimeToView(ms) {
let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_TIME_TO_VIEW_MS');
histogram.add(ms);
}

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

@ -190,7 +190,7 @@ PdfDataListener.prototype = {
this.oncompleteCallback(null, errorCode);
}
},
onprogress: function() {},
onprogress() {},
get oncomplete() {
return this.oncompleteCallback;
},
@ -205,24 +205,27 @@ PdfDataListener.prototype = {
}
};
// All the priviledged actions.
function ChromeActions(domWindow, contentDispositionFilename) {
this.domWindow = domWindow;
this.contentDispositionFilename = contentDispositionFilename;
this.telemetryState = {
documentInfo: false,
firstPageInfo: false,
streamTypesUsed: [],
fontTypesUsed: [],
startAt: Date.now()
};
}
/**
* All the privileged actions.
*/
class ChromeActions {
constructor(domWindow, contentDispositionFilename) {
this.domWindow = domWindow;
this.contentDispositionFilename = contentDispositionFilename;
this.telemetryState = {
documentInfo: false,
firstPageInfo: false,
streamTypesUsed: [],
fontTypesUsed: [],
startAt: Date.now()
};
}
ChromeActions.prototype = {
isInPrivateBrowsing: function() {
isInPrivateBrowsing() {
return PrivateBrowsingUtils.isContentWindowPrivate(this.domWindow);
},
download: function(data, sendResponse) {
}
download(data, sendResponse) {
var self = this;
var originalUrl = data.originalUrl;
var blobUrl = data.blobUrl || originalUrl;
@ -279,7 +282,7 @@ ChromeActions.prototype = {
var listener = {
extListener: null,
onStartRequest: function(aRequest, aContext) {
onStartRequest(aRequest, aContext) {
var loadContext = self.domWindow
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
@ -290,7 +293,7 @@ ChromeActions.prototype = {
aRequest, loadContext, false);
this.extListener.onStartRequest(aRequest, aContext);
},
onStopRequest: function(aRequest, aContext, aStatusCode) {
onStopRequest(aRequest, aContext, aStatusCode) {
if (this.extListener) {
this.extListener.onStopRequest(aRequest, aContext, aStatusCode);
}
@ -299,20 +302,21 @@ ChromeActions.prototype = {
sendResponse(false);
}
},
onDataAvailable: function(aRequest, aContext, aInputStream, aOffset,
aCount) {
this.extListener.onDataAvailable(aRequest, aContext, aInputStream,
onDataAvailable(aRequest, aContext, aDataInputStream, aOffset, aCount) {
this.extListener.onDataAvailable(aRequest, aContext, aDataInputStream,
aOffset, aCount);
}
};
channel.asyncOpen2(listener);
});
},
getLocale: function() {
}
getLocale() {
return getStringPref('general.useragent.locale', 'en-US');
},
getStrings: function(data) {
}
getStrings(data) {
try {
// Lazy initialization of localizedStrings
if (!('localizedStrings' in this)) {
@ -324,8 +328,9 @@ ChromeActions.prototype = {
log('Unable to retrieve localized strings: ' + e);
return 'null';
}
},
supportsIntegratedFind: function() {
}
supportsIntegratedFind() {
// Integrated find is only supported when we're not in a frame
if (this.domWindow.frameElement !== null) {
return false;
@ -339,22 +344,26 @@ ChromeActions.prototype = {
// ... or when the new find events code exists.
var findBar = getFindBar(this.domWindow);
return !!findBar && ('updateControlState' in findBar);
},
supportsDocumentFonts: function() {
}
supportsDocumentFonts() {
var prefBrowser = getIntPref('browser.display.use_document_fonts', 1);
var prefGfx = getBoolPref('gfx.downloadable_fonts.enabled', true);
return (!!prefBrowser && prefGfx);
},
supportsDocumentColors: function() {
}
supportsDocumentColors() {
return getIntPref('browser.display.document_color_use', 0) !== 2;
},
supportedMouseWheelZoomModifierKeys: function() {
}
supportedMouseWheelZoomModifierKeys() {
return {
ctrlKey: getIntPref('mousewheel.with_control.action', 3) === 3,
metaKey: getIntPref('mousewheel.with_meta.action', 1) === 3,
};
},
reportTelemetry: function (data) {
}
reportTelemetry(data) {
var probeInfo = JSON.parse(data);
switch (probeInfo.type) {
case 'documentInfo':
@ -409,12 +418,15 @@ ChromeActions.prototype = {
PdfJsTelemetry.onPrint();
break;
}
},
fallback: function(args, sendResponse) {
var featureId = args.featureId;
var url = args.url;
}
/**
* @param {Object} args - Object with `featureId` and `url` properties.
* @param {function} sendResponse - Callback function.
*/
fallback(args, sendResponse) {
var featureId = args.featureId;
var self = this;
var domWindow = this.domWindow;
var strings = getLocalizedStrings('chrome.properties');
var message;
@ -441,8 +453,9 @@ ChromeActions.prototype = {
winmm.removeMessageListener('PDFJS:Child:fallbackDownload',
fallbackDownload);
});
},
updateFindControlState: function(data) {
}
updateFindControlState(data) {
if (!this.supportsIntegratedFind()) {
return;
}
@ -461,8 +474,9 @@ ChromeActions.prototype = {
.getInterface(Ci.nsIContentFrameMessageManager);
winmm.sendAsyncMessage('PDFJS:Parent:updateControlState', data);
},
setPreferences: function(prefs, sendResponse) {
}
setPreferences(prefs, sendResponse) {
var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + '.');
var numberOfPrefs = 0;
var prefValue, prefName;
@ -496,8 +510,9 @@ ChromeActions.prototype = {
if (sendResponse) {
sendResponse(true);
}
},
getPreferences: function(prefs, sendResponse) {
}
getPreferences(prefs, sendResponse) {
var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + '.');
var currentPrefs = {}, numberOfPrefs = 0;
var prefValue, prefName;
@ -529,17 +544,16 @@ ChromeActions.prototype = {
return JSON.stringify(currentPrefs);
}
}
};
}
var RangedChromeActions = (function RangedChromeActionsClosure() {
/**
* This is for range requests
*/
function RangedChromeActions(
domWindow, contentDispositionFilename, originalRequest,
/**
* This is for range requests.
*/
class RangedChromeActions extends ChromeActions {
constructor(domWindow, contentDispositionFilename, originalRequest,
rangeEnabled, streamingEnabled, dataListener) {
ChromeActions.call(this, domWindow, contentDispositionFilename);
super(domWindow, contentDispositionFilename);
this.dataListener = dataListener;
this.originalRequest = originalRequest;
this.rangeEnabled = rangeEnabled;
@ -551,7 +565,7 @@ var RangedChromeActions = (function RangedChromeActionsClosure() {
// Pass all the headers from the original request through
var httpHeaderVisitor = {
headers: {},
visitHeader: function(aHeader, aValue) {
visitHeader(aHeader, aValue) {
if (aHeader === 'Range') {
// When loading the PDF from cache, firefox seems to set the Range
// request header to fetch only the unfetched portions of the file
@ -587,7 +601,7 @@ var RangedChromeActions = (function RangedChromeActionsClosure() {
this.networkManager = new NetworkManager(this.pdfUrl, {
httpHeaders: httpHeaderVisitor.headers,
getXhr: getXhr
getXhr,
});
// If we are in range request mode, this means we manually issued xhr
@ -598,12 +612,7 @@ var RangedChromeActions = (function RangedChromeActionsClosure() {
});
}
RangedChromeActions.prototype = Object.create(ChromeActions.prototype);
var proto = RangedChromeActions.prototype;
proto.constructor = RangedChromeActions;
proto.initPassiveLoading = function RangedChromeActions_initPassiveLoading() {
var self = this;
initPassiveLoading() {
var data;
if (!this.streamingEnabled) {
this.originalRequest.cancel(Cr.NS_BINDING_ABORTED);
@ -613,16 +622,16 @@ var RangedChromeActions = (function RangedChromeActionsClosure() {
} else {
data = this.dataListener.readData();
this.dataListener.onprogress = function (loaded, total) {
self.domWindow.postMessage({
this.dataListener.onprogress = (loaded, total) => {
this.domWindow.postMessage({
pdfjsLoadAction: 'progressiveRead',
loaded: loaded,
total: total,
chunk: self.dataListener.readData()
loaded,
total,
chunk: this.dataListener.readData(),
}, '*');
};
this.dataListener.oncomplete = function () {
self.dataListener = null;
this.dataListener.oncomplete = () => {
this.dataListener = null;
};
}
@ -632,13 +641,13 @@ var RangedChromeActions = (function RangedChromeActionsClosure() {
streamingEnabled: this.streamingEnabled,
pdfUrl: this.pdfUrl,
length: this.contentLength,
data: data
data,
}, '*');
return true;
};
}
proto.requestDataRange = function RangedChromeActions_requestDataRange(args) {
requestDataRange(args) {
if (!this.rangeEnabled) {
return;
}
@ -650,11 +659,11 @@ var RangedChromeActions = (function RangedChromeActionsClosure() {
// errors from chrome code for non-range requests, so this doesn't
// seem high-pri
this.networkManager.requestRange(begin, end, {
onDone: function RangedChromeActions_onDone(args) {
onDone: function RangedChromeActions_onDone(aArgs) {
domWindow.postMessage({
pdfjsLoadAction: 'range',
begin: args.begin,
chunk: args.chunk
begin: aArgs.begin,
chunk: aArgs.chunk,
}, '*');
},
onProgress: function RangedChromeActions_onProgress(evt) {
@ -664,162 +673,155 @@ var RangedChromeActions = (function RangedChromeActionsClosure() {
}, '*');
}
});
};
}
proto.abortLoading = function RangedChromeActions_abortLoading() {
abortLoading() {
this.networkManager.abortAllRequests();
if (this.originalRequest) {
this.originalRequest.cancel(Cr.NS_BINDING_ABORTED);
this.originalRequest = null;
}
this.dataListener = null;
};
}
}
return RangedChromeActions;
})();
var StandardChromeActions = (function StandardChromeActionsClosure() {
/**
* This is for a single network stream
*/
function StandardChromeActions(domWindow, contentDispositionFilename,
originalRequest, dataListener) {
ChromeActions.call(this, domWindow, contentDispositionFilename);
/**
* This is for a single network stream.
*/
class StandardChromeActions extends ChromeActions {
constructor(domWindow, contentDispositionFilename, originalRequest,
dataListener) {
super(domWindow, contentDispositionFilename);
this.originalRequest = originalRequest;
this.dataListener = dataListener;
}
StandardChromeActions.prototype = Object.create(ChromeActions.prototype);
var proto = StandardChromeActions.prototype;
proto.constructor = StandardChromeActions;
proto.initPassiveLoading =
function StandardChromeActions_initPassiveLoading() {
initPassiveLoading() {
if (!this.dataListener) {
return false;
}
var self = this;
this.dataListener.onprogress = function ChromeActions_dataListenerProgress(
loaded, total) {
self.domWindow.postMessage({
this.dataListener.onprogress = (loaded, total) => {
this.domWindow.postMessage({
pdfjsLoadAction: 'progress',
loaded: loaded,
total: total
loaded,
total,
}, '*');
};
this.dataListener.oncomplete =
function StandardChromeActions_dataListenerComplete(data, errorCode) {
self.domWindow.postMessage({
this.dataListener.oncomplete = (data, errorCode) => {
this.domWindow.postMessage({
pdfjsLoadAction: 'complete',
data: data,
errorCode: errorCode
data,
errorCode,
}, '*');
self.dataListener = null;
self.originalRequest = null;
this.dataListener = null;
this.originalRequest = null;
};
return true;
};
}
proto.abortLoading = function StandardChromeActions_abortLoading() {
abortLoading() {
if (this.originalRequest) {
this.originalRequest.cancel(Cr.NS_BINDING_ABORTED);
this.originalRequest = null;
}
this.dataListener = null;
};
return StandardChromeActions;
})();
// Event listener to trigger chrome privileged code.
function RequestListener(actions) {
this.actions = actions;
}
// Receive an event and synchronously or asynchronously responds.
RequestListener.prototype.receive = function(event) {
var message = event.target;
var doc = message.ownerDocument;
var action = event.detail.action;
var data = event.detail.data;
var sync = event.detail.sync;
var actions = this.actions;
if (!(action in actions)) {
log('Unknown action: ' + action);
return;
}
var response;
if (sync) {
response = actions[action].call(this.actions, data);
event.detail.response = Cu.cloneInto(response, doc.defaultView);
} else {
if (!event.detail.responseExpected) {
doc.documentElement.removeChild(message);
response = null;
} else {
response = function sendResponse(response) {
try {
var listener = doc.createEvent('CustomEvent');
let detail = Cu.cloneInto({ response: response }, doc.defaultView);
listener.initCustomEvent('pdf.js.response', true, false, detail);
return message.dispatchEvent(listener);
} catch (e) {
// doc is no longer accessible because the requestor is already
// gone. unloaded content cannot receive the response anyway.
return false;
}
};
}
/**
* Event listener to trigger chrome privileged code.
*/
class RequestListener {
constructor(actions) {
this.actions = actions;
}
// Receive an event and synchronously or asynchronously responds.
receive(event) {
var message = event.target;
var doc = message.ownerDocument;
var action = event.detail.action;
var data = event.detail.data;
var sync = event.detail.sync;
var actions = this.actions;
if (!(action in actions)) {
log('Unknown action: ' + action);
return;
}
var response;
if (sync) {
response = actions[action].call(this.actions, data);
event.detail.response = Cu.cloneInto(response, doc.defaultView);
} else {
if (!event.detail.responseExpected) {
doc.documentElement.removeChild(message);
response = null;
} else {
response = function sendResponse(aResponse) {
try {
var listener = doc.createEvent('CustomEvent');
let detail = Cu.cloneInto({ response: aResponse }, doc.defaultView);
listener.initCustomEvent('pdf.js.response', true, false, detail);
return message.dispatchEvent(listener);
} catch (e) {
// doc is no longer accessible because the requestor is already
// gone. unloaded content cannot receive the response anyway.
return false;
}
};
}
actions[action].call(this.actions, data, response);
}
actions[action].call(this.actions, data, response);
}
};
// Forwards events from the eventElement to the contentWindow only if the
// content window matches the currently selected browser window.
function FindEventManager(contentWindow) {
this.contentWindow = contentWindow;
this.winmm = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
}
FindEventManager.prototype.bind = function() {
var unload = function(e) {
this.unbind();
this.contentWindow.removeEventListener(e.type, unload);
}.bind(this);
this.contentWindow.addEventListener('unload', unload);
/**
* Forwards events from the eventElement to the contentWindow only if the
* content window matches the currently selected browser window.
*/
class FindEventManager {
constructor(contentWindow) {
this.contentWindow = contentWindow;
this.winmm = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
}
// We cannot directly attach listeners to for the find events
// since the FindBar is in the parent process. Instead we're
// asking the PdfjsChromeUtils to do it for us and forward
// all the find events to us.
this.winmm.sendAsyncMessage('PDFJS:Parent:addEventListener');
this.winmm.addMessageListener('PDFJS:Child:handleEvent', this);
};
bind() {
var unload = function(e) {
this.unbind();
this.contentWindow.removeEventListener(e.type, unload);
}.bind(this);
this.contentWindow.addEventListener('unload', unload);
FindEventManager.prototype.receiveMessage = function(msg) {
var detail = msg.data.detail;
var type = msg.data.type;
var contentWindow = this.contentWindow;
// We cannot directly attach listeners to for the find events
// since the FindBar is in the parent process. Instead we're
// asking the PdfjsChromeUtils to do it for us and forward
// all the find events to us.
this.winmm.sendAsyncMessage('PDFJS:Parent:addEventListener');
this.winmm.addMessageListener('PDFJS:Child:handleEvent', this);
}
detail = Cu.cloneInto(detail, contentWindow);
var forward = contentWindow.document.createEvent('CustomEvent');
forward.initCustomEvent(type, true, true, detail);
contentWindow.dispatchEvent(forward);
};
receiveMessage(msg) {
var detail = msg.data.detail;
var type = msg.data.type;
var contentWindow = this.contentWindow;
FindEventManager.prototype.unbind = function() {
this.winmm.sendAsyncMessage('PDFJS:Parent:removeEventListener');
};
detail = Cu.cloneInto(detail, contentWindow);
var forward = contentWindow.document.createEvent('CustomEvent');
forward.initCustomEvent(type, true, true, detail);
contentWindow.dispatchEvent(forward);
}
unbind() {
this.winmm.sendAsyncMessage('PDFJS:Parent:removeEventListener');
}
}
function PdfStreamConverter() {
}
@ -858,18 +860,18 @@ PdfStreamConverter.prototype = {
*/
// nsIStreamConverter::convert
convert: function(aFromStream, aFromType, aToType, aCtxt) {
convert(aFromStream, aFromType, aToType, aCtxt) {
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
// nsIStreamConverter::asyncConvertData
asyncConvertData: function(aFromType, aToType, aListener, aCtxt) {
asyncConvertData(aFromType, aToType, aListener, aCtxt) {
// Store the listener passed to us
this.listener = aListener;
},
// nsIStreamListener::onDataAvailable
onDataAvailable: function(aRequest, aContext, aInputStream, aOffset, aCount) {
onDataAvailable(aRequest, aContext, aInputStream, aOffset, aCount) {
if (!this.dataListener) {
return;
}
@ -881,7 +883,7 @@ PdfStreamConverter.prototype = {
},
// nsIRequestObserver::onStartRequest
onStartRequest: function(aRequest, aContext) {
onStartRequest(aRequest, aContext) {
// Setup the request so we can use it below.
var isHttpRequest = false;
try {
@ -960,14 +962,14 @@ PdfStreamConverter.prototype = {
// request(aRequest) below so we don't overwrite the original channel and
// trigger an assertion.
var proxy = {
onStartRequest: function(request, context) {
onStartRequest(request, context) {
listener.onStartRequest(aRequest, aContext);
},
onDataAvailable: function(request, context, inputStream, offset, count) {
onDataAvailable(request, context, inputStream, offset, count) {
listener.onDataAvailable(aRequest, aContext, inputStream,
offset, count);
},
onStopRequest: function(request, context, statusCode) {
onStopRequest(request, context, statusCode) {
// We get the DOM window here instead of before the request since it
// may have changed during a redirect.
var domWindow = getDOMWindow(channel);
@ -1017,7 +1019,7 @@ PdfStreamConverter.prototype = {
},
// nsIRequestObserver::onStopRequest
onStopRequest: function(aRequest, aContext, aStatusCode) {
onStopRequest(aRequest, aContext, aStatusCode) {
if (!this.dataListener) {
// Do nothing
return;

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

@ -67,7 +67,7 @@ var PdfjsChromeUtils = {
* Public API
*/
init: function () {
init() {
this._browsers = new WeakSet();
if (!this._ppmm) {
// global parent process message manager (PPMM)
@ -94,7 +94,7 @@ var PdfjsChromeUtils = {
}
},
uninit: function () {
uninit() {
if (this._ppmm) {
this._ppmm.removeMessageListener('PDFJS:Parent:clearUserPref', this);
this._ppmm.removeMessageListener('PDFJS:Parent:setIntPref', this);
@ -123,7 +123,7 @@ var PdfjsChromeUtils = {
* instruct the child to refresh its configuration and (possibly)
* the module's registration.
*/
notifyChildOfSettingsChange: function () {
notifyChildOfSettingsChange() {
if (Services.appinfo.processType ===
Services.appinfo.PROCESS_TYPE_DEFAULT && this._ppmm) {
// XXX kinda bad, we want to get the parent process mm associated
@ -139,13 +139,13 @@ var PdfjsChromeUtils = {
* Events
*/
observe: function(aSubject, aTopic, aData) {
observe(aSubject, aTopic, aData) {
if (aTopic === 'quit-application') {
this.uninit();
}
},
receiveMessage: function (aMsg) {
receiveMessage(aMsg) {
switch (aMsg.name) {
case 'PDFJS:Parent:clearUserPref':
this._clearUserPref(aMsg.data.name);
@ -182,20 +182,20 @@ var PdfjsChromeUtils = {
* Internal
*/
_findbarFromMessage: function(aMsg) {
_findbarFromMessage(aMsg) {
let browser = aMsg.target;
let tabbrowser = browser.getTabBrowser();
let tab = tabbrowser.getTabForBrowser(browser);
return tabbrowser.getFindBar(tab);
},
_updateControlState: function (aMsg) {
_updateControlState(aMsg) {
let data = aMsg.data;
this._findbarFromMessage(aMsg)
.updateControlState(data.result, data.findPrevious);
},
handleEvent: function(aEvent) {
handleEvent(aEvent) {
// To avoid forwarding the message as a CPOW, create a structured cloneable
// version of the event for both performance, and ease of usage, reasons.
let type = aEvent.type;
@ -213,8 +213,7 @@ var PdfjsChromeUtils = {
}
// Only forward the events if the current browser is a registered browser.
let mm = browser.messageManager;
mm.sendAsyncMessage('PDFJS:Child:handleEvent',
{ type: type, detail: detail });
mm.sendAsyncMessage('PDFJS:Child:handleEvent', { type, detail, });
aEvent.preventDefault();
},
@ -223,7 +222,7 @@ var PdfjsChromeUtils = {
'findhighlightallchange',
'findcasesensitivitychange'],
_addEventListener: function (aMsg) {
_addEventListener(aMsg) {
let browser = aMsg.target;
if (this._browsers.has(browser)) {
throw new Error('FindEventManager was bound 2nd time ' +
@ -242,7 +241,7 @@ var PdfjsChromeUtils = {
}
},
_removeEventListener: function (aMsg) {
_removeEventListener(aMsg) {
let browser = aMsg.target;
if (!this._browsers.has(browser)) {
throw new Error('FindEventManager was unbound without binding it first.');
@ -258,7 +257,7 @@ var PdfjsChromeUtils = {
}
},
_ensurePreferenceAllowed: function (aPrefName) {
_ensurePreferenceAllowed(aPrefName) {
let unPrefixedName = aPrefName.split(PREF_PREFIX + '.');
if (unPrefixedName[0] !== '' ||
this._allowedPrefNames.indexOf(unPrefixedName[1]) === -1) {
@ -268,27 +267,27 @@ var PdfjsChromeUtils = {
}
},
_clearUserPref: function (aPrefName) {
_clearUserPref(aPrefName) {
this._ensurePreferenceAllowed(aPrefName);
Services.prefs.clearUserPref(aPrefName);
},
_setIntPref: function (aPrefName, aPrefValue) {
_setIntPref(aPrefName, aPrefValue) {
this._ensurePreferenceAllowed(aPrefName);
Services.prefs.setIntPref(aPrefName, aPrefValue);
},
_setBoolPref: function (aPrefName, aPrefValue) {
_setBoolPref(aPrefName, aPrefValue) {
this._ensurePreferenceAllowed(aPrefName);
Services.prefs.setBoolPref(aPrefName, aPrefValue);
},
_setCharPref: function (aPrefName, aPrefValue) {
_setCharPref(aPrefName, aPrefValue) {
this._ensurePreferenceAllowed(aPrefName);
Services.prefs.setCharPref(aPrefName, aPrefValue);
},
_setStringPref: function (aPrefName, aPrefValue) {
_setStringPref(aPrefName, aPrefValue) {
this._ensurePreferenceAllowed(aPrefName);
let str = Cc['@mozilla.org/supports-string;1']
.createInstance(Ci.nsISupportsString);
@ -301,7 +300,7 @@ var PdfjsChromeUtils = {
* we bounce this pdfjs enabled configuration check over to the
* parent.
*/
isDefaultHandlerApp: function () {
isDefaultHandlerApp() {
var handlerInfo = Svc.mime.getFromTypeAndExtension(PDF_CONTENT_TYPE, 'pdf');
return (!handlerInfo.alwaysAskBeforeHandling &&
handlerInfo.preferredAction === Ci.nsIHandlerInfo.handleInternally);
@ -311,7 +310,7 @@ var PdfjsChromeUtils = {
* Display a notification warning when the renderer isn't sure
* a pdf displayed correctly.
*/
_displayWarning: function (aMsg) {
_displayWarning(aMsg) {
let data = aMsg.data;
let browser = aMsg.target;
@ -324,13 +323,12 @@ var PdfjsChromeUtils = {
let messageSent = false;
function sendMessage(download) {
let mm = browser.messageManager;
mm.sendAsyncMessage('PDFJS:Child:fallbackDownload',
{ download: download });
mm.sendAsyncMessage('PDFJS:Child:fallbackDownload', { download, });
}
let buttons = [{
label: data.label,
accessKey: data.accessKey,
callback: function() {
callback() {
messageSent = true;
sendMessage(true);
}

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

@ -38,7 +38,7 @@ var PdfjsContentUtils = {
Services.appinfo.PROCESS_TYPE_CONTENT);
},
init: function () {
init() {
// child *process* mm, or when loaded into the parent for in-content
// support the psuedo child process mm 'child PPMM'.
if (!this._mm) {
@ -49,7 +49,7 @@ var PdfjsContentUtils = {
}
},
uninit: function () {
uninit() {
if (this._mm) {
this._mm.removeMessageListener('PDFJS:Child:refreshSettings', this);
Services.obs.removeObserver(this, 'quit-application');
@ -63,34 +63,34 @@ var PdfjsContentUtils = {
* approved pdfjs prefs in chrome utils.
*/
clearUserPref: function (aPrefName) {
clearUserPref(aPrefName) {
this._mm.sendSyncMessage('PDFJS:Parent:clearUserPref', {
name: aPrefName
});
},
setIntPref: function (aPrefName, aPrefValue) {
setIntPref(aPrefName, aPrefValue) {
this._mm.sendSyncMessage('PDFJS:Parent:setIntPref', {
name: aPrefName,
value: aPrefValue
});
},
setBoolPref: function (aPrefName, aPrefValue) {
setBoolPref(aPrefName, aPrefValue) {
this._mm.sendSyncMessage('PDFJS:Parent:setBoolPref', {
name: aPrefName,
value: aPrefValue
});
},
setCharPref: function (aPrefName, aPrefValue) {
setCharPref(aPrefName, aPrefValue) {
this._mm.sendSyncMessage('PDFJS:Parent:setCharPref', {
name: aPrefName,
value: aPrefValue
});
},
setStringPref: function (aPrefName, aPrefValue) {
setStringPref(aPrefName, aPrefValue) {
this._mm.sendSyncMessage('PDFJS:Parent:setStringPref', {
name: aPrefName,
value: aPrefValue
@ -101,7 +101,7 @@ var PdfjsContentUtils = {
* Forwards default app query to the parent where we check various
* handler app settings only available in the parent process.
*/
isDefaultHandlerApp: function () {
isDefaultHandlerApp() {
return this._mm.sendSyncMessage('PDFJS:Parent:isDefaultHandlerApp')[0];
},
@ -109,7 +109,7 @@ var PdfjsContentUtils = {
* Request the display of a notification warning in the associated window
* when the renderer isn't sure a pdf displayed correctly.
*/
displayWarning: function (aWindow, aMessage, aLabel, accessKey) {
displayWarning(aWindow, aMessage, aLabel, aAccessKey) {
// the child's dom frame mm associated with the window.
let winmm = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell)
@ -118,7 +118,7 @@ var PdfjsContentUtils = {
winmm.sendAsyncMessage('PDFJS:Parent:displayWarning', {
message: aMessage,
label: aLabel,
accessKey: accessKey
accessKey: aAccessKey,
});
},
@ -126,13 +126,13 @@ var PdfjsContentUtils = {
* Events
*/
observe: function(aSubject, aTopic, aData) {
observe(aSubject, aTopic, aData) {
if (aTopic === 'quit-application') {
this.uninit();
}
},
receiveMessage: function (aMsg) {
receiveMessage(aMsg) {
switch (aMsg.name) {
case 'PDFJS:Child:refreshSettings':
// Only react to this if we are remote.

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

@ -23,8 +23,8 @@
}
}(this, function (exports) {
'use strict';
var pdfjsVersion = '1.6.467';
var pdfjsBuild = '54d55e8b';
var pdfjsVersion = '1.7.227';
var pdfjsBuild = 'e132fa97';
var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
var pdfjsLibs = {};
(function pdfjsWrapper() {
@ -1434,6 +1434,7 @@
var warn = sharedUtil.warn;
var deprecated = sharedUtil.deprecated;
var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
var CustomStyle = function CustomStyleClosure() {
var prefixes = [
'ms',
@ -1559,7 +1560,7 @@
globalSettings.externalLinkTarget = LinkTarget.NONE;
return LinkTarget.NONE;
case 'externalLinkRel':
return globalSettings ? globalSettings.externalLinkRel : 'noreferrer';
return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
case 'enableStats':
return !!(globalSettings && globalSettings.enableStats);
default:
@ -1591,6 +1592,7 @@
exports.LinkTarget = LinkTarget;
exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
exports.getDefaultSetting = getDefaultSetting;
exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
}));
(function (root, factory) {
factory(root.pdfjsDisplayFontLoader = {}, root.pdfjsSharedUtil);
@ -5084,15 +5086,13 @@
}
return pattern;
},
setStrokeColorN: function CanvasGraphics_setStrokeColorN()
{
this.current.strokeColor = this.getColorN_Pattern(arguments);
},
setFillColorN: function CanvasGraphics_setFillColorN()
{
this.current.fillColor = this.getColorN_Pattern(arguments);
this.current.patternFill = true;
},
setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
this.current.strokeColor = this.getColorN_Pattern(arguments);
},
setFillColorN: function CanvasGraphics_setFillColorN() {
this.current.fillColor = this.getColorN_Pattern(arguments);
this.current.patternFill = true;
},
setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
var color = Util.makeCssRgb(r, g, b);
this.ctx.strokeStyle = color;
@ -6824,7 +6824,7 @@
return;
}
if (this.task.onContinue) {
this.task.onContinue.call(this.task, this._scheduleNextBound);
this.task.onContinue(this._scheduleNextBound);
} else {
this._scheduleNext();
}
@ -6886,6 +6886,7 @@
var deprecated = sharedUtil.deprecated;
var warn = sharedUtil.warn;
var LinkTarget = displayDOMUtils.LinkTarget;
var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
var isWorker = typeof window === 'undefined';
if (!globalScope.PDFJS) {
globalScope.PDFJS = {};
@ -6953,7 +6954,7 @@
PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? 'noreferrer' : PDFJS.externalLinkRel;
PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
PDFJS.getDocument = displayAPI.getDocument;
PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;

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

@ -23,8 +23,8 @@
}
}(this, function (exports) {
'use strict';
var pdfjsVersion = '1.6.467';
var pdfjsBuild = '54d55e8b';
var pdfjsVersion = '1.7.227';
var pdfjsBuild = 'e132fa97';
var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
var pdfjsLibs = {};
(function pdfjsWrapper() {
@ -38197,7 +38197,7 @@
var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
if (op >= 0x71 && op <= 0x75) {
n = stack.pop();
if (n === n) {
if (!isNaN(n)) {
stackDelta = -n * 2;
}
}

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

@ -1,617 +0,0 @@
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// NOTE: Be careful what goes in this file, as it is also used from the context
// of the addon. So using warn/error in here will break the addon.
'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs/core/network', ['exports', 'pdfjs/shared/util',
'pdfjs/core/worker'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../shared/util.js'), require('./worker.js'));
} else {
factory((root.pdfjsCoreNetwork = {}), root.pdfjsSharedUtil,
root.pdfjsCoreWorker);
}
}(this, function (exports, sharedUtil, coreWorker) {
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('FIREFOX || MOZCENTRAL')) {
throw new Error('Module "pdfjs/core/network" shall not ' +
'be used with FIREFOX or MOZCENTRAL build.');
}
var OK_RESPONSE = 200;
var PARTIAL_CONTENT_RESPONSE = 206;
function NetworkManager(url, args) {
this.url = url;
args = args || {};
this.isHttp = /^https?:/i.test(url);
this.httpHeaders = (this.isHttp && args.httpHeaders) || {};
this.withCredentials = args.withCredentials || false;
this.getXhr = args.getXhr ||
function NetworkManager_getXhr() {
return new XMLHttpRequest();
};
this.currXhrId = 0;
this.pendingRequests = Object.create(null);
this.loadedRequests = Object.create(null);
}
function getArrayBuffer(xhr) {
var data = xhr.response;
if (typeof data !== 'string') {
return data;
}
var length = data.length;
var array = new Uint8Array(length);
for (var i = 0; i < length; i++) {
array[i] = data.charCodeAt(i) & 0xFF;
}
return array.buffer;
}
var supportsMozChunked =
typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME') ? false :
(function supportsMozChunkedClosure() {
try {
var x = new XMLHttpRequest();
// Firefox 37- required .open() to be called before setting responseType.
// https://bugzilla.mozilla.org/show_bug.cgi?id=707484
// Even though the URL is not visited, .open() could fail if the URL is
// blocked, e.g. via the connect-src CSP directive or the NoScript addon.
// When this error occurs, this feature detection method will mistakenly
// report that moz-chunked-arraybuffer is not supported in Firefox 37-.
x.open('GET', 'https://example.com');
x.responseType = 'moz-chunked-arraybuffer';
return x.responseType === 'moz-chunked-arraybuffer';
} catch (e) {
return false;
}
})();
NetworkManager.prototype = {
requestRange: function NetworkManager_requestRange(begin, end, listeners) {
var args = {
begin: begin,
end: end
};
for (var prop in listeners) {
args[prop] = listeners[prop];
}
return this.request(args);
},
requestFull: function NetworkManager_requestFull(listeners) {
return this.request(listeners);
},
request: function NetworkManager_request(args) {
var xhr = this.getXhr();
var xhrId = this.currXhrId++;
var pendingRequest = this.pendingRequests[xhrId] = {
xhr: xhr
};
xhr.open('GET', this.url);
xhr.withCredentials = this.withCredentials;
for (var property in this.httpHeaders) {
var value = this.httpHeaders[property];
if (typeof value === 'undefined') {
continue;
}
xhr.setRequestHeader(property, value);
}
if (this.isHttp && 'begin' in args && 'end' in args) {
var rangeStr = args.begin + '-' + (args.end - 1);
xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
pendingRequest.expectedStatus = 206;
} else {
pendingRequest.expectedStatus = 200;
}
var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
if (useMozChunkedLoading) {
xhr.responseType = 'moz-chunked-arraybuffer';
pendingRequest.onProgressiveData = args.onProgressiveData;
pendingRequest.mozChunked = true;
} else {
xhr.responseType = 'arraybuffer';
}
if (args.onError) {
xhr.onerror = function(evt) {
args.onError(xhr.status);
};
}
xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
xhr.onprogress = this.onProgress.bind(this, xhrId);
pendingRequest.onHeadersReceived = args.onHeadersReceived;
pendingRequest.onDone = args.onDone;
pendingRequest.onError = args.onError;
pendingRequest.onProgress = args.onProgress;
xhr.send(null);
return xhrId;
},
onProgress: function NetworkManager_onProgress(xhrId, evt) {
var pendingRequest = this.pendingRequests[xhrId];
if (!pendingRequest) {
// Maybe abortRequest was called...
return;
}
if (pendingRequest.mozChunked) {
var chunk = getArrayBuffer(pendingRequest.xhr);
pendingRequest.onProgressiveData(chunk);
}
var onProgress = pendingRequest.onProgress;
if (onProgress) {
onProgress(evt);
}
},
onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
var pendingRequest = this.pendingRequests[xhrId];
if (!pendingRequest) {
// Maybe abortRequest was called...
return;
}
var xhr = pendingRequest.xhr;
if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
pendingRequest.onHeadersReceived();
delete pendingRequest.onHeadersReceived;
}
if (xhr.readyState !== 4) {
return;
}
if (!(xhrId in this.pendingRequests)) {
// The XHR request might have been aborted in onHeadersReceived()
// callback, in which case we should abort request
return;
}
delete this.pendingRequests[xhrId];
// success status == 0 can be on ftp, file and other protocols
if (xhr.status === 0 && this.isHttp) {
if (pendingRequest.onError) {
pendingRequest.onError(xhr.status);
}
return;
}
var xhrStatus = xhr.status || OK_RESPONSE;
// From http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.2:
// "A server MAY ignore the Range header". This means it's possible to
// get a 200 rather than a 206 response from a range request.
var ok_response_on_range_request =
xhrStatus === OK_RESPONSE &&
pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
if (!ok_response_on_range_request &&
xhrStatus !== pendingRequest.expectedStatus) {
if (pendingRequest.onError) {
pendingRequest.onError(xhr.status);
}
return;
}
this.loadedRequests[xhrId] = true;
var chunk = getArrayBuffer(xhr);
if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
var rangeHeader = xhr.getResponseHeader('Content-Range');
var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
var begin = parseInt(matches[1], 10);
pendingRequest.onDone({
begin: begin,
chunk: chunk
});
} else if (pendingRequest.onProgressiveData) {
pendingRequest.onDone(null);
} else if (chunk) {
pendingRequest.onDone({
begin: 0,
chunk: chunk
});
} else if (pendingRequest.onError) {
pendingRequest.onError(xhr.status);
}
},
hasPendingRequests: function NetworkManager_hasPendingRequests() {
for (var xhrId in this.pendingRequests) {
return true;
}
return false;
},
getRequestXhr: function NetworkManager_getXhr(xhrId) {
return this.pendingRequests[xhrId].xhr;
},
isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
return !!(this.pendingRequests[xhrId].onProgressiveData);
},
isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
return xhrId in this.pendingRequests;
},
isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
return xhrId in this.loadedRequests;
},
abortAllRequests: function NetworkManager_abortAllRequests() {
for (var xhrId in this.pendingRequests) {
this.abortRequest(xhrId | 0);
}
},
abortRequest: function NetworkManager_abortRequest(xhrId) {
var xhr = this.pendingRequests[xhrId].xhr;
delete this.pendingRequests[xhrId];
xhr.abort();
}
};
var assert = sharedUtil.assert;
var createPromiseCapability = sharedUtil.createPromiseCapability;
var isInt = sharedUtil.isInt;
var MissingPDFException = sharedUtil.MissingPDFException;
var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
/** @implements {IPDFStream} */
function PDFNetworkStream(options) {
this._options = options;
var source = options.source;
this._manager = new NetworkManager(source.url, {
httpHeaders: source.httpHeaders,
withCredentials: source.withCredentials
});
this._rangeChunkSize = source.rangeChunkSize;
this._fullRequestReader = null;
this._rangeRequestReaders = [];
}
PDFNetworkStream.prototype = {
_onRangeRequestReaderClosed:
function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
var i = this._rangeRequestReaders.indexOf(reader);
if (i >= 0) {
this._rangeRequestReaders.splice(i, 1);
}
},
getFullReader: function PDFNetworkStream_getFullReader() {
assert(!this._fullRequestReader);
this._fullRequestReader =
new PDFNetworkStreamFullRequestReader(this._manager, this._options);
return this._fullRequestReader;
},
getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
var reader = new PDFNetworkStreamRangeRequestReader(this._manager,
begin, end);
reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
this._rangeRequestReaders.push(reader);
return reader;
},
cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
if (this._fullRequestReader) {
this._fullRequestReader.cancel(reason);
}
var readers = this._rangeRequestReaders.slice(0);
readers.forEach(function (reader) {
reader.cancel(reason);
});
}
};
/** @implements {IPDFStreamReader} */
function PDFNetworkStreamFullRequestReader(manager, options) {
this._manager = manager;
var source = options.source;
var args = {
onHeadersReceived: this._onHeadersReceived.bind(this),
onProgressiveData: source.disableStream ? null :
this._onProgressiveData.bind(this),
onDone: this._onDone.bind(this),
onError: this._onError.bind(this),
onProgress: this._onProgress.bind(this)
};
this._url = source.url;
this._fullRequestId = manager.requestFull(args);
this._headersReceivedCapability = createPromiseCapability();
this._disableRange = options.disableRange || false;
this._contentLength = source.length; // optional
this._rangeChunkSize = source.rangeChunkSize;
if (!this._rangeChunkSize && !this._disableRange) {
this._disableRange = true;
}
this._isStreamingSupported = false;
this._isRangeSupported = false;
this._cachedChunks = [];
this._requests = [];
this._done = false;
this._storedError = undefined;
this.onProgress = null;
}
PDFNetworkStreamFullRequestReader.prototype = {
_validateRangeRequestCapabilities: function
PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
if (this._disableRange) {
return false;
}
var networkManager = this._manager;
if (!networkManager.isHttp) {
return false;
}
var fullRequestXhrId = this._fullRequestId;
var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
return false;
}
var contentEncoding =
fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
if (contentEncoding !== 'identity') {
return false;
}
var length = fullRequestXhr.getResponseHeader('Content-Length');
length = parseInt(length, 10);
if (!isInt(length)) {
return false;
}
this._contentLength = length; // setting right content length
if (length <= 2 * this._rangeChunkSize) {
// The file size is smaller than the size of two chunks, so it does
// not make any sense to abort the request and retry with a range
// request.
return false;
}
return true;
},
_onHeadersReceived:
function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
if (this._validateRangeRequestCapabilities()) {
this._isRangeSupported = true;
}
var networkManager = this._manager;
var fullRequestXhrId = this._fullRequestId;
if (networkManager.isStreamingRequest(fullRequestXhrId)) {
// We can continue fetching when progressive loading is enabled,
// and we don't need the autoFetch feature.
this._isStreamingSupported = true;
} else if (this._isRangeSupported) {
// NOTE: by cancelling the full request, and then issuing range
// requests, there will be an issue for sites where you can only
// request the pdf once. However, if this is the case, then the
// server should not be returning that it can support range
// requests.
networkManager.abortRequest(fullRequestXhrId);
}
this._headersReceivedCapability.resolve();
},
_onProgressiveData:
function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
if (this._requests.length > 0) {
var requestCapability = this._requests.shift();
requestCapability.resolve({value: chunk, done: false});
} else {
this._cachedChunks.push(chunk);
}
},
_onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
if (args) {
this._onProgressiveData(args.chunk);
}
this._done = true;
if (this._cachedChunks.length > 0) {
return;
}
this._requests.forEach(function (requestCapability) {
requestCapability.resolve({value: undefined, done: true});
});
this._requests = [];
},
_onError: function PDFNetworkStreamFullRequestReader_onError(status) {
var url = this._url;
var exception;
if (status === 404 || status === 0 && /^file:/.test(url)) {
exception = new MissingPDFException('Missing PDF "' + url + '".');
} else {
exception = new UnexpectedResponseException(
'Unexpected server response (' + status +
') while retrieving PDF "' + url + '".', status);
}
this._storedError = exception;
this._headersReceivedCapability.reject(exception);
this._requests.forEach(function (requestCapability) {
requestCapability.reject(exception);
});
this._requests = [];
this._cachedChunks = [];
},
_onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
if (this.onProgress) {
this.onProgress({
loaded: data.loaded,
total: data.lengthComputable ? data.total : this._contentLength
});
}
},
get isRangeSupported() {
return this._isRangeSupported;
},
get isStreamingSupported() {
return this._isStreamingSupported;
},
get contentLength() {
return this._contentLength;
},
get headersReady() {
return this._headersReceivedCapability.promise;
},
read: function PDFNetworkStreamFullRequestReader_read() {
if (this._storedError) {
return Promise.reject(this._storedError);
}
if (this._cachedChunks.length > 0) {
var chunk = this._cachedChunks.shift();
return Promise.resolve(chunk);
}
if (this._done) {
return Promise.resolve({value: undefined, done: true});
}
var requestCapability = createPromiseCapability();
this._requests.push(requestCapability);
return requestCapability.promise;
},
cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
this._done = true;
this._headersReceivedCapability.reject(reason);
this._requests.forEach(function (requestCapability) {
requestCapability.resolve({value: undefined, done: true});
});
this._requests = [];
if (this._manager.isPendingRequest(this._fullRequestId)) {
this._manager.abortRequest(this._fullRequestId);
}
this._fullRequestReader = null;
}
};
/** @implements {IPDFStreamRangeReader} */
function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
this._manager = manager;
var args = {
onDone: this._onDone.bind(this),
onProgress: this._onProgress.bind(this)
};
this._requestId = manager.requestRange(begin, end, args);
this._requests = [];
this._queuedChunk = null;
this._done = false;
this.onProgress = null;
this.onClosed = null;
}
PDFNetworkStreamRangeRequestReader.prototype = {
_close: function PDFNetworkStreamRangeRequestReader_close() {
if (this.onClosed) {
this.onClosed(this);
}
},
_onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
var chunk = data.chunk;
if (this._requests.length > 0) {
var requestCapability = this._requests.shift();
requestCapability.resolve({value: chunk, done: false});
} else {
this._queuedChunk = chunk;
}
this._done = true;
this._requests.forEach(function (requestCapability) {
requestCapability.resolve({value: undefined, done: true});
});
this._requests = [];
this._close();
},
_onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
if (!this.isStreamingSupported && this.onProgress) {
this.onProgress({
loaded: evt.loaded
});
}
},
get isStreamingSupported() {
return false; // TODO allow progressive range bytes loading
},
read: function PDFNetworkStreamRangeRequestReader_read() {
if (this._queuedChunk !== null) {
var chunk = this._queuedChunk;
this._queuedChunk = null;
return Promise.resolve({value: chunk, done: false});
}
if (this._done) {
return Promise.resolve({value: undefined, done: true});
}
var requestCapability = createPromiseCapability();
this._requests.push(requestCapability);
return requestCapability.promise;
},
cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
this._done = true;
this._requests.forEach(function (requestCapability) {
requestCapability.resolve({value: undefined, done: true});
});
this._requests = [];
if (this._manager.isPendingRequest(this._requestId)) {
this._manager.abortRequest(this._requestId);
}
this._close();
}
};
coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
exports.PDFNetworkStream = PDFNetworkStream;
exports.NetworkManager = NetworkManager;
}));

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

@ -121,12 +121,12 @@
get: translateString,
// get the document language
getLanguage: function() {
getLanguage() {
return gLanguage;
},
// get the direction (ltr|rtl) of the current language
getDirection: function() {
getDirection() {
// http://www.w3.org/International/questions/qa-scripts
// Arabic, Hebrew, Farsi, Pashto, Urdu
var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
@ -137,9 +137,11 @@
return (rtlList.indexOf(shortCode) >= 0) ? 'rtl' : 'ltr';
},
getReadyState: function() { return gReadyState; },
getReadyState() {
return gReadyState;
},
setExternalLocalizerServices: function (externalLocalizerServices) {
setExternalLocalizerServices(externalLocalizerServices) {
gExternalLocalizerServices = externalLocalizerServices;
// ... in case if we missed DOMContentLoaded above.

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

@ -2478,8 +2478,8 @@ var pdfjsWebLibs;
};
this.anchor = anchor;
var div = document.createElement('div');
div.id = 'thumbnailContainer' + id;
div.className = 'thumbnail';
div.setAttribute('data-page-number', this.id);
this.div = div;
if (id === 1) {
div.classList.add('selected');
@ -3873,7 +3873,7 @@ var pdfjsWebLibs;
this.annotationLayerFactory = annotationLayerFactory;
this.renderer = options.renderer || RendererType.CANVAS;
this.paintTask = null;
this.paintedViewport = null;
this.paintedViewportMap = new WeakMap();
this.renderingState = RenderingStates.INITIAL;
this.resume = null;
this.error = null;
@ -3883,7 +3883,6 @@ var pdfjsWebLibs;
this.zoomLayer = null;
this.annotationLayer = null;
var div = document.createElement('div');
div.id = 'pageContainer' + this.id;
div.className = 'page';
div.style.width = Math.floor(this.viewport.width) + 'px';
div.style.height = Math.floor(this.viewport.height) + 'px';
@ -3929,16 +3928,15 @@ var pdfjsWebLibs;
this.annotationLayer = null;
}
if (this.canvas && !currentZoomLayerNode) {
this.paintedViewportMap.delete(this.canvas);
this.canvas.width = 0;
this.canvas.height = 0;
delete this.canvas;
}
if (this.svg) {
this.paintedViewportMap.delete(this.svg);
delete this.svg;
}
if (!currentZoomLayerNode) {
this.paintedViewport = null;
}
this.loadingIconDiv = document.createElement('div');
this.loadingIconDiv.className = 'loadingIcon';
div.appendChild(this.loadingIconDiv);
@ -4013,7 +4011,7 @@ var pdfjsWebLibs;
var div = this.div;
target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
var relativeRotation = this.viewport.rotation - this.paintedViewport.rotation;
var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
var absRotation = Math.abs(relativeRotation);
var scaleX = 1, scaleY = 1;
if (absRotation === 90 || absRotation === 270) {
@ -4131,6 +4129,7 @@ var pdfjsWebLibs;
}
if (self.zoomLayer) {
var zoomLayerCanvas = self.zoomLayer.firstChild;
self.paintedViewportMap.delete(zoomLayerCanvas);
zoomLayerCanvas.width = 0;
zoomLayerCanvas.height = 0;
if (div.contains(self.zoomLayer)) {
@ -4238,7 +4237,7 @@ var pdfjsWebLibs;
canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]);
canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';
canvas.style.height = roundToDivide(viewport.height, sfy[1]) + 'px';
this.paintedViewport = viewport;
this.paintedViewportMap.set(canvas, viewport);
var transform = !outputScale.scaled ? null : [
outputScale.sx,
0,
@ -4324,7 +4323,7 @@ var pdfjsWebLibs;
if (selected) {
selected.classList.remove('selected');
}
var thumbnail = document.getElementById('thumbnailContainer' + page);
var thumbnail = document.querySelector('div.thumbnail[data-page-number="' + page + '"]');
if (thumbnail) {
thumbnail.classList.add('selected');
}

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

@ -919,7 +919,9 @@ cargo_build_flags += --frozen
endif
cargo_build_flags += --manifest-path $(CARGO_FILE)
ifdef BUILD_VERBOSE_LOG
cargo_build_flags += --verbose
endif
# Enable color output if original stdout was a TTY and color settings
# aren't already present. This essentially restores the default behavior

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

@ -64,7 +64,11 @@ const ResponsePanel = createClass({
try {
json = JSON.parse(response);
} catch (err) {
error = err;
try {
json = JSON.parse(atob(response));
} catch (err64) {
error = err;
}
}
if (/\bjson/.test(mimeType) || json) {

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

@ -16,6 +16,7 @@ support-files =
html_frame-subdocument.html
html_filter-test-page.html
html_infinite-get-page.html
html_json-b64.html
html_json-custom-mime-test-page.html
html_json-long-test-page.html
html_json-malformed-test-page.html
@ -105,6 +106,7 @@ skip-if = (os == 'linux' && debug && bits == 32) # Bug 1303439
[browser_net_html-preview.js]
[browser_net_icon-preview.js]
[browser_net_image-tooltip.js]
[browser_net_json-b64.js]
[browser_net_json-long.js]
[browser_net_json-malformed.js]
[browser_net_json_custom_mime.js]

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

@ -0,0 +1,62 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests if JSON responses encoded in base64 are handled correctly.
*/
add_task(function* () {
let { L10N } = require("devtools/client/netmonitor/l10n");
let { tab, monitor } = yield initNetMonitor(JSON_B64_URL);
info("Starting test... ");
let { document, NetMonitorView } = monitor.panelWin;
let { RequestsMenu } = NetMonitorView;
RequestsMenu.lazyUpdate = false;
let wait = waitForNetworkEvents(monitor, 1);
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
content.wrappedJSObject.performRequests();
});
yield wait;
wait = waitForDOM(document, "#panel-3");
EventUtils.sendMouseEvent({ type: "mousedown" },
document.getElementById("details-pane-toggle"));
document.querySelector("#tab-3 a").click();
yield wait;
let tabpanel = document.querySelector("#panel-3");
is(tabpanel.querySelector(".response-error-header") === null, true,
"The response error header doesn't have the intended visibility.");
let jsonView = tabpanel.querySelector(".tree-section .treeLabel") || {};
is(jsonView.textContent === L10N.getStr("jsonScopeName"), true,
"The response json view has the intended visibility.");
is(tabpanel.querySelector(".editor-mount iframe") === null, true,
"The response editor doesn't have the intended visibility.");
is(tabpanel.querySelector(".response-image-box") === null, true,
"The response image box doesn't have the intended visibility.");
is(tabpanel.querySelectorAll(".tree-section").length, 1,
"There should be 1 tree sections displayed in this tabpanel.");
is(tabpanel.querySelectorAll(".treeRow:not(.tree-section)").length, 1,
"There should be 1 json properties displayed in this tabpanel.");
is(tabpanel.querySelectorAll(".empty-notice").length, 0,
"The empty notice should not be displayed in this tabpanel.");
let labels = tabpanel
.querySelectorAll("tr:not(.tree-section) .treeLabelCell .treeLabel");
let values = tabpanel
.querySelectorAll("tr:not(.tree-section) .treeValueCell .objectBox");
is(labels[0].textContent, "greeting",
"The first json property name was incorrect.");
is(values[0].textContent, "\"This is a base 64 string.\"",
"The first json property value was incorrect.");
yield teardown(monitor);
});

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

@ -39,6 +39,7 @@ const JSON_LONG_URL = EXAMPLE_URL + "html_json-long-test-page.html";
const JSON_MALFORMED_URL = EXAMPLE_URL + "html_json-malformed-test-page.html";
const JSON_CUSTOM_MIME_URL = EXAMPLE_URL + "html_json-custom-mime-test-page.html";
const JSON_TEXT_MIME_URL = EXAMPLE_URL + "html_json-text-mime-test-page.html";
const JSON_B64_URL = EXAMPLE_URL + "html_json-b64.html";
const SORTING_URL = EXAMPLE_URL + "html_sorting-test-page.html";
const FILTERING_URL = EXAMPLE_URL + "html_filter-test-page.html";
const INFINITE_GET_URL = EXAMPLE_URL + "html_infinite-get-page.html";

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

@ -0,0 +1,38 @@
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<title>Network Monitor test page</title>
</head>
<body>
<p>JSON b64 test</p>
<script type="text/javascript">
function get(aAddress, aCallback) {
var xhr = new XMLHttpRequest();
xhr.open("GET", aAddress, true);
xhr.onreadystatechange = function() {
if (this.readyState == this.DONE) {
aCallback();
}
};
xhr.send(null);
}
function performRequests() {
get("sjs_content-type-test-server.sjs?fmt=json-b64", function() {
// Done.
});
}
</script>
</body>
</html>

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

@ -137,6 +137,14 @@ function handleRequest(request, response) {
response.finish();
break;
}
case "json-b64": {
response.setStatusLine(request.httpVersion, status, "OK");
response.setHeader("Content-Type", "text/json; charset=utf-8", false);
setCacheHeaders();
response.write(btoa("{ \"greeting\": \"This is a base 64 string.\" }"));
response.finish();
break;
}
case "json-long": {
let str = "{ \"greeting\": \"Hello long string JSON!\" },";
response.setStatusLine(request.httpVersion, status, "OK");

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

@ -8,42 +8,25 @@
#define mozilla_dom_Dispatcher_h
#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/TaskCategory.h"
#include "nsISupports.h"
class nsIEventTarget;
class nsIRunnable;
// This file defines basic functionality for dispatching runnables to various
// groups: either the SystemGroup or a DocGroup or TabGroup. Ideally all
// runnables destined for the main thread should be dispatched to a group
// instead so that we know what kind of web content they'll be
// touching. Runnables sent to the SystemGroup never touch web
// content. Runnables sent to a DocGroup can only touch documents belonging to
// that DocGroup. Runnables sent to a TabGroup can touch any document in any of
// the tabs belonging to the TabGroup.
namespace mozilla {
class AbstractThread;
namespace dom {
class TabGroup;
class DocGroup;
enum class TaskCategory {
// User input (clicks, keypresses, etc.)
UI,
// Data from the network
Network,
// setTimeout, setInterval
Timer,
// Runnables posted from a worker to the main thread
Worker,
// requestIdleCallback
IdleCallback,
// Vsync notifications
RefreshDriver,
// Most DOM events (postMessage, media, plugins)
Other,
Count
};
// This trait should be attached to classes like nsIGlobalObject and nsIDocument
// that have a DocGroup or TabGroup attached to them. The methods here should
@ -83,7 +66,7 @@ public:
// off the main thread.
virtual AbstractThread* AbstractMainThreadFor(TaskCategory aCategory) = 0;
// These methods perform a safe cast. They return null if |this| is not of the
// This method performs a safe cast. It returns null if |this| is not of the
// requested type.
virtual TabGroup* AsTabGroup() { return nullptr; }

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

@ -12,7 +12,11 @@
#include "nsCOMPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsDOMNavigationTiming.h"
#include "nsICancelableRunnable.h"
#include "nsIIncrementalRunnable.h"
#include "nsIRunnable.h"
#include "nsITimeoutHandler.h"
#include "nsString.h"
class nsPIDOMWindowInner;

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

@ -3013,7 +3013,7 @@ nsIDocument::EventTargetFor(TaskCategory aCategory) const
}
AbstractThread*
nsIDocument::AbstractMainThreadFor(mozilla::dom::TaskCategory aCategory)
nsIDocument::AbstractMainThreadFor(mozilla::TaskCategory aCategory)
{
MOZ_ASSERT(NS_IsMainThread());
if (mDocGroup) {

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

@ -1777,14 +1777,14 @@ private:
public:
// Dispatch a runnable related to the global.
virtual nsresult Dispatch(const char* aName,
mozilla::dom::TaskCategory aCategory,
mozilla::TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable) override;
virtual nsIEventTarget*
EventTargetFor(mozilla::dom::TaskCategory aCategory) const override;
EventTargetFor(mozilla::TaskCategory aCategory) const override;
virtual mozilla::AbstractThread*
AbstractMainThreadFor(mozilla::dom::TaskCategory aCategory) override;
AbstractMainThreadFor(mozilla::TaskCategory aCategory) override;
protected:
// These members are only used on outer window objects. Make sure

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

@ -2876,14 +2876,14 @@ public:
// Dispatch a runnable related to the document.
virtual nsresult Dispatch(const char* aName,
mozilla::dom::TaskCategory aCategory,
mozilla::TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable) override;
virtual nsIEventTarget*
EventTargetFor(mozilla::dom::TaskCategory aCategory) const override;
EventTargetFor(mozilla::TaskCategory aCategory) const override;
virtual mozilla::AbstractThread*
AbstractMainThreadFor(mozilla::dom::TaskCategory aCategory) override;
AbstractMainThreadFor(mozilla::TaskCategory aCategory) override;
// The URLs passed to these functions should match what
// JS::DescribeScriptedCaller() returns, since these APIs are used to

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

@ -604,7 +604,7 @@ public:
mozilla::dom::DocGroup* GetDocGroup() const;
virtual nsIEventTarget*
EventTargetFor(mozilla::dom::TaskCategory aCategory) const = 0;
EventTargetFor(mozilla::TaskCategory aCategory) const = 0;
protected:
// The nsPIDOMWindow constructor. The aOuterWindow argument should

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

@ -162,13 +162,14 @@ JSEventHandler::HandleEvent(nsIDOMEvent* aEvent)
RefPtr<OnErrorEventHandlerNonNull> handler =
mTypedHandler.OnErrorEventHandler();
ErrorResult rv;
bool handled = handler->Call(mTarget, msgOrEvent, fileName, lineNumber,
columnNumber, error, rv);
JS::Rooted<JS::Value> retval(RootingCx());
handler->Call(mTarget, msgOrEvent, fileName, lineNumber,
columnNumber, error, &retval, rv);
if (rv.Failed()) {
return rv.StealNSResult();
}
if (handled) {
if (retval.isBoolean() && retval.toBoolean()) {
event->PreventDefaultInternal(isChromeHandler);
}
return NS_OK;

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

@ -4548,6 +4548,7 @@ nsresult HTMLMediaElement::InitializeDecoderAsClone(MediaDecoder* aOriginal)
originalResource->CloneData(decoder->GetResourceCallback());
if (!resource) {
decoder->Shutdown();
LOG(LogLevel::Debug, ("%p Failed to cloned stream for decoder %p", this, decoder.get()));
return NS_ERROR_FAILURE;
}
@ -4587,8 +4588,10 @@ nsresult HTMLMediaElement::InitializeDecoderForChannel(nsIChannel* aChannel,
RefPtr<MediaResource> resource =
MediaResource::Create(decoder->GetResourceCallback(), aChannel);
if (!resource)
if (!resource) {
decoder->Shutdown();
return NS_ERROR_OUT_OF_MEMORY;
}
if (mChannelLoader) {
mChannelLoader->Done();

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

@ -763,8 +763,12 @@ protected:
class ShutdownObserver;
MediaDecoderOwner::NextFrameStatus NextFrameStatus();
void SetDecoder(MediaDecoder* aDecoder) {
MOZ_ASSERT(aDecoder); // Use ShutdownDecoder() to clear.
if (mDecoder) {
ShutdownDecoder();
}
mDecoder = aDecoder;
}

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

@ -31,6 +31,7 @@
#include "mozilla/dom/ExternalHelperAppChild.h"
#include "mozilla/dom/FlyWebPublishedServerIPC.h"
#include "mozilla/dom/GetFilesHelper.h"
#include "mozilla/dom/MemoryReportRequest.h"
#include "mozilla/dom/PCrashReporterChild.h"
#include "mozilla/dom/ProcessGlobal.h"
#include "mozilla/dom/PushNotifier.h"
@ -134,7 +135,6 @@
#include "nsFrameMessageManager.h"
#include "nsIGeolocationProvider.h"
#include "mozilla/dom/PMemoryReportRequestChild.h"
#include "mozilla/dom/PCycleCollectWithLogsChild.h"
#include "nsIScriptSecurityManager.h"
@ -225,38 +225,6 @@ using namespace mozilla::widget;
namespace mozilla {
namespace dom {
class MemoryReportRequestChild : public PMemoryReportRequestChild,
public nsIRunnable
{
public:
NS_DECL_ISUPPORTS
MemoryReportRequestChild(bool aAnonymize,
const MaybeFileDesc& aDMDFile);
NS_IMETHOD Run() override;
private:
~MemoryReportRequestChild() override;
bool mAnonymize;
FileDescriptor mDMDFile;
};
NS_IMPL_ISUPPORTS(MemoryReportRequestChild, nsIRunnable)
MemoryReportRequestChild::MemoryReportRequestChild(
bool aAnonymize, const MaybeFileDesc& aDMDFile)
: mAnonymize(aAnonymize)
{
if (aDMDFile.type() == MaybeFileDesc::TFileDescriptor) {
mDMDFile = aDMDFile.get_FileDescriptor();
}
}
MemoryReportRequestChild::~MemoryReportRequestChild()
{
}
// IPC sender for remote GC/CC logging.
class CycleCollectWithLogsChild final
: public PCycleCollectWithLogsChild
@ -1049,135 +1017,19 @@ ContentChild::InitXPCOM()
mozilla::dom::time::InitializeDateCacheCleaner();
}
PMemoryReportRequestChild*
ContentChild::AllocPMemoryReportRequestChild(const uint32_t& aGeneration,
const bool &aAnonymize,
const bool &aMinimizeMemoryUsage,
const MaybeFileDesc& aDMDFile)
{
auto *actor =
new MemoryReportRequestChild(aAnonymize, aDMDFile);
actor->AddRef();
return actor;
}
class HandleReportCallback final : public nsIHandleReportCallback
{
public:
NS_DECL_ISUPPORTS
explicit HandleReportCallback(MemoryReportRequestChild* aActor,
const nsACString& aProcess)
: mActor(aActor)
, mProcess(aProcess)
{ }
NS_IMETHOD Callback(const nsACString& aProcess, const nsACString &aPath,
int32_t aKind, int32_t aUnits, int64_t aAmount,
const nsACString& aDescription,
nsISupports* aUnused) override
{
MemoryReport memreport(mProcess, nsCString(aPath), aKind, aUnits,
aAmount, nsCString(aDescription));
mActor->SendReport(memreport);
return NS_OK;
}
private:
~HandleReportCallback() = default;
RefPtr<MemoryReportRequestChild> mActor;
const nsCString mProcess;
};
NS_IMPL_ISUPPORTS(
HandleReportCallback
, nsIHandleReportCallback
)
class FinishReportingCallback final : public nsIFinishReportingCallback
{
public:
NS_DECL_ISUPPORTS
explicit FinishReportingCallback(MemoryReportRequestChild* aActor)
: mActor(aActor)
{
}
NS_IMETHOD Callback(nsISupports* aUnused) override
{
bool sent = PMemoryReportRequestChild::Send__delete__(mActor);
return sent ? NS_OK : NS_ERROR_FAILURE;
}
private:
~FinishReportingCallback() = default;
RefPtr<MemoryReportRequestChild> mActor;
};
NS_IMPL_ISUPPORTS(
FinishReportingCallback
, nsIFinishReportingCallback
)
mozilla::ipc::IPCResult
ContentChild::RecvPMemoryReportRequestConstructor(
PMemoryReportRequestChild* aChild,
const uint32_t& aGeneration,
const bool& aAnonymize,
const bool& aMinimizeMemoryUsage,
const MaybeFileDesc& aDMDFile)
ContentChild::RecvRequestMemoryReport(const uint32_t& aGeneration,
const bool& aAnonymize,
const bool& aMinimizeMemoryUsage,
const MaybeFileDesc& aDMDFile)
{
MemoryReportRequestChild *actor =
static_cast<MemoryReportRequestChild*>(aChild);
DebugOnly<nsresult> rv;
if (aMinimizeMemoryUsage) {
nsCOMPtr<nsIMemoryReporterManager> mgr =
do_GetService("@mozilla.org/memory-reporter-manager;1");
rv = mgr->MinimizeMemoryUsage(actor);
// mgr will eventually call actor->Run()
} else {
rv = actor->Run();
}
// Bug 1295622: don't kill the process just because this failed.
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "actor operation failed");
return IPC_OK();
}
NS_IMETHODIMP MemoryReportRequestChild::Run()
{
ContentChild *child = static_cast<ContentChild*>(Manager());
nsCOMPtr<nsIMemoryReporterManager> mgr =
do_GetService("@mozilla.org/memory-reporter-manager;1");
nsCString process;
child->GetProcessName(process);
child->AppendProcessId(process);
GetProcessName(process);
AppendProcessId(process);
// Run the reporters. The callback will turn each measurement into a
// MemoryReport.
RefPtr<HandleReportCallback> handleReport =
new HandleReportCallback(this, process);
RefPtr<FinishReportingCallback> finishReporting =
new FinishReportingCallback(this);
nsresult rv =
mgr->GetReportsForThisProcessExtended(handleReport, nullptr, mAnonymize,
FileDescriptorToFILE(mDMDFile, "wb"),
finishReporting, nullptr);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
"GetReportsForThisProcessExtended failed");
return rv;
}
bool
ContentChild::DeallocPMemoryReportRequestChild(PMemoryReportRequestChild* actor)
{
static_cast<MemoryReportRequestChild*>(actor)->Release();
return true;
MemoryReportRequestClient::Start(
aGeneration, aAnonymize, aMinimizeMemoryUsage, aDMDFile, process);
return IPC_OK();
}
PCycleCollectWithLogsChild*

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

@ -222,22 +222,6 @@ public:
virtual bool
DeallocPHeapSnapshotTempFileHelperChild(PHeapSnapshotTempFileHelperChild*) override;
virtual PMemoryReportRequestChild*
AllocPMemoryReportRequestChild(const uint32_t& aGeneration,
const bool& aAnonymize,
const bool& aMinimizeMemoryUsage,
const MaybeFileDesc& aDMDFile) override;
virtual bool
DeallocPMemoryReportRequestChild(PMemoryReportRequestChild* actor) override;
virtual mozilla::ipc::IPCResult
RecvPMemoryReportRequestConstructor(PMemoryReportRequestChild* aChild,
const uint32_t& aGeneration,
const bool& aAnonymize,
const bool &aMinimizeMemoryUsage,
const MaybeFileDesc &aDMDFile) override;
virtual PCycleCollectWithLogsChild*
AllocPCycleCollectWithLogsChild(const bool& aDumpAllTraces,
const FileDescriptor& aGCLog,
@ -604,6 +588,13 @@ public:
virtual mozilla::ipc::IPCResult
RecvBlobURLUnregistration(const nsCString& aURI) override;
mozilla::ipc::IPCResult
RecvRequestMemoryReport(
const uint32_t& generation,
const bool& anonymize,
const bool& minimizeMemoryUsage,
const MaybeFileDesc& DMDFile) override;
#if defined(XP_WIN) && defined(ACCESSIBILITY)
bool
SendGetA11yContentId();

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

@ -46,11 +46,11 @@
#include "mozilla/dom/ExternalHelperAppParent.h"
#include "mozilla/dom/GetFilesHelper.h"
#include "mozilla/dom/GeolocationBinding.h"
#include "mozilla/dom/MemoryReportRequest.h"
#include "mozilla/dom/Notification.h"
#include "mozilla/dom/PContentBridgeParent.h"
#include "mozilla/dom/PContentPermissionRequestParent.h"
#include "mozilla/dom/PCycleCollectWithLogsParent.h"
#include "mozilla/dom/PMemoryReportRequestParent.h"
#include "mozilla/dom/ServiceWorkerRegistrar.h"
#include "mozilla/dom/StorageIPC.h"
#include "mozilla/dom/devicestorage/DeviceStorageRequestParent.h"
@ -296,71 +296,6 @@ namespace dom {
#define NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC "ipc:network:set-offline"
#define NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC "ipc:network:set-connectivity"
class MemoryReportRequestParent : public PMemoryReportRequestParent
{
public:
explicit MemoryReportRequestParent(uint32_t aGeneration);
virtual ~MemoryReportRequestParent();
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
virtual mozilla::ipc::IPCResult RecvReport(const MemoryReport& aReport) override;
virtual mozilla::ipc::IPCResult Recv__delete__() override;
private:
const uint32_t mGeneration;
// Non-null if we haven't yet called EndProcessReport() on it.
RefPtr<nsMemoryReporterManager> mReporterManager;
ContentParent* Owner()
{
return static_cast<ContentParent*>(Manager());
}
};
MemoryReportRequestParent::MemoryReportRequestParent(uint32_t aGeneration)
: mGeneration(aGeneration)
{
MOZ_COUNT_CTOR(MemoryReportRequestParent);
mReporterManager = nsMemoryReporterManager::GetOrCreate();
NS_WARNING_ASSERTION(mReporterManager, "GetOrCreate failed");
}
mozilla::ipc::IPCResult
MemoryReportRequestParent::RecvReport(const MemoryReport& aReport)
{
if (mReporterManager) {
mReporterManager->HandleChildReport(mGeneration, aReport);
}
return IPC_OK();
}
mozilla::ipc::IPCResult
MemoryReportRequestParent::Recv__delete__()
{
// Notifying the reporter manager is done in ActorDestroy, because
// it needs to happen even if the child process exits mid-report.
// (The reporter manager will time out eventually, but let's avoid
// that if possible.)
return IPC_OK();
}
void
MemoryReportRequestParent::ActorDestroy(ActorDestroyReason aWhy)
{
if (mReporterManager) {
mReporterManager->EndProcessReport(mGeneration, aWhy == Deletion);
mReporterManager = nullptr;
}
}
MemoryReportRequestParent::~MemoryReportRequestParent()
{
MOZ_ASSERT(!mReporterManager);
MOZ_COUNT_DTOR(MemoryReportRequestParent);
}
// IPC receiver for remote GC/CC logging.
class CycleCollectWithLogsParent final : public PCycleCollectWithLogsParent
{
@ -2835,22 +2770,39 @@ ContentParent::DeallocPHeapSnapshotTempFileHelperParent(
return true;
}
PMemoryReportRequestParent*
ContentParent::AllocPMemoryReportRequestParent(const uint32_t& aGeneration,
const bool &aAnonymize,
const bool &aMinimizeMemoryUsage,
const MaybeFileDesc &aDMDFile)
bool
ContentParent::SendRequestMemoryReport(const uint32_t& aGeneration,
const bool& aAnonymize,
const bool& aMinimizeMemoryUsage,
const MaybeFileDesc& aDMDFile)
{
MemoryReportRequestParent* parent =
new MemoryReportRequestParent(aGeneration);
return parent;
// This automatically cancels the previous request.
mMemoryReportRequest = MakeUnique<MemoryReportRequestHost>(aGeneration);
Unused << PContentParent::SendRequestMemoryReport(
aGeneration,
aAnonymize,
aMinimizeMemoryUsage,
aDMDFile);
return IPC_OK();
}
bool
ContentParent::DeallocPMemoryReportRequestParent(PMemoryReportRequestParent* actor)
mozilla::ipc::IPCResult
ContentParent::RecvAddMemoryReport(const MemoryReport& aReport)
{
delete actor;
return true;
if (mMemoryReportRequest) {
mMemoryReportRequest->RecvReport(aReport);
}
return IPC_OK();
}
mozilla::ipc::IPCResult
ContentParent::RecvFinishMemoryReport(const uint32_t& aGeneration)
{
if (mMemoryReportRequest) {
mMemoryReportRequest->Finish(aGeneration);
mMemoryReportRequest = nullptr;
}
return IPC_OK();
}
PCycleCollectWithLogsParent*

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

@ -16,6 +16,7 @@
#include "mozilla/FileUtils.h"
#include "mozilla/HalTypes.h"
#include "mozilla/LinkedList.h"
#include "mozilla/MemoryReportingProcess.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/UniquePtr.h"
@ -95,6 +96,7 @@ class MemoryReport;
class TabContext;
class ContentBridgeParent;
class GetFilesHelper;
class MemoryReportRequestHost;
class ContentParent final : public PContentParent
, public nsIContentParent
@ -104,6 +106,7 @@ class ContentParent final : public PContentParent
, public gfx::gfxVarReceiver
, public mozilla::LinkedListElement<ContentParent>
, public gfx::GPUProcessListener
, public mozilla::MemoryReportingProcess
{
typedef mozilla::ipc::GeckoChildProcessHost GeckoChildProcessHost;
typedef mozilla::ipc::OptionalURIParams OptionalURIParams;
@ -322,7 +325,7 @@ public:
bool RequestRunToCompletion();
bool IsAlive() const;
bool IsAlive() const override;
virtual bool IsForBrowser() const override
{
@ -728,6 +731,10 @@ private:
OptionalURIParams* aUserContentSheetURL,
nsTArray<LookAndFeelInt>* aLookAndFeelIntCache) override;
mozilla::ipc::IPCResult RecvAddMemoryReport(const MemoryReport& aReport) override;
mozilla::ipc::IPCResult RecvFinishMemoryReport(const uint32_t& aGeneration) override;
virtual bool
DeallocPJavaScriptParent(mozilla::jsipc::PJavaScriptParent*) override;
@ -787,15 +794,6 @@ private:
virtual bool
DeallocPHeapSnapshotTempFileHelperParent(PHeapSnapshotTempFileHelperParent*) override;
virtual PMemoryReportRequestParent*
AllocPMemoryReportRequestParent(const uint32_t& aGeneration,
const bool &aAnonymize,
const bool &aMinimizeMemoryUsage,
const MaybeFileDesc &aDMDFile) override;
virtual bool
DeallocPMemoryReportRequestParent(PMemoryReportRequestParent* actor) override;
virtual PCycleCollectWithLogsParent*
AllocPCycleCollectWithLogsParent(const bool& aDumpAllTraces,
const FileDescriptor& aGCLog,
@ -1087,6 +1085,11 @@ public:
void SendGetFilesResponseAndForget(const nsID& aID,
const GetFilesResponseResult& aResult);
bool SendRequestMemoryReport(const uint32_t& aGeneration,
const bool& aAnonymize,
const bool& aMinimizeMemoryUsage,
const MaybeFileDesc& aDMDFile) override;
private:
// If you add strong pointers to cycle collected objects here, be sure to
@ -1151,6 +1154,7 @@ private:
nsCString mProfile;
UniquePtr<gfx::DriverCrashGuard> mDriverCrashGuard;
UniquePtr<MemoryReportRequestHost> mMemoryReportRequest;
#if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX)
mozilla::UniquePtr<SandboxBroker> mSandboxBroker;

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

@ -0,0 +1,205 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 "MemoryReportRequest.h"
#include "mozilla/Unused.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/gfx/GPUParent.h"
namespace mozilla {
namespace dom {
MemoryReportRequestHost::MemoryReportRequestHost(uint32_t aGeneration)
: mGeneration(aGeneration),
mSuccess(false)
{
MOZ_COUNT_CTOR(MemoryReportRequestHost);
mReporterManager = nsMemoryReporterManager::GetOrCreate();
NS_WARNING_ASSERTION(mReporterManager, "GetOrCreate failed");
}
void
MemoryReportRequestHost::RecvReport(const MemoryReport& aReport)
{
// Skip reports from older generations. We need to do this here since we
// could receive older reports from a subprocesses before it acknowledges
// a new request, and we only track one active request per process.
if (aReport.generation() != mGeneration) {
return;
}
if (mReporterManager) {
mReporterManager->HandleChildReport(mGeneration, aReport);
}
}
void
MemoryReportRequestHost::Finish(uint32_t aGeneration)
{
// Skip reports from older generations. See the comment in RecvReport.
if (mGeneration != aGeneration) {
return;
}
mSuccess = true;
}
MemoryReportRequestHost::~MemoryReportRequestHost()
{
MOZ_COUNT_DTOR(MemoryReportRequestHost);
if (mReporterManager) {
mReporterManager->EndProcessReport(mGeneration, mSuccess);
mReporterManager = nullptr;
}
}
NS_IMPL_ISUPPORTS(MemoryReportRequestClient, nsIRunnable)
/* static */ void
MemoryReportRequestClient::Start(uint32_t aGeneration,
bool aAnonymize,
bool aMinimizeMemoryUsage,
const MaybeFileDesc& aDMDFile,
const nsACString& aProcessString)
{
RefPtr<MemoryReportRequestClient> request = new MemoryReportRequestClient(
aGeneration,
aAnonymize,
aDMDFile,
aProcessString);
DebugOnly<nsresult> rv;
if (aMinimizeMemoryUsage) {
nsCOMPtr<nsIMemoryReporterManager> mgr =
do_GetService("@mozilla.org/memory-reporter-manager;1");
rv = mgr->MinimizeMemoryUsage(request);
// mgr will eventually call actor->Run()
} else {
rv = request->Run();
}
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "actor operation failed");
}
MemoryReportRequestClient::MemoryReportRequestClient(uint32_t aGeneration,
bool aAnonymize,
const MaybeFileDesc& aDMDFile,
const nsACString& aProcessString)
: mGeneration(aGeneration),
mAnonymize(aAnonymize),
mProcessString(aProcessString)
{
if (aDMDFile.type() == MaybeFileDesc::TFileDescriptor) {
mDMDFile = aDMDFile.get_FileDescriptor();
}
}
MemoryReportRequestClient::~MemoryReportRequestClient()
{
}
class HandleReportCallback final : public nsIHandleReportCallback
{
public:
NS_DECL_ISUPPORTS
explicit HandleReportCallback(uint32_t aGeneration,
const nsACString& aProcess)
: mGeneration(aGeneration)
, mProcess(aProcess)
{ }
NS_IMETHOD Callback(const nsACString& aProcess, const nsACString &aPath,
int32_t aKind, int32_t aUnits, int64_t aAmount,
const nsACString& aDescription,
nsISupports* aUnused) override
{
MemoryReport memreport(mProcess, nsCString(aPath), aKind, aUnits,
aAmount, mGeneration, nsCString(aDescription));
switch (XRE_GetProcessType()) {
case GeckoProcessType_Content:
ContentChild::GetSingleton()->SendAddMemoryReport(memreport);
break;
case GeckoProcessType_GPU:
Unused << gfx::GPUParent::GetSingleton()->SendAddMemoryReport(memreport);
break;
default:
MOZ_ASSERT_UNREACHABLE("Unhandled process type");
}
return NS_OK;
}
private:
~HandleReportCallback() = default;
uint32_t mGeneration;
const nsCString mProcess;
};
NS_IMPL_ISUPPORTS(
HandleReportCallback
, nsIHandleReportCallback
)
class FinishReportingCallback final : public nsIFinishReportingCallback
{
public:
NS_DECL_ISUPPORTS
explicit FinishReportingCallback(uint32_t aGeneration)
: mGeneration(aGeneration)
{
}
NS_IMETHOD Callback(nsISupports* aUnused) override
{
bool sent = false;
switch (XRE_GetProcessType()) {
case GeckoProcessType_Content:
sent = ContentChild::GetSingleton()->SendFinishMemoryReport(mGeneration);
break;
case GeckoProcessType_GPU:
sent = gfx::GPUParent::GetSingleton()->SendFinishMemoryReport(mGeneration);
break;
default:
MOZ_ASSERT_UNREACHABLE("Unhandled process type");
}
return sent ? NS_OK : NS_ERROR_FAILURE;
}
private:
~FinishReportingCallback() = default;
uint32_t mGeneration;
};
NS_IMPL_ISUPPORTS(
FinishReportingCallback
, nsIFinishReportingCallback
)
NS_IMETHODIMP MemoryReportRequestClient::Run()
{
nsCOMPtr<nsIMemoryReporterManager> mgr =
do_GetService("@mozilla.org/memory-reporter-manager;1");
// Run the reporters. The callback will turn each measurement into a
// MemoryReport.
RefPtr<HandleReportCallback> handleReport =
new HandleReportCallback(mGeneration, mProcessString);
RefPtr<FinishReportingCallback> finishReporting =
new FinishReportingCallback(mGeneration);
nsresult rv =
mgr->GetReportsForThisProcessExtended(handleReport, nullptr, mAnonymize,
FileDescriptorToFILE(mDMDFile, "wb"),
finishReporting, nullptr);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
"GetReportsForThisProcessExtended failed");
return rv;
}
} // namespace dom
} // namespace mozilla

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

@ -0,0 +1,68 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 mozilla_dom_MemoryReportRequest_h_
#define mozilla_dom_MemoryReportRequest_h_
#include "mozilla/dom/MemoryReportTypes.h"
#include "mozilla/ipc/FileDescriptor.h"
#include "nsISupports.h"
class nsMemoryReporterManager;
namespace mozilla {
namespace dom {
class MaybeFileDesc;
class MemoryReportRequestHost final
{
public:
explicit MemoryReportRequestHost(uint32_t aGeneration);
~MemoryReportRequestHost();
void RecvReport(const MemoryReport& aReport);
void Finish(uint32_t aGeneration);
private:
const uint32_t mGeneration;
// Non-null if we haven't yet called EndProcessReport() on it.
RefPtr<nsMemoryReporterManager> mReporterManager;
bool mSuccess;
};
class MemoryReportRequestClient final : public nsIRunnable
{
public:
NS_DECL_ISUPPORTS
static void Start(uint32_t aGeneration,
bool aAnonymize,
bool aMinimizeMemoryUsage,
const MaybeFileDesc& aDMDFile,
const nsACString& aProcessString);
NS_IMETHOD Run() override;
private:
MemoryReportRequestClient(uint32_t aGeneration,
bool aAnonymize,
const MaybeFileDesc& aDMDFile,
const nsACString& aProcessString);
private:
~MemoryReportRequestClient();
uint32_t mGeneration;
bool mAnonymize;
mozilla::ipc::FileDescriptor mDMDFile;
nsCString mProcessString;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_MemoryReportRequest_h_

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

@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PContent;
using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
namespace mozilla {
namespace dom {
@ -14,15 +14,13 @@ struct MemoryReport {
int32_t kind;
int32_t units;
int64_t amount;
uint32_t generation;
nsCString desc;
};
protocol PMemoryReportRequest {
manager PContent;
parent:
async Report(MemoryReport aReport);
async __delete__();
union MaybeFileDesc {
FileDescriptor;
void_t;
};
}

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

@ -22,7 +22,6 @@ include protocol PHeapSnapshotTempFileHelper;
include protocol PProcessHangMonitor;
include protocol PImageBridge;
include protocol PMedia;
include protocol PMemoryReportRequest;
include protocol PNecko;
include protocol PGMPContent;
include protocol PGMPService;
@ -57,6 +56,7 @@ include PContentPermission;
include ServiceWorkerConfiguration;
include GraphicsMessages;
include ProfilerTypes;
include MemoryReportTypes;
// Workaround to prevent error if PContentChild.cpp & PContentBridgeParent.cpp
// are put into different UnifiedProtocolsXX.cpp files.
@ -74,7 +74,6 @@ using base::ProcessId from "base/process.h";
using struct IPC::Permission from "mozilla/net/NeckoMessageUtils.h";
using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h";
using struct mozilla::null_t from "ipc/IPCMessageUtils.h";
using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h";
using mozilla::hal::ProcessPriority from "mozilla/HalTypes.h";
using mozilla::gfx::IntSize from "mozilla/gfx/2D.h";
@ -267,11 +266,6 @@ struct ClipboardCapabilities {
bool supportsFindClipboard;
};
union MaybeFileDesc {
FileDescriptor;
void_t;
};
union FileDescOrError {
FileDescriptor;
nsresult;
@ -371,7 +365,6 @@ nested(upto inside_cpow) sync protocol PContent
manages PHandlerService;
manages PHeapSnapshotTempFileHelper;
manages PMedia;
manages PMemoryReportRequest;
manages PNecko;
manages POfflineCacheUpdate;
manages PPrinting;
@ -448,8 +441,10 @@ child:
*/
async SetProcessSandbox(MaybeFileDesc aBroker);
async PMemoryReportRequest(uint32_t generation, bool anonymize,
bool minimizeMemoryUsage, MaybeFileDesc DMDFile);
async RequestMemoryReport(uint32_t generation,
bool anonymize,
bool minimizeMemoryUsage,
MaybeFileDesc DMDFile);
/**
* Communication between the PuppetBidiKeyboard and the actual
@ -1164,6 +1159,9 @@ parent:
sync GetA11yContentId() returns (uint32_t aContentId);
async AddMemoryReport(MemoryReport aReport);
async FinishMemoryReport(uint32_t aGeneration);
both:
async AsyncMessage(nsString aMessage, CpowEntry[] aCpows,
Principal aPrincipal, ClonedMessageData aData);

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

@ -2732,11 +2732,7 @@ TabChild::MakeHidden()
return;
}
CompositorBridgeChild* compositor = CompositorBridgeChild::Get();
// Clear cached resources directly. This avoids one extra IPC
// round-trip from CompositorBridgeChild to CompositorBridgeParent.
compositor->RecvClearCachedResources(mLayersId);
ClearCachedResources();
// Hide all plugins in this tab.
if (nsCOMPtr<nsIPresShell> shell = GetPresShell()) {

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

@ -26,6 +26,7 @@ EXPORTS.mozilla.dom += [
'CrashReporterChild.h',
'CrashReporterParent.h',
'FilePickerParent.h',
'MemoryReportRequest.h',
'nsIContentChild.h',
'nsIContentParent.h',
'PermissionMessageUtils.h',
@ -53,6 +54,7 @@ UNIFIED_SOURCES += [
'CrashReporterParent.cpp',
'DatePickerParent.cpp',
'FilePickerParent.cpp',
'MemoryReportRequest.cpp',
'nsIContentChild.cpp',
'nsIContentParent.cpp',
'PermissionMessageUtils.cpp',
@ -78,6 +80,7 @@ SOURCES += [
IPDL_SOURCES += [
'DOMTypes.ipdlh',
'MemoryReportTypes.ipdlh',
'PBrowser.ipdl',
'PBrowserOrId.ipdlh',
'PColorPicker.ipdl',
@ -90,7 +93,6 @@ IPDL_SOURCES += [
'PDatePicker.ipdl',
'PDocumentRenderer.ipdl',
'PFilePicker.ipdl',
'PMemoryReportRequest.ipdl',
'PPluginWidget.ipdl',
'PProcessHangMonitor.ipdl',
'PScreenManager.ipdl',

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

@ -1083,7 +1083,7 @@ public:
DOMMediaStream::CreateAudioCaptureStreamAsInput(window, principal, msg);
stream = msg->CreateSourceStream(
globalWindow->AbstractMainThreadFor(dom::TaskCategory::Other)); // Placeholder
globalWindow->AbstractMainThreadFor(TaskCategory::Other)); // Placeholder
msg->RegisterCaptureStreamForWindow(
mWindowID, domStream->GetInputStream()->AsProcessedStream());
window->SetAudioCapture(true);

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

@ -638,14 +638,14 @@ MediaKeySession::MakePromise(ErrorResult& aRv, const nsACString& aName)
}
void
MediaKeySession::SetExpiration(double aSecondsSinceEpoch)
MediaKeySession::SetExpiration(double aExpiration)
{
EME_LOG("MediaKeySession[%p,'%s'] SetExpiry(%.12lf) (%.2lf hours from now)",
this,
NS_ConvertUTF16toUTF8(mSessionId).get(),
aSecondsSinceEpoch,
aSecondsSinceEpoch - double(time(0)) / (60 * 60));
mExpiration = aSecondsSinceEpoch;
aExpiration,
(aExpiration - 1000.0 * double(time(0))) / (1000.0 * 60 * 60));
mExpiration = aExpiration;
}
EventHandlerNonNull*

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

@ -252,7 +252,7 @@ MP4Decoder::IsVideoAccelerated(layers::KnowsCompositor* aKnowsCompositor, nsIGlo
}
decoder->Init()
->Then(aParent->AbstractMainThreadFor(dom::TaskCategory::Other),
->Then(aParent->AbstractMainThreadFor(TaskCategory::Other),
__func__,
[promise, decoder, taskQueue] (TrackInfo::TrackType aTrack) {
nsCString failureReason;

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

@ -125,11 +125,10 @@ GMPDecryptorChild::SessionMessage(const char* aSessionId,
void
GMPDecryptorChild::ExpirationChange(const char* aSessionId,
uint32_t aSessionIdLength,
GMPTimestamp aMillisecondsSinceEpoch)
GMPTimestamp aExpiryTime)
{
CALL_ON_GMP_THREAD(SendExpirationChange,
nsCString(aSessionId, aSessionIdLength),
aMillisecondsSinceEpoch / 1e3);
nsCString(aSessionId, aSessionIdLength), aExpiryTime);
}
void

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

@ -307,16 +307,16 @@ GMPDecryptorParent::RecvSessionMessage(const nsCString& aSessionId,
mozilla::ipc::IPCResult
GMPDecryptorParent::RecvExpirationChange(const nsCString& aSessionId,
const double& aSecondsSinceEpoch)
const double& aExpiryTime)
{
LOGD(("GMPDecryptorParent[%p]::RecvExpirationChange(sessionId='%s', expiry=%lf)",
this, aSessionId.get(), aSecondsSinceEpoch));
this, aSessionId.get(), aExpiryTime));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return IPC_FAIL_NO_REASON(this);
}
mCallback->ExpirationChange(aSessionId, aSecondsSinceEpoch);
mCallback->ExpirationChange(aSessionId, aExpiryTime);
return IPC_OK();
}

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

@ -71,7 +71,7 @@ parent:
GMPSessionMessageType aMessageType,
uint8_t[] aMessage);
async ExpirationChange(nsCString aSessionId, double aSecondsSinceEpoch);
async ExpirationChange(nsCString aSessionId, double aExpiryTime);
async SessionClosed(nsCString aSessionId);

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

@ -2753,7 +2753,7 @@ PluginModuleParent::NPP_NewInternal(NPMIMEType pluginType, NPP instance,
if (nsCOMPtr<nsINode> node = do_QueryInterface(elt)) {
nsCOMPtr<nsIDocument> doc = node->OwnerDoc();
if (doc) {
nsCOMPtr<nsIEventTarget> eventTarget = doc->EventTargetFor(dom::TaskCategory::Other);
nsCOMPtr<nsIEventTarget> eventTarget = doc->EventTargetFor(TaskCategory::Other);
SetEventTargetForActor(parentInstance, eventTarget);
}
}

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

@ -34,8 +34,9 @@
function doTest() {
is(p.getClipRegionRectCount(), 1, "getClipRegionRectCount should be a single rect");
is(p.getClipRegionRectEdge(0,2) - p.getClipRegionRectEdge(0,0), 100, "width of clip region rect");
is(p.getClipRegionRectEdge(0,3) - p.getClipRegionRectEdge(0,1), 26, "height of clip region rect");
var dpr = window.devicePixelRatio;
is(p.getClipRegionRectEdge(0,2) - p.getClipRegionRectEdge(0,0), 100 * dpr, "width of clip region rect");
is(p.getClipRegionRectEdge(0,3) - p.getClipRegionRectEdge(0,1), 26 * dpr, "height of clip region rect");
}
</script>

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

@ -40,10 +40,11 @@ function runTests() {
function verify(test,x,y,next) {
var p = $("plugin1").getLastMouseX();
const delta = 2;
ok(p-delta <= x && x <= p+delta, "test"+test+" LastMouseX got " + p + " expected " + x +
var dpr = window.devicePixelRatio / SpecialPowers.getFullZoom(window);
ok(p-delta <= x * dpr && x * dpr <= p+delta, "test"+test+" LastMouseX got " + p + " expected " + x +
" with fullZoom="+SpecialPowers.getFullZoom(window)+" MozTransform='"+$("container").style.MozTransform+"'");
p = $("plugin1").getLastMouseY();
ok(p-delta <= y && y <= p+delta, "test"+test+" LastMouseY got " + p + " expected " + y +
ok(p-delta <= y * dpr && y * dpr <= p+delta, "test"+test+" LastMouseY got " + p + " expected " + y +
" with fullZoom="+SpecialPowers.getFullZoom(window)+" MozTransform='"+$("container").style.MozTransform+"'");
if (next) next();
}

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

@ -40,10 +40,11 @@ function runTests() {
function verify(test,x,y,next) {
var p = $("plugin1").getLastMouseX();
const delta = 2;
ok(p-delta <= x && x <= p+delta, "test"+test+" LastMouseX got " + p + " expected " + x +
var dpr = window.devicePixelRatio / SpecialPowers.getFullZoom(window);
ok(p-delta <= x * dpr && x * dpr <= p+delta, "test"+test+" LastMouseX got " + p + " expected " + x +
" with fullZoom="+SpecialPowers.getFullZoom(window)+" MozTransform='"+$("container").style.MozTransform+"'");
p = $("plugin1").getLastMouseY();
ok(p-delta <= y && y <= p+delta, "test"+test+" LastMouseY got " + p + " expected " + y +
ok(p-delta <= y * dpr && y * dpr <= p+delta, "test"+test+" LastMouseY got " + p + " expected " + y +
" with fullZoom="+SpecialPowers.getFullZoom(window)+" MozTransform='"+$("container").style.MozTransform+"'");
if (next) next();
}

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

@ -34,11 +34,12 @@
function doTest() {
is(p.getClipRegionRectCount(), 1, "getClipRegionRectCount should be a single rect");
is(p.getClipRegionRectEdge(0,2) - p.getClipRegionRectEdge(0,0), 100, "width of clip region rect");
is(p.getClipRegionRectEdge(0,3) - p.getClipRegionRectEdge(0,1), 50, "height of clip region rect");
var dpr = window.devicePixelRatio;
is(p.getClipRegionRectEdge(0,2) - p.getClipRegionRectEdge(0,0), 100 * dpr, "width of clip region rect");
is(p.getClipRegionRectEdge(0,3) - p.getClipRegionRectEdge(0,1), 50 * dpr, "height of clip region rect");
}
</script>
<p id="display"></p>
<embed id="theplugin" type="application/x-test" width="100" height="50" style="opacity:0" wmode="window"></embed>
<embed id="theplugin" type="application/x-test" width="100" height="50" style="opacity:0" wmode="window"></embed>

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

@ -15,13 +15,11 @@ callback EventHandlerNonNull = any (Event event);
typedef EventHandlerNonNull? EventHandler;
[TreatNonObjectAsNull]
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=23489
//callback OnBeforeUnloadEventHandlerNonNull = DOMString (Event event);
callback OnBeforeUnloadEventHandlerNonNull = DOMString? (Event event);
typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnloadEventHandler;
[TreatNonObjectAsNull]
callback OnErrorEventHandlerNonNull = boolean ((Event or DOMString) event, optional DOMString source, optional unsigned long lineno, optional unsigned long column, optional any error);
callback OnErrorEventHandlerNonNull = any ((Event or DOMString) event, optional DOMString source, optional unsigned long lineno, optional unsigned long column, optional any error);
typedef OnErrorEventHandlerNonNull? OnErrorEventHandler;
[NoInterfaceObject]

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

@ -800,6 +800,7 @@ txMozillaXMLOutput::createResultDocument(const nsSubstring& aName, int32_t aNsID
MOZ_ASSERT(mDocument->GetReadyStateEnum() ==
nsIDocument::READYSTATE_UNINITIALIZED, "Bad readyState");
mDocument->SetReadyStateInternal(nsIDocument::READYSTATE_LOADING);
mDocument->SetMayStartLayout(false);
nsCOMPtr<nsIDocument> source = do_QueryInterface(aSourceDocument);
NS_ENSURE_STATE(source);
bool hasHadScriptObject = false;

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

@ -7,6 +7,7 @@
#define mozilla_EditorBase_h
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc.
#include "mozilla/FlushType.h" // for FlushType enum
#include "mozilla/OwningNonNull.h" // for OwningNonNull
#include "mozilla/SelectionState.h" // for RangeUpdater, etc.
#include "mozilla/StyleSheet.h" // for StyleSheet
@ -952,6 +953,14 @@ public:
*/
void HideCaret(bool aHide);
void FlushFrames()
{
nsCOMPtr<nsIDocument> doc = GetDocument();
if (doc) {
doc->FlushPendingNotifications(FlushType::Frames);
}
}
protected:
enum Tristate
{

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

@ -1661,6 +1661,9 @@ HTMLEditor::PasteAsCitedQuotation(const nsAString& aCitation,
rv = selection->Collapse(newNode, 0);
NS_ENSURE_SUCCESS(rv, rv);
// Ensure that the inserted <blockquote> has a frame to make it IsEditable.
FlushFrames();
return Paste(aSelectionType);
}
@ -1717,6 +1720,7 @@ HTMLEditor::PasteAsPlaintextQuotation(int32_t aSelectionType)
NS_IMETHODIMP
HTMLEditor::InsertTextWithQuotations(const nsAString& aStringToInsert)
{
AutoEditBatch beginBatching(this);
// The whole operation should be undoable in one transaction:
BeginTransaction();
@ -1880,6 +1884,9 @@ HTMLEditor::InsertAsPlaintextQuotation(const nsAString& aQuotedText,
selection->Collapse(newNode, 0);
}
// Ensure that the inserted <span> has a frame to make it IsEditable.
FlushFrames();
if (aAddCites) {
rv = TextEditor::InsertAsQuotation(aQuotedText, aNodeInserted);
} else {
@ -1963,6 +1970,9 @@ HTMLEditor::InsertAsCitedQuotation(const nsAString& aQuotedText,
// Set the selection inside the blockquote so aQuotedText will go there:
selection->Collapse(newNode, 0);
// Ensure that the inserted <blockquote> has a frame to make it IsEditable.
FlushFrames();
if (aInsertHTML) {
rv = LoadHTML(aQuotedText);
} else {

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

@ -160,6 +160,12 @@ skip-if = toolkit == 'android' # bug 1309431
[test_bug780035.html]
[test_bug787432.html]
[test_bug790475.html]
[test_bug795418.html]
[test_bug795418-2.html]
[test_bug795418-3.html]
[test_bug795418-4.html]
[test_bug795418-5.html]
[test_bug795418-6.html]
[test_bug795785.html]
[test_bug796839.html]
[test_bug830600.html]

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

@ -0,0 +1,88 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=795418
-->
<head>
<meta charset="utf-8">
<title>Test #2 for Bug 772796</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=772796">Mozilla Bug 795418</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<div id="copySource">Copy this</div>
<iframe src="data:application/xhtml+xml,<html contenteditable='' xmlns='http://www.w3.org/1999/xhtml'><span>AB</span></html>"></iframe>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 795418 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var div = document.getElementById("copySource");
var sel = window.getSelection();
sel.removeAllRanges();
// Select the text from the text node in div.
var r = document.createRange();
r.setStart(div.firstChild, 0);
r.setEnd(div.firstChild, 9);
sel.addRange(r);
function checkResult() {
var iframe = document.querySelector("iframe");
var iframeWindow = iframe.contentWindow;
var theEdit = iframe.contentDocument.firstChild;
theEdit.offsetHeight;
is(theEdit.innerHTML,
"<blockquote xmlns=\"http://www.w3.org/1999/xhtml\" type=\"cite\">Copy this</blockquote><span xmlns=\"http://www.w3.org/1999/xhtml\">AB</span>",
"unexpected HTML for test");
SimpleTest.finish();
}
function pasteQuote() {
var iframe = document.querySelector("iframe");
var iframeWindow = iframe.contentWindow;
var theEdit = iframe.contentDocument.firstChild;
theEdit.offsetHeight;
iframeWindow.focus();
SimpleTest.waitForFocus(function() {
var iframeSel = iframeWindow.getSelection();
iframeSel.removeAllRanges();
let span = iframe.contentDocument.querySelector('span');
iframeSel.collapse(span, 1);
SpecialPowers.doCommand(iframeWindow, "cmd_pasteQuote");
setTimeout(checkResult, 0);
}, iframeWindow);
}
SimpleTest.waitForClipboard(
function compare(value) {
return true;
},
function setup() {
synthesizeKey("C", {accelKey: true});
},
function onSuccess() {
setTimeout(pasteQuote, 0);
},
function onFailure() {
SimpleTest.finish();
},
"text/html"
);
});
</script>
</pre>
</body>
</html>

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

@ -0,0 +1,88 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=795418
-->
<head>
<meta charset="utf-8">
<title>Test #3 for Bug 772796</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=772796">Mozilla Bug 795418</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<div id="copySource">Copy this</div>
<iframe src="data:text/html,<html><body><span>AB</span>"></iframe>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 795418 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var div = document.getElementById("copySource");
var sel = window.getSelection();
sel.removeAllRanges();
// Select the text from the text node in div.
var r = document.createRange();
r.setStart(div.firstChild, 0);
r.setEnd(div.firstChild, 9);
sel.addRange(r);
function checkResult() {
var iframe = document.querySelector("iframe");
var iframeWindow = iframe.contentWindow;
var theEdit = iframe.contentDocument.body;
theEdit.offsetHeight;
is(theEdit.innerHTML,
"<span>AB<blockquote type=\"cite\">Copy this</blockquote></span>",
"unexpected HTML for test");
SimpleTest.finish();
}
function pasteQuote() {
var iframe = document.querySelector("iframe");
var iframeWindow = iframe.contentWindow;
var theEdit = iframe.contentDocument.body;
iframe.contentDocument.designMode='on';
iframe.contentDocument.body.offsetHeight;
iframeWindow.focus();
SimpleTest.waitForFocus(function() {
var iframeSel = iframeWindow.getSelection();
iframeSel.removeAllRanges();
iframeSel.collapse(theEdit.firstChild, 1);
SpecialPowers.doCommand(iframeWindow, "cmd_pasteQuote");
setTimeout(checkResult, 0);
}, iframeWindow);
}
SimpleTest.waitForClipboard(
function compare(value) {
return true;
},
function setup() {
synthesizeKey("C", {accelKey: true});
},
function onSuccess() {
setTimeout(pasteQuote, 0);
},
function onFailure() {
SimpleTest.finish();
},
"text/html"
);
});
</script>
</pre>
</body>
</html>

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

@ -0,0 +1,67 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=795418
-->
<head>
<meta charset="utf-8">
<title>Test #4 for Bug 795418</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=795418">Mozilla Bug 795418</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<div id="copySource">Copy this</div>
<div id="editable" contenteditable style="display:grid">AB</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 795418 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var div = document.getElementById("copySource");
var sel = window.getSelection();
sel.removeAllRanges();
// Select the text from the text node in div.
var r = document.createRange();
r.setStart(div.firstChild, 0);
r.setEnd(div.firstChild, 9);
sel.addRange(r);
SimpleTest.waitForClipboard(
function compare(value) {
var theEdit = document.getElementById("editable");
sel.collapse(theEdit.firstChild, 2);
SpecialPowers.doCommand(window, "cmd_paste");
is(theEdit.innerHTML,
"ABCopy this",
"unexpected HTML for test");
return true;
},
function setup() {
synthesizeKey("C", {accelKey: true});
},
function onSuccess() {
SimpleTest.finish();
},
function onFailure() {
SimpleTest.finish();
},
"text/html"
);
});
</script>
</pre>
</body>
</html>

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

@ -0,0 +1,67 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=795418
-->
<head>
<meta charset="utf-8">
<title>Test #5 for Bug 795418</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=795418">Mozilla Bug 795418</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<div id="copySource">Copy this</div>
<div id="editable" contenteditable style="display:ruby">AB</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 795418 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var div = document.getElementById("copySource");
var sel = window.getSelection();
sel.removeAllRanges();
// Select the text from the text node in div.
var r = document.createRange();
r.setStart(div.firstChild, 0);
r.setEnd(div.firstChild, 9);
sel.addRange(r);
SimpleTest.waitForClipboard(
function compare(value) {
var theEdit = document.getElementById("editable");
sel.collapse(theEdit.firstChild, 2);
SpecialPowers.doCommand(window, "cmd_paste");
is(theEdit.innerHTML,
"ABCopy this",
"unexpected HTML for test");
return true;
},
function setup() {
synthesizeKey("C", {accelKey: true});
},
function onSuccess() {
SimpleTest.finish();
},
function onFailure() {
SimpleTest.finish();
},
"text/html"
);
});
</script>
</pre>
</body>
</html>

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

@ -0,0 +1,67 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=795418
-->
<head>
<meta charset="utf-8">
<title>Test #5 for Bug 795418</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=795418">Mozilla Bug 795418</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<div id="copySource">Copy this</div>
<div id="editable" contenteditable style="display:table">AB</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 795418 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var div = document.getElementById("copySource");
var sel = window.getSelection();
sel.removeAllRanges();
// Select the text from the text node in div.
var r = document.createRange();
r.setStart(div.firstChild, 0);
r.setEnd(div.firstChild, 9);
sel.addRange(r);
SimpleTest.waitForClipboard(
function compare(value) {
var theEdit = document.getElementById("editable");
sel.collapse(theEdit.firstChild, 2);
SpecialPowers.doCommand(window, "cmd_pasteQuote");
is(theEdit.innerHTML,
"AB<blockquote type=\"cite\">Copy this</blockquote>",
"unexpected HTML for test");
return true;
},
function setup() {
synthesizeKey("C", {accelKey: true});
},
function onSuccess() {
SimpleTest.finish();
},
function onFailure() {
SimpleTest.finish();
},
"text/html"
);
});
</script>
</pre>
</body>
</html>

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

@ -0,0 +1,67 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=795418
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 795418</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=795418">Mozilla Bug 795418</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<div id="copySource">Copy this</div>
<div id="editable" contenteditable><span>AB</span></div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 795418 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var div = document.getElementById("copySource");
var sel = window.getSelection();
sel.removeAllRanges();
// Select the text from the text node in div.
var r = document.createRange();
r.setStart(div.firstChild, 0);
r.setEnd(div.firstChild, 9);
sel.addRange(r);
SimpleTest.waitForClipboard(
function compare(value) {
var theEdit = document.getElementById("editable");
sel.collapse(theEdit.firstChild, 1);
SpecialPowers.doCommand(window, "cmd_pasteQuote");
is(theEdit.innerHTML,
"<span>AB<blockquote type=\"cite\">Copy this</blockquote></span>",
"unexpected HTML for test");
return true;
},
function setup() {
synthesizeKey("C", {accelKey: true});
},
function onSuccess() {
SimpleTest.finish();
},
function onFailure() {
SimpleTest.finish();
},
"text/html"
);
});
</script>
</pre>
</body>
</html>

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

@ -11,6 +11,7 @@
#include "GPUProcessManager.h"
#include "mozilla/Telemetry.h"
#include "mozilla/dom/CheckerboardReportService.h"
#include "mozilla/dom/MemoryReportRequest.h"
#include "mozilla/gfx/gfxVars.h"
#if defined(XP_WIN)
# include "mozilla/gfx/DeviceManagerDx.h"
@ -174,6 +175,40 @@ GPUChild::RecvNotifyDeviceReset()
return IPC_OK();
}
bool
GPUChild::SendRequestMemoryReport(const uint32_t& aGeneration,
const bool& aAnonymize,
const bool& aMinimizeMemoryUsage,
const MaybeFileDesc& aDMDFile)
{
mMemoryReportRequest = MakeUnique<MemoryReportRequestHost>(aGeneration);
Unused << PGPUChild::SendRequestMemoryReport(
aGeneration,
aAnonymize,
aMinimizeMemoryUsage,
aDMDFile);
return true;
}
mozilla::ipc::IPCResult
GPUChild::RecvAddMemoryReport(const MemoryReport& aReport)
{
if (mMemoryReportRequest) {
mMemoryReportRequest->RecvReport(aReport);
}
return IPC_OK();
}
mozilla::ipc::IPCResult
GPUChild::RecvFinishMemoryReport(const uint32_t& aGeneration)
{
if (mMemoryReportRequest) {
mMemoryReportRequest->Finish(aGeneration);
mMemoryReportRequest = nullptr;
}
return IPC_OK();
}
void
GPUChild::ActorDestroy(ActorDestroyReason aWhy)
{
@ -184,8 +219,9 @@ GPUChild::ActorDestroy(ActorDestroyReason aWhy)
mCrashReporter = nullptr;
}
#endif
Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT,
nsDependentCString(XRE_ChildProcessTypeToString(GeckoProcessType_GPU), 1));
nsDependentCString(XRE_ChildProcessTypeToString(GeckoProcessType_GPU)), 1);
// Notify the Telemetry environment so that we can refresh and do a subsession split
if (nsCOMPtr<nsIObserverService> obsvc = services::GetObserverService()) {

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

@ -14,7 +14,10 @@
namespace mozilla {
namespace ipc {
class CrashReporterHost;
} // namespace
} // namespace ipc
namespace dom {
class MemoryReportRequestHost;
} // namespace dom
namespace gfx {
class GPUProcessHost;
@ -23,6 +26,8 @@ class GPUChild final
: public PGPUChild,
public gfxVarReceiver
{
typedef mozilla::dom::MemoryReportRequestHost MemoryReportRequestHost;
public:
explicit GPUChild(GPUProcessHost* aHost);
~GPUChild();
@ -46,12 +51,20 @@ public:
mozilla::ipc::IPCResult RecvGraphicsError(const nsCString& aError) override;
mozilla::ipc::IPCResult RecvNotifyUiObservers(const nsCString& aTopic) override;
mozilla::ipc::IPCResult RecvNotifyDeviceReset() override;
mozilla::ipc::IPCResult RecvAddMemoryReport(const MemoryReport& aReport) override;
mozilla::ipc::IPCResult RecvFinishMemoryReport(const uint32_t& aGeneration) override;
bool SendRequestMemoryReport(const uint32_t& aGeneration,
const bool& aAnonymize,
const bool& aMinimizeMemoryUsage,
const MaybeFileDesc& aDMDFile);
static void Destroy(UniquePtr<GPUChild>&& aChild);
private:
GPUProcessHost* mHost;
UniquePtr<ipc::CrashReporterHost> mCrashReporter;
UniquePtr<MemoryReportRequestHost> mMemoryReportRequest;
bool mGPUReady;
};

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

@ -14,6 +14,9 @@
#include "mozilla/Assertions.h"
#include "mozilla/Telemetry.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/dom/MemoryReportRequest.h"
#include "mozilla/dom/VideoDecoderManagerChild.h"
#include "mozilla/dom/VideoDecoderManagerParent.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/ipc/CrashReporterClient.h"
@ -21,10 +24,8 @@
#include "mozilla/layers/APZThreadUtils.h"
#include "mozilla/layers/APZCTreeManager.h"
#include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/dom/VideoDecoderManagerParent.h"
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/ImageBridgeParent.h"
#include "mozilla/dom/VideoDecoderManagerChild.h"
#include "mozilla/layers/LayerTreeOwnerTracker.h"
#include "mozilla/layers/UiCompositorControllerParent.h"
#include "nsDebugImpl.h"
@ -38,6 +39,7 @@
#if defined(XP_WIN)
# include "DeviceManagerD3D9.h"
# include "mozilla/gfx/DeviceManagerDx.h"
# include <process.h>
#endif
#ifdef MOZ_WIDGET_GTK
# include <gtk/gtk.h>
@ -372,6 +374,19 @@ GPUParent::RecvNotifyGpuObservers(const nsCString& aTopic)
return IPC_OK();
}
mozilla::ipc::IPCResult
GPUParent::RecvRequestMemoryReport(const uint32_t& aGeneration,
const bool& aAnonymize,
const bool& aMinimizeMemoryUsage,
const MaybeFileDesc& aDMDFile)
{
nsPrintfCString processName("GPU (pid %u)", (unsigned)getpid());
mozilla::dom::MemoryReportRequestClient::Start(
aGeneration, aAnonymize, aMinimizeMemoryUsage, aDMDFile, processName);
return IPC_OK();
}
void
GPUParent::ActorDestroy(ActorDestroyReason aWhy)
{

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

@ -54,6 +54,11 @@ public:
mozilla::ipc::IPCResult RecvAddLayerTreeIdMapping(nsTArray<LayerTreeIdMapping>&& aMappings) override;
mozilla::ipc::IPCResult RecvRemoveLayerTreeIdMapping(const LayerTreeIdMapping& aMapping) override;
mozilla::ipc::IPCResult RecvNotifyGpuObservers(const nsCString& aTopic) override;
mozilla::ipc::IPCResult RecvRequestMemoryReport(
const uint32_t& generation,
const bool& anonymize,
const bool& minimizeMemoryUsage,
const MaybeFileDesc& DMDFile) override;
void ActorDestroy(ActorDestroyReason aWhy) override;

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

@ -6,6 +6,7 @@
#include "GPUProcessManager.h"
#include "GPUProcessHost.h"
#include "GPUProcessListener.h"
#include "mozilla/MemoryReportingProcess.h"
#include "mozilla/Sprintf.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/dom/ContentParent.h"
@ -906,5 +907,61 @@ GPUProcessManager::NotifyGpuObservers(const char* aTopic)
return true;
}
class GPUMemoryReporter : public MemoryReportingProcess
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GPUMemoryReporter, override)
bool IsAlive() const override {
if (GPUProcessManager* gpm = GPUProcessManager::Get()) {
return !!gpm->GetGPUChild();
}
return false;
}
bool SendRequestMemoryReport(const uint32_t& aGeneration,
const bool& aAnonymize,
const bool& aMinimizeMemoryUsage,
const dom::MaybeFileDesc& aDMDFile) override
{
GPUChild* child = GetChild();
if (!child) {
return false;
}
return child->SendRequestMemoryReport(
aGeneration, aAnonymize, aMinimizeMemoryUsage, aDMDFile);
}
int32_t Pid() const override {
if (GPUChild* child = GetChild()) {
return (int32_t)child->OtherPid();
}
return 0;
}
private:
GPUChild* GetChild() const {
if (GPUProcessManager* gpm = GPUProcessManager::Get()) {
if (GPUChild* child = gpm->GetGPUChild()) {
return child;
}
}
return nullptr;
}
protected:
~GPUMemoryReporter() = default;
};
RefPtr<MemoryReportingProcess>
GPUProcessManager::GetProcessMemoryReporter()
{
if (!mGPUChild) {
return nullptr;
}
return new GPUMemoryReporter();
}
} // namespace gfx
} // namespace mozilla

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

@ -22,6 +22,7 @@ class nsBaseWidget;
namespace mozilla {
class MemoryReportingProcess;
namespace layers {
class IAPZCTreeManager;
class CompositorOptions;
@ -140,6 +141,10 @@ public:
// Returns -1 if there is no GPU process, or the platform pid for it.
base::ProcessId GPUProcessPid();
// If a GPU process is present, create a MemoryReportingProcess object.
// Otherwise, return null.
RefPtr<MemoryReportingProcess> GetProcessMemoryReporter();
// Returns access to the PGPU protocol if a GPU process is present.
GPUChild* GetGPUChild() {
return mGPUChild;

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

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include GraphicsMessages;
include MemoryReportTypes;
include protocol PCompositorBridge;
include protocol PImageBridge;
include protocol PVRManager;
@ -85,6 +86,11 @@ parent:
// observer service.
async NotifyGpuObservers(nsCString aTopic);
async RequestMemoryReport(uint32_t generation,
bool anonymize,
bool minimizeMemoryUsage,
MaybeFileDesc DMDFile);
child:
// Sent when the GPU process has initialized devices. This occurs once, after
// Init().
@ -109,6 +115,9 @@ child:
async UpdateChildKeyedScalars(KeyedScalarAction[] actions);
async NotifyDeviceReset();
async AddMemoryReport(MemoryReport aReport);
async FinishMemoryReport(uint32_t aGeneration);
};
} // namespace gfx

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

@ -585,16 +585,6 @@ CompositorBridgeChild::RecvDidComposite(const uint64_t& aId, const uint64_t& aTr
return IPC_OK();
}
mozilla::ipc::IPCResult
CompositorBridgeChild::RecvClearCachedResources(const uint64_t& aId)
{
dom::TabChild* child = dom::TabChild::GetFrom(aId);
if (child) {
child->ClearCachedResources();
}
return IPC_OK();
}
void
CompositorBridgeChild::ActorDestroy(ActorDestroyReason aWhy)
{

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

@ -93,9 +93,6 @@ public:
// process). This may only be called on the main thread.
static bool CompositorIsInGPUProcess();
virtual mozilla::ipc::IPCResult
RecvClearCachedResources(const uint64_t& id) override;
virtual mozilla::ipc::IPCResult
RecvDidComposite(const uint64_t& aId, const uint64_t& aTransactionId,
const TimeStamp& aCompositeStart,

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

@ -126,12 +126,6 @@ child:
*/
async HideAllPlugins(uintptr_t aParentWidget);
/**
* Drop any buffers that might be retained on the child compositor
* side.
*/
async ClearCachedResources(uint64_t id);
async ParentAsyncMessages(AsyncParentMessageData[] aMessages);
async ObserveLayerUpdate(uint64_t aLayersId, uint64_t aEpoch, bool aActive);

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

@ -2220,25 +2220,25 @@ gfxPlatform::InitGPUProcessPrefs()
FeatureState& gpuProc = gfxConfig::GetFeature(Feature::GPU_PROCESS);
gpuProc.SetDefaultFromPref(
gfxPrefs::GetGPUProcessEnabledPrefName(),
true,
gfxPrefs::GetGPUProcessEnabledPrefDefault());
// We require E10S - otherwise, there is very little benefit to the GPU
// process, since the UI process must still use acceleration for
// performance.
if (!BrowserTabsRemoteAutostart()) {
gpuProc.DisableByDefault(
FeatureStatus::Unavailable,
"Multi-process mode is not enabled",
NS_LITERAL_CSTRING("FEATURE_FAILURE_NO_E10S"));
} else {
gpuProc.SetDefaultFromPref(
gfxPrefs::GetGPUProcessEnabledPrefName(),
true,
gfxPrefs::GetGPUProcessEnabledPrefDefault());
}
if (gfxPrefs::GPUProcessForceEnabled()) {
gpuProc.UserForceEnable("User force-enabled via pref");
}
// We require E10S - otherwise, there is very little benefit to the GPU
// process, since the UI process must still use acceleration for
// performance.
if (!BrowserTabsRemoteAutostart()) {
gpuProc.ForceDisable(
FeatureStatus::Unavailable,
"Multi-process mode is not enabled",
NS_LITERAL_CSTRING("FEATURE_FAILURE_NO_E10S"));
return;
}
if (InSafeMode()) {
gpuProc.ForceDisable(
FeatureStatus::Blocked,
@ -2413,6 +2413,27 @@ gfxPlatform::GetDefaultFrameRate()
return 60;
}
void
gfxPlatform::GetAzureBackendInfo(mozilla::widget::InfoObject& aObj)
{
if (gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
aObj.DefineProperty("AzureCanvasBackend (UI Process)", GetBackendName(mPreferredCanvasBackend));
aObj.DefineProperty("AzureFallbackCanvasBackend (UI Process)", GetBackendName(mFallbackCanvasBackend));
aObj.DefineProperty("AzureContentBackend (UI Process)", GetBackendName(mContentBackend));
if (gfxConfig::IsEnabled(gfx::Feature::DIRECT2D)) {
aObj.DefineProperty("AzureCanvasBackend", "Direct2D 1.1");
aObj.DefineProperty("AzureContentBackend", "Direct2D 1.1");
}
} else {
aObj.DefineProperty("AzureCanvasBackend", GetBackendName(mPreferredCanvasBackend));
aObj.DefineProperty("AzureFallbackCanvasBackend", GetBackendName(mFallbackCanvasBackend));
aObj.DefineProperty("AzureContentBackend", GetBackendName(mContentBackend));
}
aObj.DefineProperty("AzureCanvasAccelerated", AllowOpenGLCanvas());
}
void
gfxPlatform::GetApzSupportInfo(mozilla::widget::InfoObject& aObj)
{

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

@ -282,12 +282,7 @@ public:
static bool AsyncPanZoomEnabled();
virtual void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj) {
aObj.DefineProperty("AzureCanvasBackend", GetBackendName(mPreferredCanvasBackend));
aObj.DefineProperty("AzureCanvasAccelerated", AllowOpenGLCanvas());
aObj.DefineProperty("AzureFallbackCanvasBackend", GetBackendName(mFallbackCanvasBackend));
aObj.DefineProperty("AzureContentBackend", GetBackendName(mContentBackend));
}
virtual void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj);
void GetApzSupportInfo(mozilla::widget::InfoObject& aObj);
void GetTilesSupportInfo(mozilla::widget::InfoObject& aObj);

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

@ -21,7 +21,7 @@ namespace js {
// A call stack can be specified to the JS engine such that all JS entry/exits
// to functions push/pop an entry to/from the specified stack.
//
// For more detailed information, see vm/SPSProfiler.h.
// For more detailed information, see vm/GeckoProfiler.h.
//
class ProfileEntry
{
@ -95,10 +95,10 @@ class ProfileEntry
static_assert((static_cast<int>(Category::FIRST) & Flags::ALL) == 0,
"The category bitflags should not intersect with the other flags!");
// All of these methods are marked with the 'volatile' keyword because SPS's
// representation of the stack is stored such that all ProfileEntry
// instances are volatile. These methods would not be available unless they
// were marked as volatile as well.
// All of these methods are marked with the 'volatile' keyword because the
// Gecko Profiler's representation of the stack is stored such that all
// ProfileEntry instances are volatile. These methods would not be
// available unless they were marked as volatile as well.
bool isCpp() const volatile { return hasFlag(IS_CPP_ENTRY); }
bool isJs() const volatile { return !isCpp(); }
@ -173,7 +173,7 @@ class ProfileEntry
return (JSScript*)spOrScript;
}
// We can't know the layout of JSScript, so look in vm/SPSProfiler.cpp.
// We can't know the layout of JSScript, so look in vm/GeckoProfiler.cpp.
JS_FRIEND_API(jsbytecode*) pc() const volatile;
JS_FRIEND_API(void) setPC(jsbytecode* pc) volatile;

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

@ -423,18 +423,6 @@ js::obj_toString(JSContext* cx, unsigned argc, Value* vp)
return true;
}
bool
js::obj_valueOf(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx, ToObject(cx, args.thisv()));
if (!obj)
return false;
args.rval().setObject(*obj);
return true;
}
static bool
obj_setPrototypeOf(JSContext* cx, unsigned argc, Value* vp)
{
@ -1199,7 +1187,7 @@ static const JSFunctionSpec object_methods[] = {
#endif
JS_FN(js_toString_str, obj_toString, 0,0),
JS_SELF_HOSTED_FN(js_toLocaleString_str, "Object_toLocaleString", 0, 0),
JS_FN(js_valueOf_str, obj_valueOf, 0,0),
JS_SELF_HOSTED_FN(js_valueOf_str, "Object_valueOf", 0,0),
#if JS_HAS_OBJ_WATCHPOINT
JS_FN(js_watch_str, obj_watch, 2,0),
JS_FN(js_unwatch_str, obj_unwatch, 1,0),

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

@ -25,9 +25,6 @@ obj_construct(JSContext* cx, unsigned argc, JS::Value* vp);
MOZ_MUST_USE bool
obj_propertyIsEnumerable(JSContext* cx, unsigned argc, Value* vp);
MOZ_MUST_USE bool
obj_valueOf(JSContext* cx, unsigned argc, JS::Value* vp);
PlainObject*
ObjectCreateImpl(JSContext* cx, HandleObject proto, NewObjectKind newKind = GenericObject,
HandleObjectGroup group = nullptr);

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

@ -87,6 +87,12 @@ function Object_toLocaleString() {
return callContentFunction(O.toString, O);
}
// ES 2017 draft bb96899bb0d9ef9be08164a26efae2ee5f25e875 19.1.3.7
function Object_valueOf() {
// Step 1.
return ToObject(this);
}
// ES7 draft (2016 March 8) B.2.2.3
function ObjectDefineSetter(name, setter) {
// Step 1.

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

@ -1745,13 +1745,13 @@ Terminate(JSContext* cx, unsigned arg, Value* vp)
}
static bool
ReadSPSProfilingStack(JSContext* cx, unsigned argc, Value* vp)
ReadGeckoProfilingStack(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
args.rval().setUndefined();
// Return boolean 'false' if profiler is not enabled.
if (!cx->runtime()->spsProfiler.enabled()) {
if (!cx->runtime()->geckoProfiler.enabled()) {
args.rval().setBoolean(false);
return true;
}
@ -4378,8 +4378,8 @@ gc::ZealModeHelpText),
" Terminate JavaScript execution, as if we had run out of\n"
" memory or been terminated by the slow script dialog."),
JS_FN_HELP("readSPSProfilingStack", ReadSPSProfilingStack, 0, 0,
"readSPSProfilingStack()",
JS_FN_HELP("readGeckoProfilingStack", ReadGeckoProfilingStack, 0, 0,
"readGeckoProfilingStack()",
" Reads the jit stack using ProfilingFrameIterator."),
JS_FN_HELP("enableOsiPointRegisterChecks", EnableOsiPointRegisterChecks, 0, 0,

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

@ -46,7 +46,7 @@ class MOZ_RAII AutoTraceSession
void operator=(const AutoTraceSession&) = delete;
JS::HeapState prevState;
AutoSPSEntry pseudoFrame;
AutoGeckoProfilerEntry pseudoFrame;
};
class MOZ_RAII AutoPrepareForTracing

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

@ -361,8 +361,8 @@ js::gc::GCRuntime::traceRuntimeCommon(JSTracer* trc, TraceOrMarkRuntime traceOrM
for (CompartmentsIter c(rt, SkipAtoms); !c.done(); c.next())
c->traceRoots(trc, traceOrMark);
// Trace SPS.
rt->spsProfiler.trace(trc);
// Trace the Gecko Profiler.
rt->geckoProfiler.trace(trc);
// Trace helper thread roots.
HelperThreadState().trace(trc);

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

@ -1,7 +1,7 @@
if (!this.hasOwnProperty("TypedObject"))
quit();
enableSPSProfiling();
enableGeckoProfiling();
var T = TypedObject;
function check(results, ctor) {
for (var i = 0; i < results.length; i++)

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

@ -2,5 +2,5 @@ load(libdir + "asm.js");
var f = asmLink(asmCompile(USE_ASM + "function a234567() { return 42 } return a234567"));
assertEq(f(), 42);
enableSPSProfiling();
enableGeckoProfiling();
assertEq(f(), 42);

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

@ -1,4 +1,4 @@
enableSPSProfiling();
enableGeckoProfiling();
for (var j = 0; j < 1000; ++j) {
(function(stdlib) {
"use asm";

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

@ -4,7 +4,7 @@ load(libdir + "asm.js");
if (!getBuildConfiguration()["arm-simulator"])
quit();
enableSPSProfiling();
enableGeckoProfiling();
enableSingleStepProfiling();
var m = asmCompile(USE_ASM + 'function f() {} return f');
asmLink(m)();

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

@ -1,4 +1,4 @@
enableSPSProfiling();
enableGeckoProfiling();
function mod() {
"use asm";

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

@ -38,9 +38,9 @@ for (let threshold of [0, 50, 100, 5000, -1]) {
`)(this, null, buf)(0), 52);
}
enableSPSProfiling();
enableGeckoProfiling();
asmLink(asmCompile(USE_ASM + 'function f() {} function g() { f() } function h() { g() } return h'))();
disableSPSProfiling();
disableGeckoProfiling();
assertEq(asmCompile(fatFunc)()(), 142);
}

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

@ -59,11 +59,11 @@ function assertStackContainsSeq(got, expect)
var stacks;
var ffi = function(enable) {
if (enable == +1)
enableSPSProfiling();
enableGeckoProfiling();
enableSingleStepProfiling();
stacks = disableSingleStepProfiling();
if (enable == -1)
disableSPSProfiling();
disableGeckoProfiling();
}
var f = asmLink(asmCompile('global','ffis',USE_ASM + "var ffi=ffis.ffi; function g(i) { i=i|0; ffi(i|0) } function f(i) { i=i|0; g(i|0) } return f"), null, {ffi});
f(0);
@ -78,7 +78,7 @@ f(0);
assertStackContainsSeq(stacks, "");
// Enable profiling for the rest of the tests.
enableSPSProfiling();
enableGeckoProfiling();
var f = asmLink(asmCompile(USE_ASM + "function f() { return 42 } return f"));
enableSingleStepProfiling();

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

@ -2,7 +2,7 @@
load(libdir + "asm.js");
enableSPSProfiling();
enableGeckoProfiling();
var f = asmLink(asmCompile('glob', 'ffis', 'buf', USE_ASM + "function f() { var i=0; while (1) { i=(i+1)|0 } } return f"));
timeout(1);

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

@ -2,7 +2,7 @@
load(libdir + "asm.js");
enableSPSProfiling();
enableGeckoProfiling();
var f = asmLink(asmCompile('glob', 'ffis', 'buf', USE_ASM + "function g() { var i=0; while (1) { i=(i+1)|0 } } function f() { g() } return f"));
timeout(1);

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

@ -8,7 +8,7 @@ function addDebug(g, id) {\
var debuggerGlobal = newGlobal();\
debuggerGlobal.debuggee = g;\
debuggerGlobal.id = id;\
debuggerGlobal.print = function (s) { (g) += s; };\
debuggerGlobal.print = function (s) { print(s); };\
debuggerGlobal.eval('var dbg = new Debugger(debuggee);dbg.onDebuggerStatement = function () { print(id); debugger; };');\
return debuggerGlobal;\
}\

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

@ -1,5 +1,5 @@
// |jit-test| error: InternalError
enableSPSProfiling();
enableGeckoProfiling();
var g = newGlobal();
g.parent = this;
g.eval("new Debugger(parent).onExceptionUnwind = function () { hits++; };");

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

@ -9,7 +9,7 @@ if (!wasmIsSupported())
if (!getBuildConfiguration()["arm-simulator"])
throw "TestComplete";
enableSPSProfiling();
enableGeckoProfiling();
enableSingleStepProfiling();
var g = newGlobal();
@ -40,5 +40,5 @@ try {
assertEq(e, "test");
}
disableSPSProfiling();
disableGeckoProfiling();
throw "TestComplete";

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

@ -1,7 +1,7 @@
if (!('oomTest' in this) || helperThreadCount() === 0)
quit();
enableSPSProfiling();
enableGeckoProfiling();
var s = newGlobal();
s.offThreadCompileScript('oomTest(() => {});');
s.runOffThreadScript();

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

@ -1,7 +1,7 @@
if (!('oomTest' in this))
quit();
enableSPSProfilingWithSlowAssertions();
enableGeckoProfilingWithSlowAssertions();
try {
(function() {
while (n--) {

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

@ -1,7 +1,7 @@
if (!('oomTest' in this))
quit();
enableSPSProfiling();
enableGeckoProfiling();
oomTest(() => {
try {
for (var quit of oomTest.gcparam("//").ArrayBuffer(1)) {}

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

@ -1,10 +1,10 @@
var lfLogBuffer = `
gczeal(14);
enableSPSProfiling();
enableGeckoProfiling();
gczeal(15,3);
var s = "";
for (let i = 0; i != 30; i+=2) {}
readSPSProfilingStack(s, "c0d1c0d1c0d1c0d1c0d1c0d1c0d1c0");
readGeckoProfilingStack(s, "c0d1c0d1c0d1c0d1c0d1c0d1c0d1c0");
`;
loadFile(lfLogBuffer);
function loadFile(lfVarx) {

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

@ -3,6 +3,6 @@ function f() {
gc()
})()
}
enableSPSProfiling()
enableGeckoProfiling()
f()
f()

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

@ -3,5 +3,5 @@ function f(x) {
eval(x);
} catch (e) {}
};
f("enableSPSProfilingWithSlowAssertions();");
f("enableGeckoProfilingWithSlowAssertions();");
f("enableTrackAllocations(); throw Error();");

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

@ -1,5 +1,5 @@
setJitCompilerOption('ion.forceinlineCaches', 1);
enableSPSProfiling();
enableGeckoProfiling();
(function() {
-[];
})();

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

@ -1,2 +1,2 @@
enableSPSProfiling();
enableGeckoProfiling();
Object.getOwnPropertyNames(this);

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