mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 07:34:20 +00:00
Bug 709759 - Add stop() to mozbrowser API. r=jlebar
This commit is contained in:
parent
20c8f2a2b0
commit
8d89988f31
@ -122,6 +122,7 @@ BrowserElementChild.prototype = {
|
||||
addMsgListener("go-back", this._recvGoBack);
|
||||
addMsgListener("go-forward", this._recvGoForward);
|
||||
addMsgListener("reload", this._recvReload);
|
||||
addMsgListener("stop", this._recvStop);
|
||||
addMsgListener("unblock-modal-prompt", this._recvStopWaiting);
|
||||
addMsgListener("fire-ctx-callback", this._recvFireCtxCallback);
|
||||
|
||||
@ -481,6 +482,11 @@ BrowserElementChild.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
_recvStop: function(data) {
|
||||
let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
|
||||
webNav.stop(webNav.STOP_NETWORK);
|
||||
},
|
||||
|
||||
_keyEventHandler: function(e) {
|
||||
if (whitelistedEvents.indexOf(e.keyCode) != -1 && !e.defaultPrevented) {
|
||||
sendAsyncMsg('keyevent', {
|
||||
|
@ -169,6 +169,7 @@ function BrowserElementParent(frameLoader) {
|
||||
defineMethod('goBack', this._goBack);
|
||||
defineMethod('goForward', this._goForward);
|
||||
defineMethod('reload', this._reload);
|
||||
defineMethod('stop', this._stop);
|
||||
defineDOMRequestMethod('getScreenshot', 'get-screenshot');
|
||||
defineDOMRequestMethod('getCanGoBack', 'get-can-go-back');
|
||||
defineDOMRequestMethod('getCanGoForward', 'get-can-go-forward');
|
||||
@ -341,6 +342,10 @@ BrowserElementParent.prototype = {
|
||||
this._sendAsyncMsg('reload', {hardReload: hardReload});
|
||||
},
|
||||
|
||||
_stop: function() {
|
||||
this._sendAsyncMsg('stop');
|
||||
},
|
||||
|
||||
_fireKeyEvent: function(data) {
|
||||
let evt = this._window.document.createEvent("KeyboardEvent");
|
||||
evt.initKeyEvent(data.json.type, true, true, this._window,
|
||||
|
@ -81,6 +81,9 @@ MOCHITEST_FILES = \
|
||||
browserElement_BackForward.js \
|
||||
file_bug741717.sjs \
|
||||
browserElement_Reload.js \
|
||||
file_bug709759.sjs \
|
||||
browserElement_Stop.js \
|
||||
test_browserElement_inproc_Stop.html \
|
||||
browserElement_ContextmenuEvents.js \
|
||||
test_browserElement_inproc_ContextmenuEvents.html \
|
||||
$(NULL)
|
||||
@ -119,6 +122,7 @@ MOCHITEST_FILES += \
|
||||
test_browserElement_oop_SecurityChange.html \
|
||||
test_browserElement_oop_BackForward.html \
|
||||
test_browserElement_oop_Reload.html \
|
||||
test_browserElement_oop_Stop.html \
|
||||
test_browserElement_oop_ContextmenuEvents.html \
|
||||
$(NULL)
|
||||
endif #}
|
||||
|
42
dom/browser-element/mochitest/browserElement_Stop.js
Normal file
42
dom/browser-element/mochitest/browserElement_Stop.js
Normal file
@ -0,0 +1,42 @@
|
||||
/* Any copyright is dedicated to the public domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Bug 709759 - Test the stop ability of <iframe mozbrowser>.
|
||||
|
||||
// The img that is loaded will never be returned and will block
|
||||
// the page from loading, the timeout ensures that the page is
|
||||
// actually blocked from loading, once stop is called the
|
||||
// image load will be cancaelled and mozbrowserloadend should be called.
|
||||
|
||||
"use strict";
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var iframe;
|
||||
var stopped = false;
|
||||
var imgSrc = 'http://test/tests/dom/browser-element/mochitest/file_bug709759.sjs';
|
||||
|
||||
function runTest() {
|
||||
browserElementTestHelpers.setEnabledPref(true);
|
||||
browserElementTestHelpers.addToWhitelist();
|
||||
|
||||
iframe = document.createElement('iframe');
|
||||
iframe.mozbrowser = true;
|
||||
|
||||
iframe.addEventListener('mozbrowserloadend', loadend);
|
||||
iframe.src = 'data:text/html,<html>' +
|
||||
'<body><img src="' + imgSrc + '" /></body></html>';
|
||||
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
setTimeout(function() {
|
||||
stopped = true;
|
||||
iframe.stop();
|
||||
}, 200);
|
||||
}
|
||||
|
||||
function loadend() {
|
||||
ok(stopped, 'Iframes network connections were stopped');
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
runTest();
|
5
dom/browser-element/mochitest/file_bug709759.sjs
Normal file
5
dom/browser-element/mochitest/file_bug709759.sjs
Normal file
@ -0,0 +1,5 @@
|
||||
function handleRequest(request, response)
|
||||
{
|
||||
response.processAsync();
|
||||
response.setHeader("Content-Type", "image/jpeg", false);
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<!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;version=1.7" src="browserElement_Stop.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,13 @@
|
||||
<!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;version=1.7" src="browserElement_Stop.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user