Merge inbound to mozilla-central a=merge

This commit is contained in:
Coroiu Cristina 2018-11-02 07:11:08 +02:00
Родитель 2945b5216f 760f899f82
Коммит 02eff2f0bf
81 изменённых файлов: 276 добавлений и 3051 удалений

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

@ -6,7 +6,6 @@
"use strict";
const { Cu } = require("chrome");
const { Services } = require("resource://gre/modules/Services.jsm");
var systemAppOrigin = (function() {
@ -247,32 +246,6 @@ TouchSimulator.prototype = {
},
sendTouchEvent(evt, target, name) {
function clone(obj) {
return Cu.cloneInto(obj, target);
}
// When running OOP b2g desktop, we need to send the touch events
// using the mozbrowser api on the unwrapped frame.
if (target.localName == "iframe" && target.mozbrowser === true) {
if (name == "touchstart") {
this.touchstartTime = Date.now();
} else if (name == "touchend") {
// If we have a "fast" tap, don't send a click as both will be turned
// into a click and that breaks eg. checkboxes.
if (Date.now() - this.touchstartTime < delay) {
this.cancelClick = true;
}
}
const unwrapped = XPCNativeWrapper.unwrap(target);
/* eslint-disable no-multi-spaces */
unwrapped.sendTouchEvent(name, clone([0]), // event type, id
clone([evt.clientX]), // x
clone([evt.clientY]), // y
clone([1]), clone([1]), // rx, ry
clone([0]), clone([0]), // rotation, force
1); // count
/* eslint-enable no-multi-spaces */
return;
}
const document = target.ownerDocument;
const content = this.getContent(target);
if (!content) {

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

@ -161,18 +161,6 @@ Test swapFrameLoaders with different frame types and remoteness
is(pongB, "B", "Frame B message manager gets reply B before swap");
}
// Check height before swap
{
if (frameA.getContentDimensions) {
let { height } = await frameA.getContentDimensions();
is(height, heightA, "Frame A's content height is 200px before swap");
}
if (frameB.getContentDimensions) {
let { height } = await frameB.getContentDimensions();
is(height, heightB, "Frame B's content height is 400px before swap");
}
}
// Ping after swap using message managers acquired before
{
let mmA = frameA.frameLoader.messageManager;

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

@ -1,26 +1,13 @@
const FRAME_URL = "http://example.org/";
const METHODS = {
addNextPaintListener: {},
removeNextPaintListener: {},
sendMouseEvent: {},
sendTouchEvent: {},
goBack: {},
goForward: {},
reload: {},
stop: {},
download: {},
purgeHistory: {},
getScreenshot: {},
zoom: {},
getCanGoBack: {},
getCanGoForward: {},
getContentDimensions: {},
findAll: {},
findNext: {},
clearMatch: {},
executeScript: {},
getWebManifest: {},
};
const ATTRIBUTES = [];

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

@ -16,12 +16,6 @@ ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/BrowserElementPromptService.jsm");
ChromeUtils.defineModuleGetter(this, "ManifestFinder",
"resource://gre/modules/ManifestFinder.jsm");
ChromeUtils.defineModuleGetter(this, "ManifestObtainer",
"resource://gre/modules/ManifestObtainer.jsm");
var kLongestReturnedString = 128;
var Timer = Components.Constructor("@mozilla.org/timer;1",
@ -114,8 +108,6 @@ function BrowserElementChild() {
// Maps outer window id --> weak ref to window. Used by modal dialog code.
this._windowIDDict = {};
this._nextPaintHandler = null;
this._isContentWindowCreated = false;
this._init();
@ -199,8 +191,6 @@ BrowserElementChild.prototype = {
removeEventListener(event.type, this, event.useCapture, event.wantsUntrusted);
});
this._deactivateNextPaintListener();
removeMessageListener("browser-element-api:call", this);
let els = Cc["@mozilla.org/eventlistenerservice;1"]
@ -274,11 +264,7 @@ BrowserElementChild.prototype = {
let self = this;
let mmCalls = {
"purge-history": this._recvPurgeHistory,
"get-screenshot": this._recvGetScreenshot,
"get-contentdimensions": this._recvGetContentDimensions,
"send-mouse-event": this._recvSendMouseEvent,
"send-touch-event": this._recvSendTouchEvent,
"get-can-go-back": this._recvCanGoBack,
"get-can-go-forward": this._recvCanGoForward,
"go-back": this._recvGoBack,
@ -291,13 +277,6 @@ BrowserElementChild.prototype = {
"owner-visibility-change": this._recvOwnerVisibilityChange,
"entered-fullscreen": this._recvEnteredFullscreen,
"exit-fullscreen": this._recvExitFullscreen,
"activate-next-paint-listener": this._activateNextPaintListener,
"deactivate-next-paint-listener": this._deactivateNextPaintListener,
"find-all": this._recvFindAll,
"find-next": this._recvFindNext,
"clear-match": this._recvClearMatch,
"execute-script": this._recvExecuteScript,
"get-web-manifest": this._recvGetWebManifest,
}
if (message.data.msg_name in mmCalls) {
@ -541,13 +520,6 @@ BrowserElementChild.prototype = {
},
_manifestChangedHandler: function(e) {
debug('Got manifestchanged: (' + e.target.href + ')');
let manifest = { href: e.target.href };
sendAsyncMsg('manifestchange', manifest);
},
// Processes the "rel" field in <link> tags and forward to specific handlers.
_linkAddedHandler: function(e) {
let win = e.target.ownerGlobal;
@ -563,7 +535,6 @@ BrowserElementChild.prototype = {
'apple-touch-icon': this._iconChangedHandler.bind(this),
'apple-touch-icon-precomposed': this._iconChangedHandler.bind(this),
'search': this._openSearchHandler,
'manifest': this._manifestChangedHandler
};
debug('Got linkAdded: (' + e.target.href + ') ' + e.target.rel);
@ -707,27 +678,6 @@ BrowserElementChild.prototype = {
return onMozAfterPaint;
},
_removeMozAfterPaintHandler: function(listener) {
removeEventListener('MozAfterPaint', listener,
/* useCapture = */ true);
},
_activateNextPaintListener: function(e) {
if (!this._nextPaintHandler) {
this._nextPaintHandler = this._addMozAfterPaintHandler(() => {
this._nextPaintHandler = null;
sendAsyncMsg('nextpaint');
});
}
},
_deactivateNextPaintListener: function(e) {
if (this._nextPaintHandler) {
this._removeMozAfterPaintHandler(this._nextPaintHandler);
this._nextPaintHandler = null;
}
},
_windowCloseHandler: function(e) {
let win = e.target;
if (win != content || e.defaultPrevented) {
@ -909,134 +859,6 @@ BrowserElementChild.prototype = {
sendAsyncMsg("scroll", { top: win.scrollY, left: win.scrollX });
},
_recvPurgeHistory: function(data) {
debug("Received purgeHistory message: (" + data.json.id + ")");
let history = docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
try {
if (history && history.count) {
history.legacySHistory.PurgeHistory(history.count);
}
} catch(e) {}
sendAsyncMsg('got-purge-history', { id: data.json.id, successRv: true });
},
_recvGetScreenshot: function(data) {
debug("Received getScreenshot message: (" + data.json.id + ")");
let self = this;
let maxWidth = data.json.args.width;
let maxHeight = data.json.args.height;
let mimeType = data.json.args.mimeType;
let domRequestID = data.json.id;
let takeScreenshotClosure = function() {
self._takeScreenshot(maxWidth, maxHeight, mimeType, domRequestID);
};
let maxDelayMS = Services.prefs.getIntPref('dom.browserElement.maxScreenshotDelayMS', 2000);
// Try to wait for the event loop to go idle before we take the screenshot,
// but once we've waited maxDelayMS milliseconds, go ahead and take it
// anyway.
Cc['@mozilla.org/message-loop;1'].getService(Ci.nsIMessageLoop).postIdleTask(
takeScreenshotClosure, maxDelayMS);
},
_recvExecuteScript: function(data) {
debug("Received executeScript message: (" + data.json.id + ")");
let domRequestID = data.json.id;
let sendError = errorMsg => sendAsyncMsg("execute-script-done", {
errorMsg,
id: domRequestID
});
let sendSuccess = successRv => sendAsyncMsg("execute-script-done", {
successRv,
id: domRequestID
});
let isJSON = obj => {
try {
JSON.stringify(obj);
} catch(e) {
return false;
}
return true;
}
let expectedOrigin = data.json.args.options.origin;
let expectedUrl = data.json.args.options.url;
if (expectedOrigin) {
if (expectedOrigin != content.location.origin) {
sendError("Origin mismatches");
return;
}
}
if (expectedUrl) {
let expectedURI
try {
expectedURI = Services.io.newURI(expectedUrl);
} catch(e) {
sendError("Malformed URL");
return;
}
let currentURI = docShell.QueryInterface(Ci.nsIWebNavigation).currentURI;
if (!currentURI.equalsExceptRef(expectedURI)) {
sendError("URL mismatches");
return;
}
}
let sandbox = new Cu.Sandbox([content], {
sandboxPrototype: content,
sandboxName: "browser-api-execute-script",
allowWaivers: false,
sameZoneAs: content
});
try {
let sandboxRv = Cu.evalInSandbox(data.json.args.script, sandbox, "1.8");
if (sandboxRv instanceof sandbox.Promise) {
sandboxRv.then(rv => {
if (isJSON(rv)) {
sendSuccess(rv);
} else {
sendError("Value returned (resolve) by promise is not a valid JSON object");
}
}, error => {
if (isJSON(error)) {
sendError(error);
} else {
sendError("Value returned (reject) by promise is not a valid JSON object");
}
});
} else {
if (isJSON(sandboxRv)) {
sendSuccess(sandboxRv);
} else {
sendError("Script last expression must be a promise or a JSON object");
}
}
} catch(e) {
sendError(e.toString());
}
},
_recvGetContentDimensions: function(data) {
debug("Received getContentDimensions message: (" + data.json.id + ")");
sendAsyncMsg('got-contentdimensions', {
id: data.json.id,
successRv: this._getContentDimensions()
});
},
_mozScrollAreaChanged: function(e) {
sendAsyncMsg('scrollareachanged', {
width: e.width,
@ -1058,105 +880,6 @@ BrowserElementChild.prototype = {
sendAsyncMsg("exit-dom-fullscreen");
},
_getContentDimensions: function() {
return {
width: content.document.body.scrollWidth,
height: content.document.body.scrollHeight
}
},
/**
* Actually take a screenshot and foward the result up to our parent, given
* the desired maxWidth and maxHeight (in CSS pixels), and given the
* DOMRequest ID associated with the request from the parent.
*/
_takeScreenshot: function(maxWidth, maxHeight, mimeType, domRequestID) {
// You can think of the screenshotting algorithm as carrying out the
// following steps:
//
// - Calculate maxWidth, maxHeight, and viewport's width and height in the
// dimension of device pixels by multiply the numbers with
// window.devicePixelRatio.
//
// - Let scaleWidth be the factor by which we'd need to downscale the
// viewport pixel width so it would fit within maxPixelWidth.
// (If the viewport's pixel width is less than maxPixelWidth, let
// scaleWidth be 1.) Compute scaleHeight the same way.
//
// - Scale the viewport by max(scaleWidth, scaleHeight). Now either the
// viewport's width is no larger than maxWidth, the viewport's height is
// no larger than maxHeight, or both.
//
// - Crop the viewport so its width is no larger than maxWidth and its
// height is no larger than maxHeight.
//
// - Set mozOpaque to true and background color to solid white
// if we are taking a JPEG screenshot, keep transparent if otherwise.
//
// - Return a screenshot of the page's viewport scaled and cropped per
// above.
debug("Taking a screenshot: maxWidth=" + maxWidth +
", maxHeight=" + maxHeight +
", mimeType=" + mimeType +
", domRequestID=" + domRequestID + ".");
if (!content) {
// If content is not loaded yet, bail out since even sendAsyncMessage
// fails...
debug("No content yet!");
return;
}
let devicePixelRatio = content.devicePixelRatio;
let maxPixelWidth = Math.round(maxWidth * devicePixelRatio);
let maxPixelHeight = Math.round(maxHeight * devicePixelRatio);
let contentPixelWidth = content.innerWidth * devicePixelRatio;
let contentPixelHeight = content.innerHeight * devicePixelRatio;
let scaleWidth = Math.min(1, maxPixelWidth / contentPixelWidth);
let scaleHeight = Math.min(1, maxPixelHeight / contentPixelHeight);
let scale = Math.max(scaleWidth, scaleHeight);
let canvasWidth =
Math.min(maxPixelWidth, Math.round(contentPixelWidth * scale));
let canvasHeight =
Math.min(maxPixelHeight, Math.round(contentPixelHeight * scale));
let transparent = (mimeType !== 'image/jpeg');
var canvas = content.document
.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
if (!transparent)
canvas.mozOpaque = true;
canvas.width = canvasWidth;
canvas.height = canvasHeight;
let ctx = canvas.getContext("2d", { willReadFrequently: true });
ctx.scale(scale * devicePixelRatio, scale * devicePixelRatio);
let flags = ctx.DRAWWINDOW_DRAW_VIEW |
ctx.DRAWWINDOW_USE_WIDGET_LAYERS |
ctx.DRAWWINDOW_DO_NOT_FLUSH |
ctx.DRAWWINDOW_ASYNC_DECODE_IMAGES;
ctx.drawWindow(content, 0, 0, content.innerWidth, content.innerHeight,
transparent ? "rgba(255,255,255,0)" : "rgb(255,255,255)",
flags);
// Take a JPEG screenshot by default instead of PNG with alpha channel.
// This requires us to unpremultiply the alpha channel, which
// is expensive on ARM processors because they lack a hardware integer
// division instruction.
canvas.toBlob(function(blob) {
sendAsyncMsg('got-screenshot', {
id: domRequestID,
successRv: blob
});
}, mimeType);
},
_recvFireCtxCallback: function(data) {
debug("Received fireCtxCallback message: (" + data.json.menuitem + ")");
@ -1240,15 +963,6 @@ BrowserElementChild.prototype = {
json.clickCount, json.modifiers);
},
_recvSendTouchEvent: function(data) {
let json = data.json;
let utils = content.windowUtils;
utils.sendTouchEventToWindow(json.type, json.identifiers, json.touchesX,
json.touchesY, json.radiisX, json.radiisY,
json.rotationAngles, json.forces, json.count,
json.modifiers);
},
_recvCanGoBack: function(data) {
var webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
sendAsyncMsg('got-can-go-back', {
@ -1298,78 +1012,6 @@ BrowserElementChild.prototype = {
webNav.stop(webNav.STOP_NETWORK);
},
_recvZoom: function(data) {
docShell.contentViewer.fullZoom = data.json.zoom;
},
async _recvGetWebManifest(data) {
debug(`Received GetWebManifest message: (${data.json.id})`);
let manifest = null;
let hasManifest = ManifestFinder.contentHasManifestLink(content);
if (hasManifest) {
try {
manifest = await ManifestObtainer.contentObtainManifest(content);
} catch (e) {
sendAsyncMsg('got-web-manifest', {
id: data.json.id,
errorMsg: `Error fetching web manifest: ${e}.`,
});
return;
}
}
sendAsyncMsg('got-web-manifest', {
id: data.json.id,
successRv: manifest
});
},
_initFinder: function() {
if (!this._finder) {
let {Finder} = ChromeUtils.import("resource://gre/modules/Finder.jsm", {});
this._finder = new Finder(docShell);
}
let listener = {
onMatchesCountResult: (data) => {
sendAsyncMsg("findchange", {
active: true,
searchString: this._finder.searchString,
searchLimit: this._finder.matchesCountLimit,
activeMatchOrdinal: data.current,
numberOfMatches: data.total
});
this._finder.removeResultListener(listener);
}
};
this._finder.addResultListener(listener);
},
_recvFindAll: function(data) {
this._initFinder();
let searchString = data.json.searchString;
this._finder.caseSensitive = data.json.caseSensitive;
this._finder.fastFind(searchString, false, false);
this._finder.requestMatchesCount(searchString, this._finder.matchesCountLimit, false);
},
_recvFindNext: function(data) {
if (!this._finder) {
debug("findNext() called before findAll()");
return;
}
this._initFinder();
this._finder.findAgain(data.json.backward, false, false);
this._finder.requestMatchesCount(this._finder.searchString, this._finder.matchesCountLimit, false);
},
_recvClearMatch: function(data) {
if (!this._finder) {
debug("clearMach() called before findAll()");
return;
}
this._finder.removeSelection();
sendAsyncMsg("findchange", {active: false});
},
// The docShell keeps a weak reference to the progress listener, so we need
// to keep a strong ref to it ourselves.
_progressListener: {

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

@ -49,19 +49,18 @@ function defineNoReturnMethod(fn) {
};
}
function defineDOMRequestMethod(msgName) {
function definePromiseMethod(msgName) {
return function() {
return this._sendDOMRequest(msgName);
return this._sendAsyncRequest(msgName);
};
}
function BrowserElementParent() {
debug("Creating new BrowserElementParent object");
this._domRequestCounter = 0;
this._promiseCounter = 0;
this._domRequestReady = false;
this._pendingAPICalls = [];
this._pendingDOMRequests = {};
this._nextPaintListeners = [];
this._pendingPromises = {};
this._pendingDOMFullscreen = false;
Services.obs.addObserver(this, 'oop-frameloader-crashed', /* ownsWeak = */ true);
@ -157,22 +156,13 @@ BrowserElementParent.prototype = {
"error": this._fireEventFromMsg,
"firstpaint": this._fireProfiledEventFromMsg,
"documentfirstpaint": this._fireProfiledEventFromMsg,
"nextpaint": this._recvNextPaint,
"got-purge-history": this._gotDOMRequestResult,
"got-screenshot": this._gotDOMRequestResult,
"got-contentdimensions": this._gotDOMRequestResult,
"got-can-go-back": this._gotDOMRequestResult,
"got-can-go-forward": this._gotDOMRequestResult,
"got-can-go-back": this._gotAsyncResult,
"got-can-go-forward": this._gotAsyncResult,
"requested-dom-fullscreen": this._requestedDOMFullscreen,
"fullscreen-origin-change": this._fullscreenOriginChange,
"exit-dom-fullscreen": this._exitDomFullscreen,
"got-visible": this._gotDOMRequestResult,
"got-set-input-method-active": this._gotDOMRequestResult,
"scrollviewchange": this._handleScrollViewChange,
"caretstatechanged": this._handleCaretStateChanged,
"findchange": this._handleFindChange,
"execute-script-done": this._gotDOMRequestResult,
"got-web-manifest": this._gotDOMRequestResult,
};
let mmSecuritySensitiveCalls = {
@ -185,7 +175,6 @@ BrowserElementParent.prototype = {
"scrollareachanged": this._fireEventFromMsg,
"titlechange": this._fireProfiledEventFromMsg,
"opensearch": this._fireEventFromMsg,
"manifestchange": this._fireEventFromMsg,
"metachange": this._fireEventFromMsg,
"resize": this._fireEventFromMsg,
"activitydone": this._fireEventFromMsg,
@ -435,12 +424,6 @@ BrowserElementParent.prototype = {
this._frameElement.dispatchEvent(evt);
},
_handleFindChange: function(data) {
let evt = this._createEvent("findchange", data.json,
/* cancelable = */ false);
this._frameElement.dispatchEvent(evt);
},
_createEvent: function(evtName, detail, cancelable) {
// This will have to change if we ever want to send a CustomEvent with null
// detail. For now, it's OK.
@ -458,29 +441,33 @@ BrowserElementParent.prototype = {
},
/**
* Kick off a DOMRequest in the child process.
* Kick off an async operation in the child process.
*
* We'll fire an event called |msgName| on the child process, passing along
* We'll send a message called |msgName| to the child process, passing along
* an object with two fields:
*
* - id: the ID of this request.
* - arg: arguments to pass to the child along with this request.
* - id: the ID of this async call.
* - arg: arguments to pass to the child along with this async call.
*
* We expect the child to pass the ID back to us upon completion of the
* request. See _gotDOMRequestResult.
* call. See _gotAsyncResult.
*/
_sendDOMRequest: function(msgName, args) {
let id = 'req_' + this._domRequestCounter++;
let req = Services.DOMRequest.createRequest(this._window);
_sendAsyncRequest: function(msgName, args) {
let id = 'req_' + this._promiseCounter++;
let resolve, reject;
let p = new this._window.Promise((res, rej) => {
resolve = res;
reject = rej;
});
let self = this;
let send = function() {
if (!self._isAlive()) {
return;
}
if (self._sendAsyncMsg(msgName, {id: id, args: args})) {
self._pendingDOMRequests[id] = req;
self._pendingPromises[id] = { p, resolve, reject };
} else {
Services.DOMRequest.fireErrorAsync(req, "fail");
reject(new this._window.DOMException("fail"));
}
};
if (this._domRequestReady) {
@ -489,35 +476,35 @@ BrowserElementParent.prototype = {
// Child haven't been loaded.
this._pendingAPICalls.push(send);
}
return req;
return p;
},
/**
* Called when the child process finishes handling a DOMRequest. data.json
* must have the fields [id, successRv], if the DOMRequest was successful, or
* [id, errorMsg], if the request was not successful.
* Called when the child process finishes handling an async call. data.json
* must have the fields [id, successRv], if the async call was successful, or
* [id, errorMsg], if the call was not successful.
*
* The fields have the following meanings:
*
* - id: the ID of the DOM request (see _sendDOMRequest)
* - successRv: the request's return value, if the request succeeded
* - errorMsg: the message to pass to DOMRequest.fireError(), if the request
* failed.
* - id: the ID of the async call (see _sendAsyncRequest)
* - successRv: the call's return value, if the call succeeded
* - errorMsg: the message to pass to the Promise reject callback, if the
* call failed.
*
*/
_gotDOMRequestResult: function(data) {
let req = this._pendingDOMRequests[data.json.id];
delete this._pendingDOMRequests[data.json.id];
_gotAsyncResult: function(data) {
let p = this._pendingPromises[data.json.id];
delete this._pendingPromises[data.json.id];
if ('successRv' in data.json) {
debug("Successful gotDOMRequestResult.");
debug("Successful gotAsyncResult.");
let clientObj = Cu.cloneInto(data.json.successRv, this._window);
Services.DOMRequest.fireSuccess(req, clientObj);
p.resolve(clientObj);
}
else {
debug("Got error in gotDOMRequestResult.");
Services.DOMRequest.fireErrorAsync(req,
Cu.cloneInto(data.json.errorMsg, this._window));
debug("Got error in gotAsyncResult.");
p.reject(new this._window.DOMException(
Cu.cloneInto(data.json.errorMsg, this._window)));
}
},
@ -549,51 +536,8 @@ BrowserElementParent.prototype = {
});
}),
sendTouchEvent: defineNoReturnMethod(function(type, identifiers, touchesX, touchesY,
radiisX, radiisY, rotationAngles, forces,
count, modifiers) {
let offset = this.getChildProcessOffset();
for (var i = 0; i < touchesX.length; i++) {
touchesX[i] += offset.x;
}
for (var i = 0; i < touchesY.length; i++) {
touchesY[i] += offset.y;
}
this._sendAsyncMsg("send-touch-event", {
"type": type,
"identifiers": identifiers,
"touchesX": touchesX,
"touchesY": touchesY,
"radiisX": radiisX,
"radiisY": radiisY,
"rotationAngles": rotationAngles,
"forces": forces,
"count": count,
"modifiers": modifiers
});
}),
getCanGoBack: defineDOMRequestMethod('get-can-go-back'),
getCanGoForward: defineDOMRequestMethod('get-can-go-forward'),
getContentDimensions: defineDOMRequestMethod('get-contentdimensions'),
findAll: defineNoReturnMethod(function(searchString, caseSensitivity) {
return this._sendAsyncMsg('find-all', {
searchString,
caseSensitive: caseSensitivity == Ci.nsIBrowserElementAPI.FIND_CASE_SENSITIVE
});
}),
findNext: defineNoReturnMethod(function(direction) {
return this._sendAsyncMsg('find-next', {
backward: direction == Ci.nsIBrowserElementAPI.FIND_BACKWARD
});
}),
clearMatch: defineNoReturnMethod(function() {
return this._sendAsyncMsg('clear-match');
}),
getCanGoBack: definePromiseMethod('get-can-go-back'),
getCanGoForward: definePromiseMethod('get-can-go-forward'),
goBack: defineNoReturnMethod(function() {
this._sendAsyncMsg('go-back');
@ -611,242 +555,6 @@ BrowserElementParent.prototype = {
this._sendAsyncMsg('stop');
}),
executeScript: function(script, options) {
if (!this._isAlive()) {
throw Components.Exception("Dead content process",
Cr.NS_ERROR_DOM_INVALID_STATE_ERR);
}
// Enforcing options.url or options.origin
if (!options.url && !options.origin) {
throw Components.Exception("Invalid argument", Cr.NS_ERROR_INVALID_ARG);
}
return this._sendDOMRequest('execute-script', {script, options});
},
/*
* The valid range of zoom scale is defined in preference "zoom.maxPercent" and "zoom.minPercent".
*/
zoom: defineNoReturnMethod(function(zoom) {
zoom *= 100;
zoom = Math.min(getIntPref("zoom.maxPercent", 300), zoom);
zoom = Math.max(getIntPref("zoom.minPercent", 50), zoom);
this._sendAsyncMsg('zoom', {zoom: zoom / 100.0});
}),
purgeHistory: defineDOMRequestMethod('purge-history'),
download: function(_url, _options) {
if (!this._isAlive()) {
return null;
}
let uri = Services.io.newURI(_url);
let url = uri.QueryInterface(Ci.nsIURL);
debug('original _options = ' + uneval(_options));
// Ensure we have _options, we always use it to send the filename.
_options = _options || {};
if (!_options.filename) {
_options.filename = url.fileName;
}
debug('final _options = ' + uneval(_options));
// Ensure we have a filename.
if (!_options.filename) {
throw Components.Exception("Invalid argument", Cr.NS_ERROR_INVALID_ARG);
}
let interfaceRequestor =
this._frameLoader.loadContext.QueryInterface(Ci.nsIInterfaceRequestor);
let req = Services.DOMRequest.createRequest(this._window);
function DownloadListener() {
debug('DownloadListener Constructor');
}
DownloadListener.prototype = {
extListener: null,
onStartRequest: function(aRequest, aContext) {
debug('DownloadListener - onStartRequest');
let extHelperAppSvc =
Cc['@mozilla.org/uriloader/external-helper-app-service;1'].
getService(Ci.nsIExternalHelperAppService);
let channel = aRequest.QueryInterface(Ci.nsIChannel);
// First, we'll ensure the filename doesn't have any leading
// periods. We have to do it here to avoid ending up with a filename
// that's only an extension with no extension (e.g. Sending in
// '.jpeg' without stripping the '.' would result in a filename of
// 'jpeg' where we want 'jpeg.jpeg'.
_options.filename = _options.filename.replace(/^\.+/, "");
let ext = null;
let mimeSvc = extHelperAppSvc.QueryInterface(Ci.nsIMIMEService);
try {
ext = '.' + mimeSvc.getPrimaryExtension(channel.contentType, '');
} catch (e) { ext = null; }
// Check if we need to add an extension to the filename.
if (ext && !_options.filename.endsWith(ext)) {
_options.filename += ext;
}
// Set the filename to use when saving to disk.
channel.contentDispositionFilename = _options.filename;
this.extListener =
extHelperAppSvc.doContent(
channel.contentType,
aRequest,
interfaceRequestor,
true);
this.extListener.onStartRequest(aRequest, aContext);
},
onStopRequest: function(aRequest, aContext, aStatusCode) {
debug('DownloadListener - onStopRequest (aStatusCode = ' +
aStatusCode + ')');
if (aStatusCode == Cr.NS_OK) {
// Everything looks great.
debug('DownloadListener - Download Successful.');
Services.DOMRequest.fireSuccess(req, aStatusCode);
}
else {
// In case of failure, we'll simply return the failure status code.
debug('DownloadListener - Download Failed!');
Services.DOMRequest.fireError(req, aStatusCode);
}
if (this.extListener) {
this.extListener.onStopRequest(aRequest, aContext, aStatusCode);
}
},
onDataAvailable: function(aRequest, aContext, aInputStream,
aOffset, aCount) {
this.extListener.onDataAvailable(aRequest, aContext, aInputStream,
aOffset, aCount);
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIStreamListener,
Ci.nsIRequestObserver])
};
let referrer = Services.io.newURI(_options.referrer);
let principal =
Services.scriptSecurityManager.createCodebasePrincipal(
referrer, this._frameLoader.loadContext.originAttributes);
let channel = NetUtil.newChannel({
uri: url,
loadingPrincipal: principal,
securityFlags: SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS,
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER
});
// XXX We would set private browsing information prior to calling this.
channel.notificationCallbacks = interfaceRequestor;
// Since we're downloading our own local copy we'll want to bypass the
// cache and local cache if the channel let's us specify this.
let flags = Ci.nsIChannel.LOAD_CALL_CONTENT_SNIFFERS |
Ci.nsIChannel.LOAD_BYPASS_CACHE;
if (channel instanceof Ci.nsICachingChannel) {
debug('This is a caching channel. Forcing bypass.');
flags |= Ci.nsICachingChannel.LOAD_BYPASS_LOCAL_CACHE_IF_BUSY;
}
channel.loadFlags |= flags;
if (channel instanceof Ci.nsIHttpChannel) {
debug('Setting HTTP referrer = ' + (referrer && referrer.spec));
channel.referrer = referrer;
if (channel instanceof Ci.nsIHttpChannelInternal) {
channel.forceAllowThirdPartyCookie = true;
}
}
// Set-up complete, let's get things started.
channel.asyncOpen2(new DownloadListener());
return req;
},
getScreenshot: function(_width, _height, _mimeType) {
if (!this._isAlive()) {
throw Components.Exception("Dead content process",
Cr.NS_ERROR_DOM_INVALID_STATE_ERR);
}
let width = parseInt(_width);
let height = parseInt(_height);
let mimeType = (typeof _mimeType === 'string') ?
_mimeType.trim().toLowerCase() : 'image/jpeg';
if (isNaN(width) || isNaN(height) || width < 0 || height < 0) {
throw Components.Exception("Invalid argument",
Cr.NS_ERROR_INVALID_ARG);
}
return this._sendDOMRequest('get-screenshot',
{width: width, height: height,
mimeType: mimeType});
},
_recvNextPaint: function(data) {
let listeners = this._nextPaintListeners;
this._nextPaintListeners = [];
for (let listener of listeners) {
try {
listener();
} catch (e) {
// If a listener throws we'll continue.
}
}
},
addNextPaintListener: function(listener) {
if (!this._isAlive()) {
throw Components.Exception("Dead content process",
Cr.NS_ERROR_DOM_INVALID_STATE_ERR);
}
let self = this;
let run = function() {
if (self._nextPaintListeners.push(listener) == 1)
self._sendAsyncMsg('activate-next-paint-listener');
};
if (!this._domRequestReady) {
this._pendingAPICalls.push(run);
} else {
run();
}
},
removeNextPaintListener: function(listener) {
if (!this._isAlive()) {
throw Components.Exception("Dead content process",
Cr.NS_ERROR_DOM_INVALID_STATE_ERR);
}
let self = this;
let run = function() {
for (let i = self._nextPaintListeners.length - 1; i >= 0; i--) {
if (self._nextPaintListeners[i] == listener) {
self._nextPaintListeners.splice(i, 1);
break;
}
}
if (self._nextPaintListeners.length == 0)
self._sendAsyncMsg('deactivate-next-paint-listener');
};
if (!this._domRequestReady) {
this._pendingAPICalls.push(run);
} else {
run();
}
},
getWebManifest: defineDOMRequestMethod('get-web-manifest'),
/**
* Called when the visibility of the window which owns this iframe changes.
*/

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

@ -32,20 +32,20 @@ function runTest() {
function checkCanGoBackAndForward(canGoBack, canGoForward, nextTest) {
var seenCanGoBackResult = false;
iframe.getCanGoBack().onsuccess = function(e) {
iframe.getCanGoBack().then(function(result) {
is(seenCanGoBackResult, false, "onsuccess handler shouldn't be called twice.");
seenCanGoBackResult = true;
is(e.target.result, canGoBack);
is(result, canGoBack);
maybeRunNextTest();
};
});
var seenCanGoForwardResult = false;
iframe.getCanGoForward().onsuccess = function(e) {
iframe.getCanGoForward().then(function(result) {
is(seenCanGoForwardResult, false, "onsuccess handler shouldn't be called twice.");
seenCanGoForwardResult = true;
is(e.target.result, canGoForward);
is(result, canGoForward);
maybeRunNextTest();
};
});
function maybeRunNextTest() {
if (seenCanGoBackResult && seenCanGoForwardResult) {

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

@ -1,71 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 800170 - Test that we get errors when we pass bad arguments to
// mozbrowser's getScreenshot.
"use strict";
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
var iframe;
var numPendingTests = 0;
// Call iframe.getScreenshot with the given args. If expectSuccess is true, we
// expect the screenshot's onsuccess handler to fire. Otherwise, we expect
// getScreenshot() to throw an exception.
function checkScreenshotResult(expectSuccess, args) {
var req;
try {
req = iframe.getScreenshot.apply(iframe, args);
}
catch(e) {
ok(!expectSuccess, "getScreenshot(" + JSON.stringify(args) + ") threw an exception.");
return;
}
numPendingTests++;
req.onsuccess = function() {
ok(expectSuccess, "getScreenshot(" + JSON.stringify(args) + ") succeeded.");
numPendingTests--;
if (numPendingTests == 0) {
SimpleTest.finish();
}
};
// We never expect to see onerror.
req.onerror = function() {
ok(false, "getScreenshot(" + JSON.stringify(args) + ") ran onerror.");
numPendingTests--;
if (numPendingTests == 0) {
SimpleTest.finish();
}
};
}
function runTest() {
iframe = document.createElement('iframe');
iframe.setAttribute('mozbrowser', 'true');
document.body.appendChild(iframe);
iframe.src = 'data:text/html,<html>' +
'<body style="background:green">hello</body></html>';
iframe.addEventListener('mozbrowserfirstpaint', function() {
// This one should succeed.
checkScreenshotResult(true, [100, 100]);
// These should fail.
checkScreenshotResult(false, []);
checkScreenshotResult(false, [100]);
checkScreenshotResult(false, ['a', 100]);
checkScreenshotResult(false, [100, 'a']);
checkScreenshotResult(false, [-1, 100]);
checkScreenshotResult(false, [100, -1]);
if (numPendingTests == 0) {
SimpleTest.finish();
}
});
}
addEventListener('testready', runTest);

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

@ -1,62 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Test if DOMRequest returned by an iframe gets an error callback when
// the iframe is not in the DOM.
"use strict";
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
function runTest() {
var iframe1 = document.createElement('iframe');
iframe1.setAttribute('mozbrowser', 'true');
iframe1.src = 'data:text/html,<html>' +
'<body style="background:green">hello</body></html>';
document.body.appendChild(iframe1);
function testIframe(beforeRun, isErrorExpected, nextTest) {
return function() {
var error = false;
if (beforeRun)
beforeRun();
function testEnd() {
is(isErrorExpected, error);
SimpleTest.executeSoon(nextTest);
}
var domRequest = iframe1.getScreenshot(1000, 1000);
domRequest.onsuccess = function(e) {
testEnd();
}
domRequest.onerror = function(e) {
error = true;
testEnd();
}
};
}
function iframeLoadedHandler() {
iframe1.removeEventListener('mozbrowserloadend', iframeLoadedHandler);
// Test 1: iframe is in the DOM.
// Test 2: iframe is removed from the DOM.
// Test 3: iframe is added back into the DOM.
var test3 = testIframe(
function() {
document.body.appendChild(iframe1);
}, false,
function() {
SimpleTest.finish();
})
;
var test2 = testIframe(function() {
document.body.removeChild(iframe1);
}, true, test3);
var test1 = testIframe(null, false, test2);
SimpleTest.executeSoon(test1);
}
iframe1.addEventListener('mozbrowserloadend', iframeLoadedHandler);
}
addEventListener('testready', runTest);

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

@ -1,37 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 983747 - Test 'download' method on iframe.
"use strict";
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addPermission();
var iframe;
var downloadURL = 'http://test/tests/dom/browser-element/mochitest/file_download_bin.sjs';
function runTest() {
iframe = document.createElement('iframe');
iframe.setAttribute('mozbrowser', 'true');
iframe.addEventListener('mozbrowserloadend', loadend);
iframe.src = 'data:text/html,<html><body>hello</body></html>';
iframe.setAttribute('remote', 'true');
document.body.appendChild(iframe);
}
function loadend() {
var req = iframe.download(downloadURL, { filename: 'test.bin' });
req.onsuccess = function() {
ok(true, 'Download finished as expected.');
SimpleTest.finish();
}
req.onerror = function() {
ok(false, 'Expected no error, got ' + req.error);
}
}
addEventListener('testready', runTest);

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

@ -1,118 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 1174733 - Browser API: iframe.executeScript
'use strict';
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
function runTest() {
const origin = 'http://example.org';
const url = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_ExecuteScript.html';
// Test if all key=>value pairs in o1 are present in o2.
const c = (o1, o2) => Object.keys(o1).every(k => o1[k] == o2[k]);
let scriptId = 0;
const bail = () => {
ok(false, `scriptId: ${scriptId++}`);
}
SpecialPowers.pushPermissions([
{type: 'browser', allow: 1, context: document},
{type: 'browser:universalxss', allow: 1, context: document}
], function() {
let iframe = document.createElement('iframe');
iframe.setAttribute('mozbrowser', 'true');
iframe.addEventListener('mozbrowserloadend', function() {
onReady(iframe);
}, {once: true});
iframe.src = url;
document.body.appendChild(iframe);
});
function onReady(iframe) {
iframe.executeScript('4 + 4', {url}).then(rv => {
is(rv, 8, `scriptId: ${scriptId++}`);
return iframe.executeScript('(() => {return {a:42}})()', {url})
}, bail).then(rv => {
ok(c(rv, {a:42}), `scriptId: ${scriptId++}`);
return iframe.executeScript('(() => {return {a:42}})()', {origin})
}, bail).then(rv => {
ok(c(rv, {a:42}), `scriptId: ${scriptId++}`);
return iframe.executeScript('(() => {return {a:42}})()', {origin, url})
}, bail).then(rv => {
ok(c(rv, {a:42}), `scriptId: ${scriptId++}`);
return iframe.executeScript(`
new Promise((resolve, reject) => {
resolve(document.body.textContent.trim());
});
`, {url})
}, bail).then(rv => {
is(rv, 'foo', `scriptId: ${scriptId++}`);
return iframe.executeScript(`
new Promise((resolve, reject) => {
resolve({a:43,b:34});
});
`, {url})
}, bail).then(rv => {
ok(c(rv, {a:43,b:34}), `scriptId: ${scriptId++}`);
return iframe.executeScript(`
syntax error
`, {url});
}, bail).then(bail, (error) => {
is(error.message, 'SyntaxError: illegal character', `scriptId: ${scriptId++}`);
return iframe.executeScript(`
window
`, {url});
}).then(bail, (error) => {
is(error.message, 'Script last expression must be a promise or a JSON object', `scriptId: ${scriptId++}`);
return iframe.executeScript(`
new Promise((resolve, reject) => {
reject('BOOM');
});
`, {url});
}).then(bail, (error) => {
is(error.message, 'BOOM', `scriptId: ${scriptId++}`);
return iframe.executeScript(`
new Promise((resolve, reject) => {
resolve(window);
});
`, {url});
}).then(bail, (error) => {
is(error.message, 'Value returned (resolve) by promise is not a valid JSON object', `scriptId: ${scriptId++}`);
return iframe.executeScript('window.btoa("a")', {url})
}, bail).then(rv => {
ok(c(rv, 'YQ=='), `scriptId: ${scriptId++}`);
return iframe.executeScript('window.wrappedJSObject.btoa("a")', {url})
}, bail).then(bail, (error) => {
is(error.message, `TypeError: window.wrappedJSObject is undefined; can't access its "btoa" property`, `scriptId: ${scriptId++}`);
return iframe.executeScript('42', {})
}).then(bail, error => {
is(error.name, 'InvalidAccessError', `scriptId: ${scriptId++}`);
return iframe.executeScript('42');
}).then(bail, error => {
is(error.name, 'InvalidAccessError', `scriptId: ${scriptId++}`);
return iframe.executeScript('43', { url: 'http://foo.com' });
}).then(bail, (error) => {
is(error.message, 'URL mismatches', `scriptId: ${scriptId++}`);
return iframe.executeScript('43', { url: '_' });
}, bail).then(bail, (error) => {
is(error.message, 'Malformed URL', `scriptId: ${scriptId++}`);
return iframe.executeScript('43', { origin: 'http://foo.com' });
}, bail).then(bail, (error) => {
is(error.message, 'Origin mismatches', `scriptId: ${scriptId++}`);
return iframe.executeScript('43', { origin: 'https://example.org' });
}, bail).then(bail, (error) => {
is(error.message, 'Origin mismatches', `scriptId: ${scriptId++}`);
SimpleTest.finish();
});
}
}
addEventListener('testready', runTest);

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

@ -1,148 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 1163961 - Test search API
"use strict";
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
function runTest() {
let iframe = document.createElement('iframe');
iframe.setAttribute('mozbrowser', 'true');
iframe.src = 'data:text/html,foo bar foo XXX Foo BAR foobar foobar';
const once = (eventName) => {
return new Promise((resolve) => {
iframe.addEventListener(eventName, function(...args) {
resolve(...args);
}, {once: true});
});
}
// Test if all key=>value pairs in o1 are present in o2.
const c = (o1, o2, i) => {
for (let k of Object.keys(o1)) {
is(o1[k], o2[k], `Test ${i} should match for key ${k}`);
}
}
let testCount = 0;
once('mozbrowserloadend').then(() => {
iframe.findAll('foo', 'case-insensitive');
return once('mozbrowserfindchange');
}).then(({detail}) => {
c(detail, {
msg_name: "findchange",
active: true,
searchString: 'foo',
searchLimit: 1000,
activeMatchOrdinal: 1,
numberOfMatches: 5,
}, testCount++);
iframe.findNext('forward');
return once('mozbrowserfindchange');
}).then(({detail}) => {
c(detail, {
msg_name: "findchange",
active: true,
searchString: 'foo',
searchLimit: 1000,
activeMatchOrdinal: 2,
numberOfMatches: 5,
}, testCount++);
iframe.findNext('backward');
return once('mozbrowserfindchange');
}).then(({detail}) => {
c(detail, {
msg_name: "findchange",
active: true,
searchString: 'foo',
searchLimit: 1000,
activeMatchOrdinal: 1,
numberOfMatches: 5,
}, testCount++);
iframe.findAll('xxx', 'case-sensitive');
return once('mozbrowserfindchange');
}).then(({detail}) => {
c(detail, {
msg_name: "findchange",
active: true,
searchString: 'xxx',
searchLimit: 1000,
activeMatchOrdinal: 0,
numberOfMatches: 0,
}, testCount++);
iframe.findAll('bar', 'case-insensitive');
return once('mozbrowserfindchange');
}).then(({detail}) => {
c(detail, {
msg_name: "findchange",
active: true,
searchString: 'bar',
searchLimit: 1000,
activeMatchOrdinal: 1,
numberOfMatches: 4,
}, testCount++);
iframe.findNext('forward');
return once('mozbrowserfindchange');
}).then(({detail}) => {
c(detail, {
msg_name: "findchange",
active: true,
searchString: 'bar',
searchLimit: 1000,
activeMatchOrdinal: 2,
numberOfMatches: 4,
}, testCount++);
iframe.findNext('forward');
return once('mozbrowserfindchange');
}).then(({detail}) => {
c(detail, {
msg_name: "findchange",
active: true,
searchString: 'bar',
searchLimit: 1000,
activeMatchOrdinal: 3,
numberOfMatches: 4,
}, testCount++);
iframe.findNext('forward');
return once('mozbrowserfindchange');
}).then(({detail}) => {
c(detail, {
msg_name: "findchange",
active: true,
searchString: 'bar',
searchLimit: 1000,
activeMatchOrdinal: 4,
numberOfMatches: 4,
}, testCount++);
iframe.findNext('forward');
return once('mozbrowserfindchange');
}).then(({detail}) => {
c(detail, {
msg_name: "findchange",
active: true,
searchString: 'bar',
searchLimit: 1000,
activeMatchOrdinal: 1,
numberOfMatches: 4,
}, testCount++);
iframe.clearMatch();
return once('mozbrowserfindchange');
}).then(({detail}) => {
c(detail, {
msg_name: "findchange",
active: false
}, testCount++);
SimpleTest.finish();
});
document.body.appendChild(iframe);
}
addEventListener('testready', runTest);

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

@ -1,66 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 757859 - Test the getContentDimensions functionality of mozbrowser
"use strict";
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
var resizeContent = function() {
var innerBox = content.document.getElementById('abox');
innerBox.style.width = '800px';
innerBox.style.height = '800px';
}
function runTest() {
var iframe1 = document.createElement('iframe');
iframe1.setAttribute('mozbrowser', 'true');
var iframeWidth = 400;
var iframeHeight = 400;
var numIframeLoaded = 0;
var numResizeEvents = 0;
var mm;
iframe1.src = 'data:text/html,<html><body><div id=\'abox\' ' +
'style=\'background:blue;width:200px;height:200px\'>test</div></body></html>';
iframe1.style.width = iframeWidth + 'px';
iframe1.style.height = iframeHeight + 'px';
document.body.appendChild(iframe1);
function iframeScrollAreaChanged(e) {
numResizeEvents++;
if (numResizeEvents === 1) {
ok(true, 'Resize event when changing content size');
ok(e.detail.width > iframeWidth, 'Iframes content is larger than iframe');
ok(e.detail.height > iframeHeight, 'Iframes content is larger than iframe');
iframe1.src = 'data:text/html,<html><body><div id=\'abox\' ' +
'style=\'background:blue;width:200px;height:200px\'>test</div></body></html>';
} else if (numResizeEvents === 2) {
ok(true, 'Resize event when changing src');
iframe1.removeEventListener('mozbrowserresize', iframeScrollAreaChanged);
SimpleTest.finish();
}
}
function iframeLoadedHandler() {
iframe1.removeEventListener('mozbrowserloadend', iframeLoadedHandler);
mm = SpecialPowers.getBrowserFrameMessageManager(iframe1);
iframe1.getContentDimensions().onsuccess = function(e) {
ok(typeof e.target.result.width === 'number', 'Received width');
ok(typeof e.target.result.height === 'number', 'Received height');
ok(e.target.result.height <= iframeHeight, 'Iframes content is smaller than iframe');
ok(e.target.result.width <= iframeWidth, 'Iframes content is smaller than iframe');
iframe1.addEventListener('mozbrowserscrollareachanged', iframeScrollAreaChanged);
mm.loadFrameScript('data:,(' + resizeContent.toString() + ')();', false);
}
}
iframe1.addEventListener('mozbrowserloadend', iframeLoadedHandler);
}
addEventListener('load', function() {
SimpleTest.executeSoon(runTest);
});

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

@ -1,117 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Test the getScreenshot property for mozbrowser
"use strict";
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
function runTest() {
var iframe1 = document.createElement('iframe');
iframe1.setAttribute('mozbrowser', 'true');
iframe1.src = 'data:text/html,<html>' +
'<body style="background:green">hello</body></html>';
document.body.appendChild(iframe1);
var screenshotImageDatas = [];
function screenshotTaken(aScreenshotImageData) {
screenshotImageDatas.push(aScreenshotImageData);
if (screenshotImageDatas.length === 1) {
ok(true, 'Got initial non blank screenshot');
var view = aScreenshotImageData.data;
if (view[3] !== 255) {
ok(false, 'The first pixel of initial screenshot is not opaque');
SimpleTest.finish();
return;
}
ok(true, 'Verified the first pixel of initial screenshot is opaque');
iframe1.src = 'data:text/html,<html>' +
'<body style="background:transparent">hello</body></html>';
iframe1.addEventListener('mozbrowserloadend', ()=>takeScreenshot('image/png'));
}
else if (screenshotImageDatas.length === 2) {
ok(true, 'Got updated screenshot after source page changed');
var view = aScreenshotImageData.data;
if (view[3] !== 0) {
// The case here will always fail when oop'd on Firefox Desktop,
// but not on B2G Emulator
// See https://bugzil.la/878003#c20
var isB2G = (navigator.platform === '');
info('navigator.platform: ' + navigator.platform);
if (!isB2G && browserElementTestHelpers.getOOPByDefaultPref()) {
todo(false, 'The first pixel of updated screenshot is not transparent');
} else {
ok(false, 'The first pixel of updated screenshot is not transparent');
}
SimpleTest.finish();
return;
}
ok(true, 'Verified the first pixel of updated screenshot is transparent');
SimpleTest.finish();
}
}
// We continually take screenshots until we get one that we are
// happy with.
function takeScreenshot(mimeType) {
function gotImage(e) {
// |this| is the Image.
URL.revokeObjectURL(this.src);
if (e.type === 'error' || !this.width || !this.height) {
ok(false, "load image error");
SimpleTest.finish();
return;
}
var canvas = document.createElement('canvas');
canvas.width = canvas.height = 1000;
var ctx = canvas.getContext('2d');
ctx.drawImage(this, 0, 0);
var imageData = ctx.getImageData(0, 0, 1000, 1000);
screenshotTaken(imageData);
}
function getScreenshotImageData(e) {
var blob = e.target.result;
if (blob.type !== mimeType) {
ok(false, 'MIME type of screenshot taken incorrect');
SimpleTest.finish();
}
if (blob.size === 0) {
ok(false, "get screenshot image error");
SimpleTest.finish();
}
var img = new Image();
img.src = URL.createObjectURL(blob);
img.onload = img.onerror = gotImage;
}
iframe1.getScreenshot(1000, 1000, mimeType).onsuccess =
getScreenshotImageData;
}
function iframeLoadedHandler(e) {
iframe1.removeEventListener('mozbrowserloadend', iframeLoadedHandler);
takeScreenshot('image/jpeg');
}
iframe1.addEventListener('mozbrowserloadend', iframeLoadedHandler);
}
addEventListener('testready', runTest);

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

@ -1,107 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Test the getScreenshot property for mozbrowser
"use strict";
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
function runTest() {
var dppxPref = 'layout.css.devPixelsPerPx';
var cssPixelWidth = 600;
var cssPixelHeight = 400;
var iframe1 = document.createElement('iframe');
iframe1.setAttribute('width', cssPixelWidth);
iframe1.setAttribute('height', cssPixelHeight);
iframe1.setAttribute('mozbrowser', 'true');
iframe1.src = 'data:text/html,<html><body>hello</body></html>';
document.body.appendChild(iframe1);
var images = [];
function screenshotTaken(image) {
images.push(image);
if (images.length === 1) {
ok(true, 'Got initial non blank screenshot');
if (image.width !== cssPixelWidth || image.height !== cssPixelHeight) {
ok(false, 'The pixel width of the image received is not correct');
SimpleTest.finish();
return;
}
ok(true, 'The pixel width of the image received is correct');
SpecialPowers.pushPrefEnv(
{'set': [['layout.css.devPixelsPerPx', 2]]}, takeScreenshot);
}
else if (images.length === 2) {
ok(true, 'Got updated screenshot after source page changed');
if (image.width !== cssPixelWidth * 2 ||
image.height !== cssPixelHeight * 2) {
ok(false, 'The pixel width of the 2dppx image received is not correct');
SimpleTest.finish();
return;
}
ok(true, 'The pixel width of the 2dppx image received is correct');
SimpleTest.finish();
}
}
function takeScreenshot() {
function gotImage(e) {
// |this| is the Image.
URL.revokeObjectURL(this.src);
if (e.type === 'error' || !this.width || !this.height) {
tryAgain();
return;
}
screenshotTaken(this);
}
function tryAgain() {
if (--attempts === 0) {
ok(false, 'Timed out waiting for correct screenshot');
SimpleTest.finish();
} else {
setTimeout(function() {
iframe1.getScreenshot(cssPixelWidth, cssPixelHeight).onsuccess =
getScreenshotImageData;
}, 200);
}
}
function getScreenshotImageData(e) {
var blob = e.target.result;
if (blob.size === 0) {
tryAgain();
return;
}
var img = new Image();
img.src = URL.createObjectURL(blob);
img.onload = img.onerror = gotImage;
}
var attempts = 10;
iframe1.getScreenshot(cssPixelWidth, cssPixelHeight).onsuccess =
getScreenshotImageData;
}
function iframeLoadedHandler() {
SpecialPowers.pushPrefEnv(
{'set': [['layout.css.devPixelsPerPx', 1]]}, takeScreenshot);
}
iframe1.addEventListener('mozbrowserloadend', iframeLoadedHandler);
}
addEventListener('testready', runTest);

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

@ -1,97 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Test that the onmozbrowsermanifestchange event works.
"use strict";
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addPermission();
browserElementTestHelpers.allowTopLevelDataURINavigation();
function createHtml(manifest) {
return 'data:text/html,<html xmlns:xml="http://www.w3.org/XML/1998/namespace"><head>' + manifest + '<body></body></html>';
}
function createManifest(href) {
return '<link rel="manifest" href="' + href + '">';
}
function runTest() {
var iframe1 = document.createElement('iframe');
iframe1.setAttribute('mozbrowser', 'true');
document.body.appendChild(iframe1);
// iframe2 is a red herring; we modify its manifest link elements but don't
// listen for manifestchanges; we want to make sure that its manifestchange
// events aren't picked up by the listener on iframe1.
var iframe2 = document.createElement('iframe');
iframe2.setAttribute('mozbrowser', 'true');
document.body.appendChild(iframe2);
// iframe3 is another red herring. It's not a mozbrowser, so we shouldn't
// get any manifestchange events on it.
var iframe3 = document.createElement('iframe');
document.body.appendChild(iframe3);
var numManifestChanges = 0;
iframe1.addEventListener('mozbrowsermanifestchange', function(e) {
numManifestChanges++;
if (numManifestChanges == 1) {
is(e.detail.href, 'manifest.1', 'manifest.1 matches');
// We should receive manifestchange events when the user creates new
// manifests
SpecialPowers.getBrowserFrameMessageManager(iframe1)
.loadFrameScript("data:,content.document.title='New title';",
/* allowDelayedLoad = */ false);
SpecialPowers.getBrowserFrameMessageManager(iframe1)
.loadFrameScript("data:,content.document.head.insertAdjacentHTML('beforeend', '<link rel=manifest href=manifest.2>')",
/* allowDelayedLoad = */ false);
SpecialPowers.getBrowserFrameMessageManager(iframe2)
.loadFrameScript("data:,content.document.head.insertAdjacentHTML('beforeend', '<link rel=manifest href=manifest.2>')",
/* allowDelayedLoad = */ false);
}
else if (numManifestChanges == 2) {
is(e.detail.href, 'manifest.2', 'manifest.2 matches');
// Full new pages should trigger manifestchange events
iframe1.src = createHtml(createManifest('manifest.3'));
}
else if (numManifestChanges == 3) {
is(e.detail.href, 'manifest.3', 'manifest.3 matches');
// Test setting a page with multiple manifest link elements
iframe1.src = createHtml(createManifest('manifest.4a') + createManifest('manifest.4b'));
}
else if (numManifestChanges == 4) {
is(e.detail.href, 'manifest.4a', 'manifest.4a matches');
// 2 events will be triggered by previous test, wait for next
}
else if (numManifestChanges == 5) {
is(e.detail.href, 'manifest.4b', 'manifest.4b matches');
SimpleTest.finish();
} else {
ok(false, 'Too many manifestchange events.');
}
});
iframe3.addEventListener('mozbrowsermanifestchange', function(e) {
ok(false, 'Should not get a manifestchange event for iframe3.');
});
iframe1.src = createHtml(createManifest('manifest.1'));
// We should not receive manifest change events for either of the below iframes
iframe2.src = createHtml(createManifest('manifest.1'));
iframe3.src = createHtml(createManifest('manifest.1'));
}
addEventListener('testready', runTest);

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

@ -1,43 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 808231 - Add mozbrowsernextpaint event.
"use strict";
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
function runTest() {
var iframe = document.createElement('iframe');
iframe.setAttribute('mozbrowser', 'true');
document.body.appendChild(iframe);
// Add a first listener that we'll remove shortly after.
iframe.addNextPaintListener(wrongListener);
var gotFirstNextPaintEvent = false;
iframe.addNextPaintListener(function () {
ok(!gotFirstNextPaintEvent, 'got the first nextpaint event');
// Make sure we're only called once.
gotFirstNextPaintEvent = true;
iframe.addNextPaintListener(function () {
info('got the second nextpaint event');
SimpleTest.finish();
});
// Force the iframe to repaint.
SimpleTest.executeSoon(() => iframe.src += '#next');
});
// Remove the first listener to make sure it's not called.
iframe.removeNextPaintListener(wrongListener);
iframe.src = 'file_browserElement_NextPaint.html';
}
function wrongListener() {
ok(false, 'first listener should have been removed');
}
addEventListener('testready', runTest);

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

@ -1,105 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 776129 - If a window w calls window.open, the resultant window should be
// remote iff w is remote.
//
// <iframe mozbrowser> can be default-OOP or default-in-process. But we can
// override this default by setting remote=true or remote=false on the iframe.
//
// This bug arises when we are default-in-process and a OOP iframe calls
// window.open, or when we're default-OOP and an in-process iframe calls
// window.open. In either case, if the opened iframe gets the default
// remotness, it will not match its opener's remoteness, which is bad.
//
// Since the name of the test determines the OOP-by-default pref, the "inproc"
// version of this test opens an OOP frame, and the "oop" version opens an
// in-process frame. Enjoy. :)
"use strict";
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
function runTest() {
// We're going to open a remote frame if OOP off by default. If OOP is on by
// default, we're going to open an in-process frame.
var remote = !browserElementTestHelpers.getOOPByDefaultPref();
var iframe = document.createElement('iframe');
iframe.setAttribute('mozbrowser', 'true');
iframe.setAttribute('remote', remote);
// The page we load does window.open, then checks some things and reports
// back using alert(). Finally, it calls alert('finish').
//
// Bug 776129 in particular manifests itself such that the popup frame loads
// and the tests in file_browserElement_OpenMixedProcess pass, but the
// content of the frame is invisible. To catch this case, we take a
// screenshot after we load the content into the popup, and ensure that it's
// not blank.
var popup;
iframe.addEventListener('mozbrowseropenwindow', function(e) {
popup = document.body.appendChild(e.detail.frameElement);
});
iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
if (e.detail.message.startsWith('pass')) {
ok(true, e.detail.message);
}
else if (e.detail.message.startsWith('fail')) {
ok(false, e.detail.message);
}
else if (e.detail.message == 'finish') {
// We assume here that iframe is completely blank, and spin until popup's
// screenshot is not the same as iframe.
iframe.getScreenshot(1000, 1000).onsuccess = function(e) {
var fr = new FileReader();
fr.onloadend = function() { test2(popup, fr.result); };
fr.readAsArrayBuffer(e.target.result);
};
}
else {
ok(false, e.detail.message, "Unexpected message!");
}
});
document.body.appendChild(iframe);
iframe.src = 'file_browserElement_OpenMixedProcess.html';
}
function arrayBuffersEqual(a, b) {
var x = new Int8Array(a);
var y = new Int8Array(b);
if (x.length != y.length) {
return false;
}
for (var i = 0; i < x.length; i++) {
if (x[i] != y[i]) {
return false;
}
}
return true;
}
function test2(popup, blankScreenshotArrayBuffer) {
// Take screenshots of popup until it doesn't equal blankScreenshot (or we
// time out).
popup.getScreenshot(1000, 1000).onsuccess = function(e) {
var fr = new FileReader();
fr.onloadend = function() {
if (!arrayBuffersEqual(blankScreenshotArrayBuffer, fr.result)) {
ok(true, "Finally got a non-blank screenshot.");
SimpleTest.finish();
return;
}
SimpleTest.executeSoon(function() { test2(popup, blankScreenshot) });
};
fr.readAsArrayBuffer(e.target.result);
};
}
addEventListener('testready', runTest);

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

@ -1,87 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 807056 - [Browser] Clear History doesn't clear back/forward history in open tabs
// <iframe mozbrowser>.
"use strict";
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
var iframe;
function addOneShotIframeEventListener(event, fn) {
function wrapper(e) {
iframe.removeEventListener(event, wrapper);
fn(e);
};
iframe.addEventListener(event, wrapper);
}
function runTest() {
iframe = document.createElement('iframe');
iframe.setAttribute('mozbrowser', 'true');
// FIXME: Bug 1270790
iframe.setAttribute('remote', 'true');
addOneShotIframeEventListener('mozbrowserloadend', function() {
SimpleTest.executeSoon(test2);
});
iframe.src = browserElementTestHelpers.emptyPage1;
document.body.appendChild(iframe);
}
function purgeHistory(nextTest) {
var seenCanGoBackResult = false;
var seenCanGoForwardResult = false;
iframe.purgeHistory().onsuccess = function(e) {
ok(true, "The history has been purged");
iframe.getCanGoBack().onsuccess = function(e) {
is(e.target.result, false, "Iframe cannot go back");
seenCanGoBackResult = true;
maybeRunNextTest();
};
iframe.getCanGoForward().onsuccess = function(e) {
is(e.target.result, false, "Iframe cannot go forward");
seenCanGoForwardResult = true;
maybeRunNextTest();
};
};
function maybeRunNextTest() {
if (seenCanGoBackResult && seenCanGoForwardResult) {
nextTest();
}
}
}
function test2() {
purgeHistory(test3);
}
function test3() {
addOneShotIframeEventListener('mozbrowserloadend', function() {
purgeHistory(test4);
});
SimpleTest.executeSoon(function() {
iframe.src = browserElementTestHelpers.emptyPage2;
});
}
function test4() {
addOneShotIframeEventListener('mozbrowserlocationchange', function(e) {
is(e.detail.url, browserElementTestHelpers.emptyPage3);
purgeHistory(SimpleTest.finish);
});
SimpleTest.executeSoon(function() {
iframe.src = browserElementTestHelpers.emptyPage3;
});
}
addEventListener('testready', runTest);

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

@ -51,27 +51,6 @@ function runTest() {
break;
case "#click":
ok(true, "Receive a click event.");
if (SpecialPowers.getIntPref("dom.w3c_touch_events.enabled") != 0) {
iframe.sendTouchEvent("touchstart", [1], [x], [y], [2], [2],
[20], [0.5], 1, 0);
} else {
iframe.removeEventListener('mozbrowserlocationchange', onlocchange);
SimpleTest.finish();
}
break;
case "#touchstart":
ok(true, "Receive a touchstart event.");
iframe.sendTouchEvent("touchmove", [1], [x], [y], [2], [2],
[20], [0.5], 1, 0);
case "#touchmove":
ok(true, "Receive a touchmove event.");
iframe.sendTouchEvent("touchend", [1], [x], [y], [2], [2],
[20], [0.5], 1, 0);
break;
case "#touchend":
ok(true, "Receive a touchend event.");
iframe.sendTouchEvent("touchcancel", [1], [x], [y], [2], [2],
[20], [0.5], 1, 0);
iframe.removeEventListener('mozbrowserlocationchange', onlocchange);
SimpleTest.finish();
break;

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

@ -1,63 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/*globals async, ok, is, SimpleTest, browserElementTestHelpers*/
// Bug 1169633 - getWebManifest tests
'use strict';
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
// request to load a manifest from a page that doesn't have a manifest.
// The expected result to be null.
var test1 = async(async function() {
var manifest = await requestManifest('file_empty.html');
is(manifest, null, 'it should be null.');
});
// request to load a manifest from a page that has a manifest.
// The expected manifest to have a property name whose value is 'pass'.
var test2 = async(async function() {
var manifest = await requestManifest('file_web_manifest.html');
is(manifest && manifest.name, 'pass', 'it should return a manifest with name pass.');
});
// Cause an exception by attempting to fetch a file URL,
// expect onerror to be called.
var test3 = async(async function() {
var gotError = false;
try {
await requestManifest('file_illegal_web_manifest.html');
} catch (err) {
gotError = true;
}
ok(gotError, 'onerror was called on the DOMRequest.');
});
// Run the tests
addEventListener('testready', () => {
Promise
.all([test1(), test2(), test3()])
.then(SimpleTest.finish);
});
function requestManifest(url) {
var iframe = document.createElement('iframe');
iframe.setAttribute('mozbrowser', 'true');
iframe.src = url;
document.body.appendChild(iframe);
return new Promise((resolve, reject) => {
iframe.addEventListener('mozbrowserloadend', function() {
SimpleTest.executeSoon(() => {
var req = iframe.getWebManifest();
req.onsuccess = () => {
document.body.removeChild(iframe);
resolve(req.result);
};
req.onerror = () => {
document.body.removeChild(iframe);
reject(new Error(req.error));
};
});
}, {once: true});
});
}

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

@ -6,43 +6,17 @@ support-files =
async.js
browserElementTestHelpers.js
browserElement_BackForward.js
browserElement_BadScreenshot.js
browserElement_DocumentFirstPaint.js
browserElement_DOMRequestError.js
browserElement_ExecuteScript.js
browserElement_Find.js
browserElement_GetContentDimensions.js
browserElement_GetScreenshot.js
browserElement_GetScreenshotDppx.js
browserElement_getWebManifest.js
browserElement_NextPaint.js
browserElement_PurgeHistory.js
browserElement_ReloadPostRequest.js
browserElement_SendEvent.js
browserElement_Stop.js
file_browserElement_ExecuteScript.html
file_browserElement_NextPaint.html
file_browserElement_SendEvent.html
file_bug709759.sjs
file_empty.html
file_post_request.html
file_web_manifest.html
file_web_manifest.json
file_illegal_web_manifest.html
[test_browserElement_inproc_BackForward.html]
[test_browserElement_inproc_BadScreenshot.html]
[test_browserElement_inproc_DocumentFirstPaint.html]
[test_browserElement_inproc_DOMRequestError.html]
[test_browserElement_inproc_ExecuteScript.html]
[test_browserElement_inproc_Find.html]
disabled = Bug 1458393
[test_browserElement_inproc_GetContentDimensions.html]
[test_browserElement_inproc_GetScreenshot.html]
[test_browserElement_inproc_GetScreenshotDppx.html]
[test_browserElement_inproc_getWebManifest.html]
[test_browserElement_inproc_NextPaint.html]
[test_browserElement_inproc_PurgeHistory.html]
[test_browserElement_inproc_ReloadPostRequest.html]
disabled = no modal prompt on POST reload for chrome window
[test_browserElement_inproc_SendEvent.html]

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

@ -1,8 +0,0 @@
<html>
<head>
<script>
window.btoa = () => "fake btoa";
</script>
</head>
<body>foo</body>
</html>

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

@ -1,9 +0,0 @@
<html>
<body>
<script>
addEventListener("hashchange", function () {
document.body.style.backgroundColor = "red";
});
</script>
</body>
</html>

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

@ -1,22 +0,0 @@
<html>
<body>
<!-- The test relies on the fact that this file is completely empty. -->
<script>
function ok(b, msg)
{
alert((b ? 'pass:' : 'fail:') + msg);
}
var w = window.open("file_empty.html");
w.addEventListener('load', function() {
ok(true, 'Got load.');
ok(w.document.getElementById('url'), 'Found element with id "url"');
alert('finish');
});
</script>
</body>
</html>

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

@ -1,5 +1,5 @@
<html><body>
<button>send[Mouse|Touch]Event</button>
<button>sendMouseEvent</button>
</body><script>
function changeHash(e) {
document.location.hash = e.type;
@ -8,8 +8,4 @@ window.addEventListener('mousedown', changeHash);
window.addEventListener('mousemove', changeHash);
window.addEventListener('mouseup', changeHash);
window.addEventListener('click', changeHash, true);
window.addEventListener('touchstart', changeHash);
window.addEventListener('touchmove', changeHash);
window.addEventListener('touchend', changeHash);
window.addEventListener('touchcancel', changeHash);
</script></html>

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

@ -1,4 +0,0 @@
function handleRequest(request, response) {
response.setHeader("Content-Type", "application/octet-stream", false);
response.write("BIN");
}

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

@ -1,7 +0,0 @@
<!doctype html>
<meta charset=utf-8>
<head>
<!-- FIXME: we should keep file:// here ... -->
<link rel="manifest" href="sshfs://this_is_not_allowed!">
</head>
<h1>Support Page for Web Manifest Tests</h1>

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

@ -1,6 +0,0 @@
<!doctype html>
<meta charset=utf-8>
<head>
<link rel="manifest" href="file_web_manifest.json">
</head>
<h1>Support Page for Web Manifest Tests</h1>

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

@ -1 +0,0 @@
{"name": "pass"}

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

@ -1,59 +1,35 @@
[DEFAULT]
# Both the "inproc" and "oop" versions of OpenMixedProcess open remote frames,
# so we don't run that test on platforms which don't support OOP tests.
# FIXME(bz, bug 1504026): now that we're not testing OpenMixedProcess,
# can we reenable these tests on Android and e10s?
skip-if = os == "android" || e10s
support-files =
browserElement_OpenMixedProcess.js
file_browserElement_ExecuteScript.html
file_browserElement_OpenMixedProcess.html
browserElement_ExecuteScript.js
browserElement_Find.js
browserElement_OpenTab.js
[test_browserElement_oop_Viewmode.html]
[test_browserElement_oop_ThemeColor.html]
[test_browserElement_inproc_ErrorSecurity.html]
[test_browserElement_inproc_OpenMixedProcess.html]
disabled = disabled for bug 1266035 (bug 1310706 for re-enabling)
[test_browserElement_oop_Alert.html]
[test_browserElement_oop_AlertInFrame.html]
[test_browserElement_oop_Auth.html]
[test_browserElement_oop_BackForward.html]
disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
[test_browserElement_oop_BadScreenshot.html]
disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
[test_browserElement_oop_BrowserWindowResize.html]
[test_browserElement_oop_Close.html]
[test_browserElement_oop_CookiesNotThirdParty.html]
[test_browserElement_oop_CopyPaste.html]
subsuite = clipboard
[test_browserElement_oop_DOMRequestError.html]
disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
[test_browserElement_oop_DataURI.html]
[test_browserElement_oop_DocumentFirstPaint.html]
disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
[test_browserElement_oop_Download.html]
disabled = bug 1022281
[test_browserElement_oop_ErrorSecurity.html]
[test_browserElement_oop_ExecuteScript.html]
disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
[test_browserElement_oop_Find.html]
disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
[test_browserElement_oop_FirstPaint.html]
[test_browserElement_oop_ForwardName.html]
[test_browserElement_oop_FrameWrongURI.html]
[test_browserElement_oop_GetScreenshot.html]
disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
[test_browserElement_oop_GetScreenshotDppx.html]
disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
[test_browserElement_oop_Iconchange.html]
[test_browserElement_oop_LoadEvents.html]
[test_browserElement_oop_Manifestchange.html]
[test_browserElement_oop_Metachange.html]
[test_browserElement_oop_NoAudioTrack.html]
disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
[test_browserElement_oop_OpenMixedProcess.html]
disabled = disabled for bug 1266035 (bug 1310706 for re-enabling)
[test_browserElement_oop_OpenNamed.html]
[test_browserElement_oop_OpenWindow.html]
[test_browserElement_oop_OpenWindowDifferentOrigin.html]
@ -66,8 +42,6 @@ disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re
skip-if = true # Bug 1315042
[test_browserElement_oop_PromptCheck.html]
[test_browserElement_oop_PromptConfirm.html]
[test_browserElement_oop_PurgeHistory.html]
disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
[test_browserElement_oop_Reload.html]
disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
[test_browserElement_oop_ReloadPostRequest.html]
@ -95,8 +69,4 @@ disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re
[test_browserElement_oop_CloseFromOpener.html]
[test_browserElement_oop_ExposableURI.html]
skip-if = !e10s # Bug 1391349
[test_browserElement_oop_GetContentDimensions.html]
disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
[test_browserElement_oop_getWebManifest.html]
disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
[test_browserElement_oop_OpenWindowEmpty.html]

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

@ -20,7 +20,6 @@ support-files =
browserElement_DataURI.js
browserElement_DataURILoad.html
browserElement_DataURILoad.js
browserElement_Download.js
browserElement_ErrorSecurity.js
browserElement_ExposableURI.js
browserElement_FirstPaint.js
@ -28,9 +27,7 @@ support-files =
browserElement_FrameWrongURI.js
browserElement_Iconchange.js
browserElement_LoadEvents.js
browserElement_Manifestchange.js
browserElement_Metachange.js
browserElement_NextPaint.js
browserElement_OpenNamed.js
browserElement_OpenTab.js
browserElement_OpenWindow.js
@ -65,7 +62,6 @@ support-files =
file_browserElement_FrameWrongURI.html
file_browserElement_LoadEvents.html
file_browserElement_Metachange.sjs
file_browserElement_NextPaint.html
file_browserElement_Open1.html
file_browserElement_Open2.html
file_browserElement_OpenNamed.html
@ -84,16 +80,12 @@ support-files =
file_browserElement_XFrameOptionsDeny.html
file_browserElement_XFrameOptionsSameOrigin.html
file_bug741717.sjs
file_download_bin.sjs
file_empty.html
file_empty_script.js
file_focus.html
file_http_401_response.sjs
file_http_407_response.sjs
file_wyciwyg.html
file_web_manifest.html
file_web_manifest.json
file_illegal_web_manifest.html
noaudio.webm
# Note: browserElementTestHelpers.js looks at the test's filename to determine
@ -117,15 +109,12 @@ support-files =
subsuite = clipboard
skip-if = (os == "android") # Disabled on Android, see bug 1230421
[test_browserElement_inproc_DataURI.html]
[test_browserElement_inproc_Download.html]
disabled = bug 1022281
[test_browserElement_inproc_ExposableURI.html]
[test_browserElement_inproc_FirstPaint.html]
[test_browserElement_inproc_ForwardName.html]
[test_browserElement_inproc_FrameWrongURI.html]
[test_browserElement_inproc_Iconchange.html]
[test_browserElement_inproc_LoadEvents.html]
[test_browserElement_inproc_Manifestchange.html]
[test_browserElement_inproc_Metachange.html]
[test_browserElement_inproc_OpenNamed.html]
[test_browserElement_inproc_OpenTab.html]
@ -150,9 +139,6 @@ skip-if = android_version == '22' # bug 1358876, bug 1322607
[test_browserElement_inproc_XFrameOptionsAllowFrom.html]
[test_browserElement_inproc_XFrameOptionsDeny.html]
[test_browserElement_inproc_XFrameOptionsSameOrigin.html]
[test_browserElement_oop_NextPaint.html]
# Disabled due to https://bugzilla.mozilla.org/show_bug.cgi?id=774100
disabled = temp disabling some OOP tests for WebIDL scope changes
[test_browserElement_inproc_Reload.html]
disabled = bug 774100
[test_browserElement_inproc_OpenWindowEmpty.html]

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

@ -1,13 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 800170</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript" src="browserElement_BadScreenshot.js">
</script>
</body>
</html>

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

@ -1,19 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=787519
-->
<head>
<title>Test for Bug 787519</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=787519">Mozilla Bug 787519</a>
<script type="application/javascript" src='browserElement_DOMRequestError.js'>
</script>
</body>
</html>

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

@ -1,13 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 983747</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript" src="browserElement_Download.js">
</script>
</body>
</html>

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

@ -1,18 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1174733
-->
<head>
<title>Test for Bug 1163961</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1174733">Mozilla Bug 1174733</a>
<script type="application/javascript" src="browserElement_ExecuteScript.js">
</script>
</body>
</html>

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

@ -1,19 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1163961
-->
<head>
<title>Test for Bug 1163961</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1163961">Mozilla Bug 1163961</a>
<script type="application/javascript" src="browserElement_Find.js">
</script>
</body>
</html>

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

@ -1,13 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test of browser element.</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript" src="browserElement_GetContentDimensions.js">
</script>
</body>
</html>

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

@ -1,19 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=753595
-->
<head>
<title>Test for Bug 753595</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=753595">Mozilla Bug 753595</a>
<script type="application/javascript" src='browserElement_GetScreenshot.js'>
</script>
</body>
</html>

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

@ -1,19 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=959066
-->
<head>
<title>Test for Bug 959066</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=959066">Mozilla Bug 959066</a>
<script type="application/javascript" src='browserElement_GetScreenshotDppx.js'>
</script>
</body>
</html>

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

@ -1,19 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=982800
-->
<head>
<title>Test for Bug 982800</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.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=982800">Mozilla Bug 982800</a>
<script type="application/javascript" src="browserElement_Manifestchange.js">
</script>
</body>
</html>

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

@ -1,13 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 808231</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript" src="browserElement_NextPaint.js">
</script>
</body>
</html>

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

@ -1,13 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 776129</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript" src="browserElement_OpenMixedProcess.js">
</script>
</body>
</html>

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

@ -1,13 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test of browser element.</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript" src="browserElement_PurgeHistory.js">
</script>
</body>
</html>

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

@ -1,17 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 1169633</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript"
src="async.js">
</script>
<script type="application/javascript"
src="browserElement_getWebManifest.js">
</script>
</body>
</html>

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

@ -1,13 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 800170</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript" src="browserElement_BadScreenshot.js">
</script>
</body>
</html>

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

@ -1,19 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=787519
-->
<head>
<title>Test for Bug 787519</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.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=787519">Mozilla Bug 787519</a>
<script type="application/javascript" src='browserElement_DOMRequestError.js'>
</script>
</body>
</html>

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

@ -1,13 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 983747</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript" src="browserElement_Download.js">
</script>
</body>
</html>

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

@ -1,18 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1174733
-->
<head>
<title>Test for Bug 1163961</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.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=1174733">Mozilla Bug 1174733</a>
<script type="application/javascript" src="browserElement_ExecuteScript.js">
</script>
</body>
</html>

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

@ -1,19 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1163961
-->
<head>
<title>Test for Bug 1163961</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.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=1163961">Mozilla Bug 1163961</a>
<script type="application/javascript" src="browserElement_Find.js">
</script>
</body>
</html>

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

@ -1,13 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test of browser element.</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript" src="browserElement_GetContentDimensions.js">
</script>
</body>
</html>

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

@ -1,20 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=753595
-->
<head>
<title>Test for Bug 753595</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.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=753595">Mozilla Bug 753595</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=878003">Mozilla Bug 878003</a>
<script type="application/javascript" src='browserElement_GetScreenshot.js'>
</script>
</body>
</html>

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

@ -1,19 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=959066
-->
<head>
<title>Test for Bug 959066</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.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=959066">Mozilla Bug 959066</a>
<script type="application/javascript" src='browserElement_GetScreenshotDppx.js'>
</script>
</body>
</html>

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

@ -1,19 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=982800
-->
<head>
<title>Test for Bug 982800</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.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=982800">Mozilla Bug 982800</a>
<script type="application/javascript" src="browserElement_Manifestchange.js">
</script>
</body>
</html>

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

@ -1,13 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 808231</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript" src="browserElement_NextPaint.js">
</script>
</body>
</html>

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

@ -1,13 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 776129</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript" src="browserElement_OpenMixedProcess.js">
</script>
</body>
</html>

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

@ -1,13 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test of browser element.</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript" src="browserElement_PurgeHistory.js">
</script>
</body>
</html>

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

@ -1,16 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 1169633</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/dom/browser-element/mochitest/browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript"
src="async.js"></script>
<script type="application/javascript"
src="browserElement_getWebManifest.js">
</script>
</body>
</html>

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

@ -6,7 +6,6 @@
#include "nsISupports.idl"
webidl DOMRequest;
webidl FrameLoader;
%{C++
@ -23,12 +22,6 @@ webidl FrameLoader;
[scriptable, uuid(57758c10-6036-11e5-a837-0800200c9a66)]
interface nsIBrowserElementAPI : nsISupports
{
const long FIND_CASE_SENSITIVE = 0;
const long FIND_CASE_INSENSITIVE = 1;
const long FIND_FORWARD = 0;
const long FIND_BACKWARD = 1;
/**
* Notify frame scripts that support the API to destroy.
*/
@ -42,43 +35,10 @@ interface nsIBrowserElementAPI : nsISupports
in uint32_t button,
in uint32_t clickCount,
in uint32_t mifiers);
void sendTouchEvent(in AString aType,
[const, array, size_is(count)] in uint32_t aIdentifiers,
[const, array, size_is(count)] in int32_t aXs,
[const, array, size_is(count)] in int32_t aYs,
[const, array, size_is(count)] in uint32_t aRxs,
[const, array, size_is(count)] in uint32_t aRys,
[const, array, size_is(count)] in float aRotationAngles,
[const, array, size_is(count)] in float aForces,
in uint32_t count,
in long aModifiers);
void goBack();
void goForward();
void reload(in boolean hardReload);
void stop();
DOMRequest download(in AString url,
[optional] in jsval options);
DOMRequest purgeHistory();
DOMRequest getScreenshot(in uint32_t width,
in uint32_t height,
[optional] in AString mimeType);
void zoom(in float zoom);
DOMRequest getCanGoBack();
DOMRequest getCanGoForward();
DOMRequest getContentDimensions();
void findAll(in AString searchString, in long caseSensitivity);
void findNext(in long direction);
void clearMatch();
void addNextPaintListener(in jsval listener); // BrowserElementNextPaintEventCallback
void removeNextPaintListener(in jsval listener); // BrowserElementNextPaintEventCallback
DOMRequest executeScript(in AString script, in jsval options);
/**
* Returns an object that represents a Web Manifest:
* http://w3c.github.io/manifest/
*/
DOMRequest getWebManifest();
Promise getCanGoBack();
Promise getCanGoForward();
};

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

@ -12,6 +12,7 @@
#include "nsContentUtils.h"
#include "nsIScriptError.h"
#include "nsPIDOMWindow.h"
#include "jsapi.h"
namespace mozilla {
namespace dom {
@ -160,6 +161,12 @@ FetchStreamReader::StartConsuming(JSContext* aCx,
aRv.MightThrowJSException();
// Here, by spec, we can pick any global we want. Just to avoid extra
// cross-compartment steps, we want to create the reader in the same
// compartment of the owning Fetch Body object.
// The same global will be used to retrieve data from this reader.
JSAutoRealm ar(aCx, mGlobal->GetGlobalJSObject());
JS::Rooted<JSObject*> reader(aCx,
JS::ReadableStreamGetReader(aCx, aStream,
JS::ReadableStreamReaderMode::Default));
@ -195,8 +202,9 @@ FetchStreamReader::OnOutputStreamReady(nsIAsyncOutputStream* aStream)
return WriteBuffer();
}
// TODO: We need to verify this is the correct global per the spec.
// See bug 1385890.
// Here we can retrieve data from the reader using any global we want because
// it is not observable. We want to use the reader's global, which is also the
// Response's one.
AutoEntryScript aes(mGlobal, "ReadableStreamReader.read", !mWorkerRef);
JS::Rooted<JSObject*> reader(aes.cx(), mReader);

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

@ -9,7 +9,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/dom/BrowserElementBinding.h"
#include "mozilla/dom/DOMRequest.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/ToJSValue.h"
@ -86,48 +86,6 @@ nsBrowserElement::SendMouseEvent(const nsAString& aType,
}
}
void
nsBrowserElement::SendTouchEvent(const nsAString& aType,
const Sequence<uint32_t>& aIdentifiers,
const Sequence<int32_t>& aXs,
const Sequence<int32_t>& aYs,
const Sequence<uint32_t>& aRxs,
const Sequence<uint32_t>& aRys,
const Sequence<float>& aRotationAngles,
const Sequence<float>& aForces,
uint32_t aCount,
uint32_t aModifiers,
ErrorResult& aRv)
{
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
if (aIdentifiers.Length() != aCount ||
aXs.Length() != aCount ||
aYs.Length() != aCount ||
aRxs.Length() != aCount ||
aRys.Length() != aCount ||
aRotationAngles.Length() != aCount ||
aForces.Length() != aCount) {
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
return;
}
nsresult rv = mBrowserElementAPI->SendTouchEvent(aType,
aIdentifiers.Elements(),
aXs.Elements(),
aYs.Elements(),
aRxs.Elements(),
aRys.Elements(),
aRotationAngles.Elements(),
aForces.Elements(),
aCount,
aModifiers);
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
}
}
void
nsBrowserElement::GoBack(ErrorResult& aRv)
{
@ -176,276 +134,36 @@ nsBrowserElement::Stop(ErrorResult& aRv)
}
}
already_AddRefed<DOMRequest>
nsBrowserElement::Download(const nsAString& aUrl,
const BrowserElementDownloadOptions& aOptions,
ErrorResult& aRv)
{
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
RefPtr<DOMRequest> req;
nsCOMPtr<nsIXPConnectWrappedJS> wrappedObj = do_QueryInterface(mBrowserElementAPI);
MOZ_ASSERT(wrappedObj, "Failed to get wrapped JS from XPCOM component.");
MOZ_RELEASE_ASSERT(!js::IsWrapper(wrappedObj->GetJSObject()));
AutoJSAPI jsapi;
if (!jsapi.Init(wrappedObj->GetJSObject())) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> options(cx);
aRv.MightThrowJSException();
if (!ToJSValue(cx, aOptions, &options)) {
aRv.StealExceptionFromJSContext(cx);
return nullptr;
}
nsresult rv = mBrowserElementAPI->Download(aUrl, options, getter_AddRefs(req));
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
return req.forget();
}
already_AddRefed<DOMRequest>
nsBrowserElement::PurgeHistory(ErrorResult& aRv)
{
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
RefPtr<DOMRequest> req;
nsresult rv = mBrowserElementAPI->PurgeHistory(getter_AddRefs(req));
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
return req.forget();
}
already_AddRefed<DOMRequest>
nsBrowserElement::GetScreenshot(uint32_t aWidth,
uint32_t aHeight,
const nsAString& aMimeType,
ErrorResult& aRv)
{
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
RefPtr<DOMRequest> req;
nsresult rv = mBrowserElementAPI->GetScreenshot(aWidth, aHeight, aMimeType,
getter_AddRefs(req));
if (NS_WARN_IF(NS_FAILED(rv))) {
if (rv == NS_ERROR_INVALID_ARG) {
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
} else {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
}
return nullptr;
}
return req.forget();
}
void
nsBrowserElement::Zoom(float aZoom, ErrorResult& aRv)
{
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
nsresult rv = mBrowserElementAPI->Zoom(aZoom);
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
}
}
already_AddRefed<DOMRequest>
already_AddRefed<Promise>
nsBrowserElement::GetCanGoBack(ErrorResult& aRv)
{
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
RefPtr<DOMRequest> req;
nsresult rv = mBrowserElementAPI->GetCanGoBack(getter_AddRefs(req));
RefPtr<Promise> p;
nsresult rv = mBrowserElementAPI->GetCanGoBack(getter_AddRefs(p));
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
return req.forget();
return p.forget();
}
already_AddRefed<DOMRequest>
already_AddRefed<Promise>
nsBrowserElement::GetCanGoForward(ErrorResult& aRv)
{
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
RefPtr<DOMRequest> req;
nsresult rv = mBrowserElementAPI->GetCanGoForward(getter_AddRefs(req));
RefPtr<Promise> p;
nsresult rv = mBrowserElementAPI->GetCanGoForward(getter_AddRefs(p));
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
return req.forget();
return p.forget();
}
already_AddRefed<DOMRequest>
nsBrowserElement::GetContentDimensions(ErrorResult& aRv)
{
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
RefPtr<DOMRequest> req;
nsresult rv = mBrowserElementAPI->GetContentDimensions(getter_AddRefs(req));
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
return req.forget();
}
void
nsBrowserElement::FindAll(const nsAString& aSearchString,
BrowserFindCaseSensitivity aCaseSensitivity,
ErrorResult& aRv)
{
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
uint32_t caseSensitivity;
if (aCaseSensitivity == BrowserFindCaseSensitivity::Case_insensitive) {
caseSensitivity = nsIBrowserElementAPI::FIND_CASE_INSENSITIVE;
} else {
caseSensitivity = nsIBrowserElementAPI::FIND_CASE_SENSITIVE;
}
nsresult rv = mBrowserElementAPI->FindAll(aSearchString, caseSensitivity);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
}
}
void
nsBrowserElement::FindNext(BrowserFindDirection aDirection,
ErrorResult& aRv)
{
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
uint32_t direction;
if (aDirection == BrowserFindDirection::Backward) {
direction = nsIBrowserElementAPI::FIND_BACKWARD;
} else {
direction = nsIBrowserElementAPI::FIND_FORWARD;
}
nsresult rv = mBrowserElementAPI->FindNext(direction);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
}
}
void
nsBrowserElement::ClearMatch(ErrorResult& aRv)
{
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
nsresult rv = mBrowserElementAPI->ClearMatch();
if (NS_FAILED(rv)) {
aRv.Throw(rv);
}
}
void
nsBrowserElement::AddNextPaintListener(BrowserElementNextPaintEventCallback& aListener,
ErrorResult& aRv)
{
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
JS::Rooted<JS::Value> val(RootingCx(),
JS::ObjectOrNullValue(aListener.CallbackOrNull()));
nsresult rv = mBrowserElementAPI->AddNextPaintListener(val);
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
}
}
void
nsBrowserElement::RemoveNextPaintListener(BrowserElementNextPaintEventCallback& aListener,
ErrorResult& aRv)
{
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
JS::Rooted<JS::Value> val(RootingCx(),
JS::ObjectOrNullValue(aListener.CallbackOrNull()));
nsresult rv = mBrowserElementAPI->RemoveNextPaintListener(val);
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
}
}
already_AddRefed<DOMRequest>
nsBrowserElement::ExecuteScript(const nsAString& aScript,
const BrowserElementExecuteScriptOptions& aOptions,
ErrorResult& aRv)
{
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
RefPtr<DOMRequest> req;
nsCOMPtr<nsIXPConnectWrappedJS> wrappedObj = do_QueryInterface(mBrowserElementAPI);
MOZ_ASSERT(wrappedObj, "Failed to get wrapped JS from XPCOM component.");
MOZ_RELEASE_ASSERT(!js::IsWrapper(wrappedObj->GetJSObject()));
AutoJSAPI jsapi;
if (!jsapi.Init(wrappedObj->GetJSObject())) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> options(cx);
aRv.MightThrowJSException();
if (!ToJSValue(cx, aOptions, &options)) {
aRv.StealExceptionFromJSContext(cx);
return nullptr;
}
nsresult rv = mBrowserElementAPI->ExecuteScript(aScript, options, getter_AddRefs(req));
if (NS_FAILED(rv)) {
if (rv == NS_ERROR_INVALID_ARG) {
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
} else {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
}
return nullptr;
}
return req.forget();
}
already_AddRefed<DOMRequest>
nsBrowserElement::GetWebManifest(ErrorResult& aRv)
{
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
RefPtr<DOMRequest> req;
nsresult rv = mBrowserElementAPI->GetWebManifest(getter_AddRefs(req));
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
return req.forget();
}
} // namespace mozilla

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

@ -17,12 +17,7 @@ class nsFrameLoader;
namespace mozilla {
namespace dom {
struct BrowserElementDownloadOptions;
struct BrowserElementExecuteScriptOptions;
class BrowserElementNextPaintEventCallback;
class DOMRequest;
enum class BrowserFindCaseSensitivity: uint8_t;
enum class BrowserFindDirection: uint8_t;
class Promise;
} // namespace dom
class ErrorResult;
@ -43,56 +38,13 @@ public:
uint32_t aClickCount,
uint32_t aModifiers,
ErrorResult& aRv);
void SendTouchEvent(const nsAString& aType,
const dom::Sequence<uint32_t>& aIdentifiers,
const dom::Sequence<int32_t>& aX,
const dom::Sequence<int32_t>& aY,
const dom::Sequence<uint32_t>& aRx,
const dom::Sequence<uint32_t>& aRy,
const dom::Sequence<float>& aRotationAngles,
const dom::Sequence<float>& aForces,
uint32_t aCount,
uint32_t aModifiers,
ErrorResult& aRv);
void GoBack(ErrorResult& aRv);
void GoForward(ErrorResult& aRv);
void Reload(bool aHardReload, ErrorResult& aRv);
void Stop(ErrorResult& aRv);
already_AddRefed<dom::DOMRequest>
Download(const nsAString& aUrl,
const dom::BrowserElementDownloadOptions& options,
ErrorResult& aRv);
already_AddRefed<dom::DOMRequest> PurgeHistory(ErrorResult& aRv);
already_AddRefed<dom::DOMRequest>
GetScreenshot(uint32_t aWidth,
uint32_t aHeight,
const nsAString& aMimeType,
ErrorResult& aRv);
void Zoom(float aZoom, ErrorResult& aRv);
already_AddRefed<dom::DOMRequest> GetCanGoBack(ErrorResult& aRv);
already_AddRefed<dom::DOMRequest> GetCanGoForward(ErrorResult& aRv);
already_AddRefed<dom::DOMRequest> GetContentDimensions(ErrorResult& aRv);
void FindAll(const nsAString& aSearchString, dom::BrowserFindCaseSensitivity aCaseSensitivity,
ErrorResult& aRv);
void FindNext(dom::BrowserFindDirection aDirection, ErrorResult& aRv);
void ClearMatch(ErrorResult& aRv);
void AddNextPaintListener(dom::BrowserElementNextPaintEventCallback& listener,
ErrorResult& aRv);
void RemoveNextPaintListener(dom::BrowserElementNextPaintEventCallback& listener,
ErrorResult& aRv);
already_AddRefed<dom::DOMRequest> ExecuteScript(const nsAString& aScript,
const dom::BrowserElementExecuteScriptOptions& aOptions,
ErrorResult& aRv);
already_AddRefed<dom::DOMRequest> GetWebManifest(ErrorResult& aRv);
already_AddRefed<dom::Promise> GetCanGoBack(ErrorResult& aRv);
already_AddRefed<dom::Promise> GetCanGoForward(ErrorResult& aRv);
protected:
NS_IMETHOD_(already_AddRefed<nsFrameLoader>) GetFrameLoader() = 0;

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

@ -437,7 +437,7 @@ skip-if = toolkit == 'android'
[test_formelements.html]
[test_fullscreen-api.html]
tags = fullscreen
skip-if = toolkit == 'android'
skip-if = toolkit == 'android' || (os == 'linux' && !debug) # linux opt/pgo timeouts: bug 1504062
support-files =
file_fullscreen-api.html
file_fullscreen-backdrop.html

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

@ -4,41 +4,12 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
callback BrowserElementNextPaintEventCallback = void ();
enum BrowserFindCaseSensitivity { "case-sensitive", "case-insensitive" };
enum BrowserFindDirection { "forward", "backward" };
dictionary BrowserElementDownloadOptions {
DOMString? filename;
DOMString? referrer;
};
dictionary BrowserElementExecuteScriptOptions {
DOMString? url;
DOMString? origin;
};
[NoInterfaceObject]
interface BrowserElement {
};
BrowserElement implements BrowserElementCommon;
BrowserElement implements BrowserElementPrivileged;
[NoInterfaceObject]
interface BrowserElementCommon {
[Throws,
Pref="dom.mozBrowserFramesEnabled",
ChromeOnly]
void addNextPaintListener(BrowserElementNextPaintEventCallback listener);
[Throws,
Pref="dom.mozBrowserFramesEnabled",
ChromeOnly]
void removeNextPaintListener(BrowserElementNextPaintEventCallback listener);
};
[NoInterfaceObject]
interface BrowserElementPrivileged {
[Throws,
@ -51,21 +22,6 @@ interface BrowserElementPrivileged {
unsigned long clickCount,
unsigned long modifiers);
[Throws,
Pref="dom.mozBrowserFramesEnabled",
Func="TouchEvent::PrefEnabled",
ChromeOnly]
void sendTouchEvent(DOMString type,
sequence<unsigned long> identifiers,
sequence<long> x,
sequence<long> y,
sequence<unsigned long> rx,
sequence<unsigned long> ry,
sequence<float> rotationAngles,
sequence<float> forces,
unsigned long count,
unsigned long modifiers);
[Throws,
Pref="dom.mozBrowserFramesEnabled",
ChromeOnly]
@ -89,65 +45,10 @@ interface BrowserElementPrivileged {
[Throws,
Pref="dom.mozBrowserFramesEnabled",
ChromeOnly]
DOMRequest download(DOMString url,
optional BrowserElementDownloadOptions options);
Promise<boolean> getCanGoBack();
[Throws,
Pref="dom.mozBrowserFramesEnabled",
ChromeOnly]
DOMRequest purgeHistory();
[Throws,
Pref="dom.mozBrowserFramesEnabled",
ChromeOnly]
DOMRequest getScreenshot([EnforceRange] unsigned long width,
[EnforceRange] unsigned long height,
optional DOMString mimeType="");
[Throws,
Pref="dom.mozBrowserFramesEnabled",
ChromeOnly]
void zoom(float zoom);
[Throws,
Pref="dom.mozBrowserFramesEnabled",
ChromeOnly]
DOMRequest getCanGoBack();
[Throws,
Pref="dom.mozBrowserFramesEnabled",
ChromeOnly]
DOMRequest getCanGoForward();
[Throws,
Pref="dom.mozBrowserFramesEnabled",
ChromeOnly]
DOMRequest getContentDimensions();
[Throws,
Pref="dom.mozBrowserFramesEnabled",
ChromeOnly]
void findAll(DOMString searchString, BrowserFindCaseSensitivity caseSensitivity);
[Throws,
Pref="dom.mozBrowserFramesEnabled",
ChromeOnly]
void findNext(BrowserFindDirection direction);
[Throws,
Pref="dom.mozBrowserFramesEnabled",
ChromeOnly]
void clearMatch();
[Throws,
Pref="dom.mozBrowserFramesEnabled",
ChromeOnly]
DOMRequest executeScript(DOMString script,
optional BrowserElementExecuteScriptOptions options);
[Throws,
Pref="dom.mozBrowserFramesEnabled",
ChromeOnly]
DOMRequest getWebManifest();
Promise<boolean> getCanGoForward();
};

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

@ -246,7 +246,8 @@ DecoderFactory::CloneAnimationDecoder(Decoder* aDecoder)
// get scheduled yet, or it has only decoded the first frame and has yet to
// rediscover it is animated).
DecoderType type = aDecoder->GetType();
MOZ_ASSERT(type == DecoderType::GIF || type == DecoderType::PNG,
MOZ_ASSERT(type == DecoderType::GIF || type == DecoderType::PNG ||
type == DecoderType::WEBP,
"Calling CloneAnimationDecoder for non-animating DecoderType");
RefPtr<Decoder> decoder = GetDecoder(type, nullptr, /* aIsRedecode = */ true);

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

@ -185,8 +185,10 @@ MetadataDecodingTask::Run()
// AnonymousDecodingTask implementation.
///////////////////////////////////////////////////////////////////////////////
AnonymousDecodingTask::AnonymousDecodingTask(NotNull<Decoder*> aDecoder)
AnonymousDecodingTask::AnonymousDecodingTask(NotNull<Decoder*> aDecoder,
bool aResumable)
: mDecoder(aDecoder)
, mResumable(aResumable)
{ }
void
@ -211,5 +213,20 @@ AnonymousDecodingTask::Run()
}
}
void
AnonymousDecodingTask::Resume()
{
// Anonymous decoders normally get all their data at once. We have tests
// where they don't; typically in these situations, the test re-runs them
// manually. However some tests want to verify Resume works, so they will
// explicitly request this behaviour.
if (mResumable) {
RefPtr<AnonymousDecodingTask> self(this);
NS_DispatchToMainThread(NS_NewRunnableFunction(
"image::AnonymousDecodingTask::Resume",
[self]() -> void { self->Run(); }));
}
}
} // namespace image
} // namespace mozilla

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

@ -109,22 +109,21 @@ class AnonymousDecodingTask final : public IDecodingTask
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AnonymousDecodingTask, override)
explicit AnonymousDecodingTask(NotNull<Decoder*> aDecoder);
explicit AnonymousDecodingTask(NotNull<Decoder*> aDecoder,
bool aResumable);
void Run() override;
bool ShouldPreferSyncRun() const override { return true; }
TaskPriority Priority() const override { return TaskPriority::eLow; }
// Anonymous decoders normally get all their data at once. We have tests where
// they don't; in these situations, the test re-runs them manually. So no
// matter what, we don't want to resume by posting a task to the DecodePool.
void Resume() override { }
void Resume() override;
private:
virtual ~AnonymousDecodingTask() { }
NotNull<RefPtr<Decoder>> mDecoder;
bool mResumable;
};
} // namespace image

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

@ -179,7 +179,8 @@ ImageOps::DecodeMetadata(ImageBuffer* aBuffer,
}
// Run the decoder synchronously.
RefPtr<IDecodingTask> task = new AnonymousDecodingTask(WrapNotNull(decoder));
RefPtr<IDecodingTask> task =
new AnonymousDecodingTask(WrapNotNull(decoder), /* aResumable */ false);
task->Run();
if (!decoder->GetDecodeDone() || decoder->HasError()) {
return NS_ERROR_FAILURE;
@ -233,7 +234,8 @@ ImageOps::DecodeToSurface(ImageBuffer* aBuffer,
}
// Run the decoder synchronously.
RefPtr<IDecodingTask> task = new AnonymousDecodingTask(WrapNotNull(decoder));
RefPtr<IDecodingTask> task =
new AnonymousDecodingTask(WrapNotNull(decoder), /* aResumable */ false);
task->Run();
if (!decoder->GetDecodeDone() || decoder->HasError()) {
return nullptr;

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

@ -110,7 +110,7 @@ nsWebPDecoder::DoDecode(SourceBufferIterator& aIterator, IResumable* aOnResume)
SourceBufferIterator::State state = SourceBufferIterator::COMPLETE;
if (!mIteratorComplete) {
state = aIterator.Advance(SIZE_MAX);
state = aIterator.AdvanceOrScheduleResume(SIZE_MAX, aOnResume);
// We need to remember since we can't advance a complete iterator.
mIteratorComplete = state == SourceBufferIterator::COMPLETE;
@ -133,6 +133,8 @@ nsWebPDecoder::DoDecode(SourceBufferIterator& aIterator, IResumable* aOnResume)
return ReadData();
case SourceBufferIterator::COMPLETE:
return ReadData();
case SourceBufferIterator::WAITING:
return LexerResult(Yield::NEED_MORE_DATA);
default:
MOZ_LOG(sWebPLog, LogLevel::Error,
("[this=%p] nsWebPDecoder::DoDecode -- bad state\n", this));
@ -180,8 +182,16 @@ nsWebPDecoder::CreateFrame(const nsIntRect& aFrameRect)
MOZ_ASSERT(!mDecoder);
MOZ_LOG(sWebPLog, LogLevel::Debug,
("[this=%p] nsWebPDecoder::CreateFrame -- frame %u, %d x %d\n",
this, mCurrentFrame, aFrameRect.width, aFrameRect.height));
("[this=%p] nsWebPDecoder::CreateFrame -- frame %u, (%d, %d) %d x %d\n",
this, mCurrentFrame, aFrameRect.x, aFrameRect.y,
aFrameRect.width, aFrameRect.height));
if (aFrameRect.width <= 0 || aFrameRect.height <= 0) {
MOZ_LOG(sWebPLog, LogLevel::Error,
("[this=%p] nsWebPDecoder::CreateFrame -- bad frame rect\n",
this));
return NS_ERROR_FAILURE;
}
// If this is our first frame in an animation and it doesn't cover the
// full frame, then we are transparent even if there is no alpha
@ -220,6 +230,7 @@ nsWebPDecoder::CreateFrame(const nsIntRect& aFrameRect)
return NS_ERROR_FAILURE;
}
mFrameRect = aFrameRect;
mPipe = std::move(*pipe);
return NS_OK;
}
@ -419,7 +430,9 @@ nsWebPDecoder::ReadSingle(const uint8_t* aData, size_t aLength, const IntRect& a
return LexerResult(Yield::NEED_MORE_DATA);
}
if (width <= 0 || height <= 0 || stride <= 0) {
if (width != mFrameRect.width || height != mFrameRect.height ||
stride < mFrameRect.width * 4 ||
lastRow > mFrameRect.height) {
MOZ_LOG(sWebPLog, LogLevel::Error,
("[this=%p] nsWebPDecoder::ReadSingle -- bad (w,h,s) = (%d, %d, %d)\n",
this, width, height, stride));

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

@ -21,6 +21,8 @@ class nsWebPDecoder final : public Decoder
public:
virtual ~nsWebPDecoder();
DecoderType GetType() const override { return DecoderType::WEBP; }
protected:
LexerResult DoDecode(SourceBufferIterator& aIterator,
IResumable* aOnResume) override;
@ -77,6 +79,9 @@ private:
/// Surface format for the current frame.
gfx::SurfaceFormat mFormat;
/// Frame rect for the current frame.
IntRect mFrameRect;
/// The last row of decoded pixels written to mPipe.
int mLastRow;

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

@ -17,7 +17,6 @@
#include "mozilla/Preferences.h"
#include "mozilla/ChaosMode.h"
#include "mozilla/LoadInfo.h"
#include "mozilla/Telemetry.h"
#include "nsImageModule.h"
#include "imgRequestProxy.h"
@ -1414,9 +1413,6 @@ void imgLoader::GlobalInit()
RegisterStrongAsyncMemoryReporter(sMemReporter);
RegisterImagesContentUsedUncompressedDistinguishedAmount(
imgMemoryReporter::ImagesContentUsedUncompressedDistinguishedAmount);
Telemetry::ScalarSet(Telemetry::ScalarID::IMAGES_WEBP_PROBE_OBSERVED, false);
Telemetry::ScalarSet(Telemetry::ScalarID::IMAGES_WEBP_CONTENT_OBSERVED, false);
}
void imgLoader::ShutdownMemoryReporter()

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

@ -41,7 +41,6 @@
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/SizeOfState.h"
#include "mozilla/Telemetry.h"
using namespace mozilla;
using namespace mozilla::image;
@ -922,7 +921,6 @@ imgRequest::OnStopRequest(nsIRequest* aRequest,
struct mimetype_closure
{
nsACString* newType;
uint32_t segmentSize;
};
/* prototype for these defined below */
@ -969,49 +967,11 @@ PrepareForNewPart(nsIRequest* aRequest, nsIInputStream* aInStr, uint32_t aCount,
if (aInStr) {
mimetype_closure closure;
closure.newType = &result.mContentType;
closure.segmentSize = 0;
// Look at the first few bytes and see if we can tell what the data is from
// that since servers tend to lie. :(
uint32_t out;
aInStr->ReadSegments(sniff_mimetype_callback, &closure, aCount, &out);
// We don't support WebP but we are getting reports of Firefox being served
// WebP content in the wild. In particular this appears to be a problem on
// Fennec where content authors assume Android implies WebP support. The
// telemetry below is intended to get a sense of how prevalent this is.
//
// From the Google WebP FAQ example and the Modernizr library, websites may
// supply a tiny WebP image to probe for feature support using scripts. The
// probes are implemented as data URIs thus we should have all the content
// upfront. We don't want to consider a probe as having observed WebP since
// in theory the client should do the right thing when we fail to decode it.
// See https://developers.google.com/speed/webp/faq for details.
bool webp = result.mContentType.EqualsLiteral(IMAGE_WEBP);
bool webpProbe = false;
if (webp) {
// The probes from the example/library are all < 90 bytes. Round it up
// just in case.
const uint32_t kMaxProbeSize = 100;
if (closure.segmentSize < kMaxProbeSize &&
NS_FAILED(aURI->SchemeIs("data", &webpProbe))) {
webpProbe = false;
}
if (webpProbe) {
Telemetry::ScalarSet(Telemetry::ScalarID::IMAGES_WEBP_PROBE_OBSERVED,
true);
} else {
Telemetry::ScalarSet(Telemetry::ScalarID::IMAGES_WEBP_CONTENT_OBSERVED,
true);
}
}
if (!webpProbe) {
Telemetry::ScalarAdd(Telemetry::ScalarID::IMAGES_WEBP_CONTENT_FREQUENCY,
webp ? NS_LITERAL_STRING("webp") :
NS_LITERAL_STRING("other"), 1);
}
}
nsCOMPtr<nsIChannel> chan(do_QueryInterface(aRequest));
@ -1261,7 +1221,6 @@ sniff_mimetype_callback(nsIInputStream* in,
NS_ASSERTION(closure, "closure is null!");
closure->segmentSize = count;
if (count > 0) {
imgLoader::GetMimeTypeFromContent(fromRawSegment, count, *closure->newType);
}

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

@ -55,15 +55,7 @@ AutoInitializeImageLib::AutoInitializeImageLib()
// Depending on initialization order, it is possible that our pref changes
// have not taken effect yet because there are pending gfx-related events on
// the main thread.
nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
EXPECT_TRUE(mainThread != nullptr);
bool processed;
do {
processed = false;
nsresult rv = mainThread->ProcessNextEvent(false, &processed);
EXPECT_TRUE(NS_SUCCEEDED(rv));
} while (processed);
SpinPendingEvents();
}
///////////////////////////////////////////////////////////////////////////////
@ -102,6 +94,20 @@ AutoInitializeImageLib::AutoInitializeImageLib()
return rv; \
}
void
SpinPendingEvents()
{
nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
EXPECT_TRUE(mainThread != nullptr);
bool processed;
do {
processed = false;
nsresult rv = mainThread->ProcessNextEvent(false, &processed);
EXPECT_TRUE(NS_SUCCEEDED(rv));
} while (processed);
}
already_AddRefed<nsIInputStream>
LoadFile(const char* aRelativePath)
{

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

@ -133,6 +133,9 @@ public:
AutoInitializeImageLib();
};
/// Spins on the main thread to process any pending events.
void SpinPendingEvents();
/// Loads a file from the current directory. @return an nsIInputStream for it.
already_AddRefed<nsIInputStream> LoadFile(const char* aRelativePath);

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

@ -34,6 +34,11 @@ using namespace mozilla::image;
static already_AddRefed<SourceSurface>
CheckDecoderState(const ImageTestCase& aTestCase, Decoder* aDecoder)
{
// Decoder should match what we asked for in the MIME type.
EXPECT_NE(aDecoder->GetType(), DecoderType::UNKNOWN);
EXPECT_EQ(aDecoder->GetType(),
DecoderFactory::GetDecoderType(aTestCase.mMimeType));
EXPECT_TRUE(aDecoder->GetDecodeDone());
EXPECT_EQ(bool(aTestCase.mFlags & TEST_CASE_HAS_ERROR),
aDecoder->HasError());
@ -119,7 +124,8 @@ void WithSingleChunkDecode(const ImageTestCase& aTestCase,
DecoderFlags::FIRST_FRAME_ONLY,
DefaultSurfaceFlags());
ASSERT_TRUE(decoder != nullptr);
RefPtr<IDecodingTask> task = new AnonymousDecodingTask(WrapNotNull(decoder));
RefPtr<IDecodingTask> task =
new AnonymousDecodingTask(WrapNotNull(decoder), /* aResumable */ false);
// Run the full decoder synchronously.
task->Run();
@ -136,6 +142,58 @@ CheckDecoderSingleChunk(const ImageTestCase& aTestCase)
});
}
template <typename Func>
void WithDelayedChunkDecode(const ImageTestCase& aTestCase,
const Maybe<IntSize>& aOutputSize,
Func aResultChecker)
{
nsCOMPtr<nsIInputStream> inputStream = LoadFile(aTestCase.mPath);
ASSERT_TRUE(inputStream != nullptr);
// Figure out how much data we have.
uint64_t length;
nsresult rv = inputStream->Available(&length);
ASSERT_TRUE(NS_SUCCEEDED(rv));
// Prepare an empty SourceBuffer.
auto sourceBuffer = MakeNotNull<RefPtr<SourceBuffer>>();
// Create a decoder.
DecoderType decoderType =
DecoderFactory::GetDecoderType(aTestCase.mMimeType);
RefPtr<Decoder> decoder =
DecoderFactory::CreateAnonymousDecoder(decoderType, sourceBuffer, aOutputSize,
DecoderFlags::FIRST_FRAME_ONLY,
DefaultSurfaceFlags());
ASSERT_TRUE(decoder != nullptr);
RefPtr<IDecodingTask> task =
new AnonymousDecodingTask(WrapNotNull(decoder), /* aResumable */ true);
// Run the full decoder synchronously. It should now be waiting on
// the iterator to yield some data since we haven't written anything yet.
task->Run();
// Writing all of the data should wake up the decoder to complete.
sourceBuffer->ExpectLength(length);
rv = sourceBuffer->AppendFromInputStream(inputStream, length);
ASSERT_TRUE(NS_SUCCEEDED(rv));
sourceBuffer->Complete(NS_OK);
// It would have gotten posted to the main thread to avoid mutex contention.
SpinPendingEvents();
// Call the lambda to verify the expected results.
aResultChecker(decoder);
}
static void
CheckDecoderDelayedChunk(const ImageTestCase& aTestCase)
{
WithDelayedChunkDecode(aTestCase, Nothing(), [&](Decoder* aDecoder) {
CheckDecoderResults(aTestCase, aDecoder);
});
}
static void
CheckDecoderMultiChunk(const ImageTestCase& aTestCase)
{
@ -157,7 +215,8 @@ CheckDecoderMultiChunk(const ImageTestCase& aTestCase)
DecoderFlags::FIRST_FRAME_ONLY,
DefaultSurfaceFlags());
ASSERT_TRUE(decoder != nullptr);
RefPtr<IDecodingTask> task = new AnonymousDecodingTask(WrapNotNull(decoder));
RefPtr<IDecodingTask> task =
new AnonymousDecodingTask(WrapNotNull(decoder), /* aResumable */ false);
for (uint64_t read = 0; read < length ; ++read) {
uint64_t available = 0;
@ -581,6 +640,11 @@ TEST_F(ImageDecoders, PNGSingleChunk)
CheckDecoderSingleChunk(GreenPNGTestCase());
}
TEST_F(ImageDecoders, PNGDelayedChunk)
{
CheckDecoderDelayedChunk(GreenPNGTestCase());
}
TEST_F(ImageDecoders, PNGMultiChunk)
{
CheckDecoderMultiChunk(GreenPNGTestCase());
@ -596,6 +660,11 @@ TEST_F(ImageDecoders, GIFSingleChunk)
CheckDecoderSingleChunk(GreenGIFTestCase());
}
TEST_F(ImageDecoders, GIFDelayedChunk)
{
CheckDecoderDelayedChunk(GreenGIFTestCase());
}
TEST_F(ImageDecoders, GIFMultiChunk)
{
CheckDecoderMultiChunk(GreenGIFTestCase());
@ -611,6 +680,11 @@ TEST_F(ImageDecoders, JPGSingleChunk)
CheckDecoderSingleChunk(GreenJPGTestCase());
}
TEST_F(ImageDecoders, JPGDelayedChunk)
{
CheckDecoderDelayedChunk(GreenJPGTestCase());
}
TEST_F(ImageDecoders, JPGMultiChunk)
{
CheckDecoderMultiChunk(GreenJPGTestCase());
@ -626,6 +700,11 @@ TEST_F(ImageDecoders, BMPSingleChunk)
CheckDecoderSingleChunk(GreenBMPTestCase());
}
TEST_F(ImageDecoders, BMPDelayedChunk)
{
CheckDecoderDelayedChunk(GreenBMPTestCase());
}
TEST_F(ImageDecoders, BMPMultiChunk)
{
CheckDecoderMultiChunk(GreenBMPTestCase());
@ -641,6 +720,11 @@ TEST_F(ImageDecoders, ICOSingleChunk)
CheckDecoderSingleChunk(GreenICOTestCase());
}
TEST_F(ImageDecoders, ICODelayedChunk)
{
CheckDecoderDelayedChunk(GreenICOTestCase());
}
TEST_F(ImageDecoders, ICOMultiChunk)
{
CheckDecoderMultiChunk(GreenICOTestCase());
@ -661,6 +745,11 @@ TEST_F(ImageDecoders, IconSingleChunk)
CheckDecoderSingleChunk(GreenIconTestCase());
}
TEST_F(ImageDecoders, IconDelayedChunk)
{
CheckDecoderDelayedChunk(GreenIconTestCase());
}
TEST_F(ImageDecoders, IconMultiChunk)
{
CheckDecoderMultiChunk(GreenIconTestCase());
@ -676,6 +765,11 @@ TEST_F(ImageDecoders, WebPSingleChunk)
CheckDecoderSingleChunk(GreenWebPTestCase());
}
TEST_F(ImageDecoders, WebPDelayedChunk)
{
CheckDecoderDelayedChunk(GreenWebPTestCase());
}
TEST_F(ImageDecoders, WebPMultiChunk)
{
CheckDecoderMultiChunk(GreenWebPTestCase());

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

@ -60,7 +60,8 @@ CheckMetadata(const ImageTestCase& aTestCase,
RefPtr<Decoder> decoder =
DecoderFactory::CreateAnonymousMetadataDecoder(decoderType, sourceBuffer);
ASSERT_TRUE(decoder != nullptr);
RefPtr<IDecodingTask> task = new AnonymousDecodingTask(WrapNotNull(decoder));
RefPtr<IDecodingTask> task =
new AnonymousDecodingTask(WrapNotNull(decoder), /* aResumable */ false);
if (aBMPWithinICO == BMPWithinICO::YES) {
static_cast<nsBMPDecoder*>(decoder.get())->SetIsWithinICO();
@ -111,7 +112,7 @@ CheckMetadata(const ImageTestCase& aTestCase,
DecoderFlags::FIRST_FRAME_ONLY,
DefaultSurfaceFlags());
ASSERT_TRUE(decoder != nullptr);
task = new AnonymousDecodingTask(WrapNotNull(decoder));
task = new AnonymousDecodingTask(WrapNotNull(decoder), /* aResumable */ false);
if (aBMPWithinICO == BMPWithinICO::YES) {
static_cast<nsBMPDecoder*>(decoder.get())->SetIsWithinICO();

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

@ -36,7 +36,8 @@ if CONFIG['CPU_ARCH'] == 'arm' and CONFIG['BUILD_ARM_NEON']:
for f in SOURCES:
if f.endswith('neon.c'):
SOURCES[f].flags += CONFIG['NEON_FLAGS']
elif CONFIG['CPU_ARCH'] == 'aarch64':
elif CONFIG['CPU_ARCH'] == 'aarch64' and CONFIG['OS_ARCH'] != 'WINNT':
# Bug 1504017 tracks re-enabling this for Windows.
SOURCES += [
'alpha_processing_neon.c',
'dec_neon.c',

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

@ -205,7 +205,6 @@ class NavigationDelegateTest : BaseSessionTest() {
})
}
@Ignore
@Test fun redirectLoad() {
val redirectUri = if (sessionRule.env.isAutomation) {
"http://example.org/tests/robocop/robocop_blank_02.html"

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

@ -5281,10 +5281,6 @@ pref("io.activity.intervalMilliseconds", 0);
// to take effect.
pref("jsloader.shareGlobal", true);
// When we're asked to take a screenshot, don't wait more than 2000ms for the
// event loop to become idle before actually taking the screenshot.
pref("dom.browserElement.maxScreenshotDelayMS", 2000);
// Whether we should show the placeholder when the element is focused but empty.
pref("dom.placeholder.show_on_focus", true);

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

@ -242,7 +242,7 @@ Task group: https://tools.taskcluster.net/push-inspector/#/{task_group_id}
subject = '{} Build of {} {} build {}'.format(subject_prefix, product, version, build_number)
notify_options = {}
if 'TASKCLUSTER_BASE_URL' in os.environ:
if 'TASKCLUSTER_PROXY_URL' in os.environ:
base_url = os.environ['TASKCLUSTER_PROXY_URL'].rstrip('/')
notify_options['baseUrl'] = '{}/notify/v1'.format(base_url)
notify = Notify(notify_options)

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

@ -1729,53 +1729,6 @@ gfx.omtp:
record_in_processes:
- 'content'
images.webp:
probe_observed:
bug_numbers:
- 1472145
description: >
Whether we received a probe detecting our WebP image support.
kind: boolean
expires: "65"
notification_emails:
- gfx-telemetry-alerts@mozilla.com
- aosmond@mozilla.com
release_channel_collection: opt-out
record_in_processes:
- 'main'
- 'content'
content_observed:
bug_numbers:
- 1472145
description: >
Whether we received a request to decode a WebP image, excluding probes.
kind: boolean
expires: "65"
notification_emails:
- gfx-telemetry-alerts@mozilla.com
- aosmond@mozilla.com
release_channel_collection: opt-out
record_in_processes:
- 'main'
- 'content'
content_frequency:
bug_numbers:
- 1472145
description: >
How many image requests are WebP images, excluding probes.
kind: uint
keyed: true
expires: "65"
notification_emails:
- gfx-telemetry-alerts@mozilla.com
- aosmond@mozilla.com
release_channel_collection: opt-out
record_in_processes:
- 'main'
- 'content'
# The following section contains the form autofill related scalars.
formautofill:
availability:

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

@ -34,6 +34,8 @@
#include "nsIDocument.h"
#include "nsPresContext.h"
#include "nsIAsyncVerifyRedirectCallback.h"
#include "nsILoadURIDelegate.h"
#include "nsIBrowserDOMWindow.h"
using mozilla::dom::ContentBlockingLog;
using mozilla::DebugOnly;
@ -1424,6 +1426,36 @@ NS_IMETHODIMP nsDocLoader::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
uint32_t aFlags,
nsIAsyncVerifyRedirectCallback *cb)
{
if (aFlags &
(nsIChannelEventSink::REDIRECT_TEMPORARY |
nsIChannelEventSink::REDIRECT_PERMANENT)) {
nsCOMPtr<nsIDocShell> docShell =
do_QueryInterface(static_cast<nsIRequestObserver*>(this));
nsCOMPtr<nsILoadURIDelegate> delegate;
if (docShell) {
docShell->GetLoadURIDelegate(getter_AddRefs(delegate));
}
nsCOMPtr<nsIURI> newURI;
if (delegate) {
// No point in getting the URI if we don't have a LoadURIDelegate.
aNewChannel->GetURI(getter_AddRefs(newURI));
}
if (newURI) {
const int where = nsIBrowserDOMWindow::OPEN_CURRENTWINDOW;
bool loadURIHandled = false;
nsresult rv = delegate->LoadURI(newURI, where, /* flags */ 0,
/* triggering principal */ nullptr,
&loadURIHandled);
if (NS_SUCCEEDED(rv) && loadURIHandled) {
cb->OnRedirectVerifyCallback(NS_OK);
return NS_OK;
}
}
}
if (aOldChannel)
{
nsLoadFlags loadFlags = 0;