зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1257488 - Fix test_gzip_offline.html to work with e10s enabled, r=mayhemer
MozReview-Commit-ID: Fv3ECOAlJ2b --HG-- extra : rebase_source : 9ed438f8d76ce821f57ebc5c0ae24ba2686726f5
This commit is contained in:
Родитель
d9987b06e1
Коммит
aefa743971
|
@ -351,6 +351,9 @@ skip-if = os != "win" # The Fitts Law menu button is only supported on Windows (
|
|||
tags = mcb
|
||||
[browser_offlineQuotaNotification.js]
|
||||
skip-if = buildapp == 'mulet' || e10s # Bug 1093603 - test breaks with PopupNotifications.panel.firstElementChild is null
|
||||
[browser_gZipOfflineChild.js]
|
||||
skip-if = buildapp == 'mulet' # Bug 1066070 - I don't think either popup notifications nor addon install stuff works?
|
||||
support-files = test_offline_gzip.html gZipOfflineChild.cacheManifest gZipOfflineChild.cacheManifest^headers^ gZipOfflineChild.html gZipOfflineChild.html^headers^
|
||||
[browser_openPromptInBackgroundTab.js]
|
||||
support-files = openPromptOffTimeout.html
|
||||
[browser_overflowScroll.js]
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
const URL = "http://mochi.test:8888/browser/browser/base/content/test/general/test_offline_gzip.html"
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
// Clean up after ourself
|
||||
let uri = Services.io.newURI(URL, null, null);
|
||||
let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
|
||||
Services.perms.removeFromPrincipal(principal, "offline-app");
|
||||
Services.prefs.clearUserPref("offline-apps.allow_by_default");
|
||||
});
|
||||
|
||||
var cacheCount = 0;
|
||||
var intervalID = 0;
|
||||
|
||||
////
|
||||
// Handle "message" events which are posted from the iframe upon
|
||||
// offline cache events.
|
||||
//
|
||||
function handleMessageEvents(event) {
|
||||
cacheCount++;
|
||||
switch (cacheCount) {
|
||||
case 1:
|
||||
// This is the initial caching off offline data.
|
||||
is(event.data, "oncache", "Child was successfully cached.");
|
||||
// Reload the frame; this will generate an error message
|
||||
// in the case of bug 501422.
|
||||
event.source.location.reload();
|
||||
// Use setInterval to repeatedly call a function which
|
||||
// checks that one of two things has occurred: either
|
||||
// the offline cache is udpated (which means our iframe
|
||||
// successfully reloaded), or the string "error" appears
|
||||
// in the iframe, as in the case of bug 501422.
|
||||
intervalID = setInterval(function() {
|
||||
// Sometimes document.body may not exist, and trying to access
|
||||
// it will throw an exception, so handle this case.
|
||||
try {
|
||||
var bodyInnerHTML = event.source.document.body.innerHTML;
|
||||
}
|
||||
catch (e) {
|
||||
var bodyInnerHTML = "";
|
||||
}
|
||||
if (cacheCount == 2 || bodyInnerHTML.includes("error")) {
|
||||
clearInterval(intervalID);
|
||||
is(cacheCount, 2, "frame not reloaded successfully");
|
||||
if (cacheCount != 2) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
break;
|
||||
case 2:
|
||||
is(event.data, "onupdate", "Child was successfully updated.");
|
||||
clearInterval(intervalID);
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
// how'd we get here?
|
||||
ok(false, "cacheCount not 1 or 2");
|
||||
}
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
Services.prefs.setBoolPref("offline-apps.allow_by_default", true);
|
||||
|
||||
// Open a new tab.
|
||||
gBrowser.selectedTab = gBrowser.addTab(URL);
|
||||
registerCleanupFunction(() => gBrowser.removeCurrentTab());
|
||||
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
|
||||
let window = gBrowser.selectedBrowser.contentWindow;
|
||||
|
||||
window.addEventListener("message", handleMessageEvents, false);
|
||||
});
|
||||
}
|
Двоичные данные
browser/base/content/test/general/gZipOfflineChild.html
Двоичные данные
browser/base/content/test/general/gZipOfflineChild.html
Двоичный файл не отображается.
|
@ -8,10 +8,6 @@ support-files =
|
|||
contextmenu_common.js
|
||||
ctxmenu-image.png
|
||||
feed_discovery.html
|
||||
gZipOfflineChild.cacheManifest
|
||||
gZipOfflineChild.cacheManifest^headers^
|
||||
gZipOfflineChild.html
|
||||
gZipOfflineChild.html^headers^
|
||||
head_plain.js
|
||||
offlineByDefault.js
|
||||
offlineChild.cacheManifest
|
||||
|
@ -32,5 +28,3 @@ support-files =
|
|||
skip-if = e10s
|
||||
[test_offlineNotification.html]
|
||||
skip-if = buildapp == 'mulet' || e10s # Bug 1066070 - I don't think either popup notifications nor addon install stuff works?
|
||||
[test_offline_gzip.html]
|
||||
skip-if = buildapp == 'mulet' || e10s # Bug 1066070 - I don't think either popup notifications nor addon install stuff works?
|
||||
|
|
|
@ -9,107 +9,13 @@ cache, it can be fetched from the cache successfully.
|
|||
-->
|
||||
<head>
|
||||
<title>Test gzipped offline resources</title>
|
||||
<script type="text/javascript"
|
||||
src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript"
|
||||
src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="offlineByDefault.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body onload="loaded()">
|
||||
<body>
|
||||
<p id="display">
|
||||
<iframe name="testFrame" src="gZipOfflineChild.html"></iframe>
|
||||
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var cacheCount = 0;
|
||||
var intervalID = 0;
|
||||
|
||||
window.addEventListener("message", handleMessageEvents, false);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function finishTest() {
|
||||
// Clean up after ourselves.
|
||||
var Cc = SpecialPowers.Cc;
|
||||
var pm = Cc["@mozilla.org/permissionmanager;1"].
|
||||
getService(SpecialPowers.Ci.nsIPermissionManager);
|
||||
|
||||
var uri = Cc["@mozilla.org/network/io-service;1"].getService(SpecialPowers.Ci.nsIIOService)
|
||||
.newURI(window.frames[0].location, null, null);
|
||||
var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
|
||||
.getService(SpecialPowers.Ci.nsIScriptSecurityManager);
|
||||
var principal = ssm.createCodebasePrincipal(uri, {});
|
||||
|
||||
pm.removeFromPrincipal(principal, "offline-app");
|
||||
|
||||
window.removeEventListener("message", handleMessageEvents, false);
|
||||
|
||||
offlineByDefault.reset();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
////
|
||||
// Handle "message" events which are posted from the iframe upon
|
||||
// offline cache events.
|
||||
//
|
||||
function handleMessageEvents(event) {
|
||||
cacheCount++;
|
||||
switch (cacheCount) {
|
||||
case 1:
|
||||
// This is the initial caching off offline data.
|
||||
is(event.data, "oncache", "Child was successfully cached.");
|
||||
// Reload the frame; this will generate an error message
|
||||
// in the case of bug 501422.
|
||||
frames.testFrame.window.location.reload();
|
||||
// Use setInterval to repeatedly call a function which
|
||||
// checks that one of two things has occurred: either
|
||||
// the offline cache is udpated (which means our iframe
|
||||
// successfully reloaded), or the string "error" appears
|
||||
// in the iframe, as in the case of bug 501422.
|
||||
intervalID = setInterval(function() {
|
||||
// Sometimes document.body may not exist, and trying to access
|
||||
// it will throw an exception, so handle this case.
|
||||
try {
|
||||
var bodyInnerHTML = frames.testFrame.document.body.innerHTML;
|
||||
}
|
||||
catch (e) {
|
||||
var bodyInnerHTML = "";
|
||||
}
|
||||
if (cacheCount == 2 || bodyInnerHTML.includes("error")) {
|
||||
clearInterval(intervalID);
|
||||
is(cacheCount, 2, "frame not reloaded successfully");
|
||||
if (cacheCount != 2) {
|
||||
finishTest();
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
break;
|
||||
case 2:
|
||||
is(event.data, "onupdate", "Child was successfully updated.");
|
||||
clearInterval(intervalID);
|
||||
finishTest();
|
||||
break;
|
||||
default:
|
||||
// how'd we get here?
|
||||
ok(false, "cacheCount not 1 or 2");
|
||||
}
|
||||
}
|
||||
|
||||
function loaded() {
|
||||
// Click the notification panel's "Allow" button. This should kick
|
||||
// off updates, which will eventually lead to getting messages from
|
||||
// the iframe.
|
||||
var wm = SpecialPowers.Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(SpecialPowers.Ci.nsIWindowMediator);
|
||||
var win = wm.getMostRecentWindow("navigator:browser");
|
||||
var panel = win.PopupNotifications.panel;
|
||||
panel.firstElementChild.button.click();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Загрузка…
Ссылка в новой задаче