Backed out changeset d1cd8175cc47 (bug 1288276)

--HG--
extra : rebase_source : 2a54594aa1e55fc06f411824226460745e4bb9c7
This commit is contained in:
Carsten "Tomcat" Book 2016-08-05 15:31:41 +02:00
Родитель 25a51b27dc
Коммит 094203dbf2
5 изменённых файлов: 2 добавлений и 136 удалений

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

@ -4,7 +4,7 @@
"use strict";
this.EXPORTED_SYMBOLS = ["Extension", "ExtensionData", "InternalTestAPI"];
this.EXPORTED_SYMBOLS = ["Extension", "ExtensionData"];
/* globals Extension ExtensionData */
@ -1555,13 +1555,3 @@ Extension.prototype = extend(Object.create(ExtensionData.prototype), {
return this.localize(this.manifest.name);
},
});
// Expose a limited subset of the Management API for testing.
this.InternalTestAPI = {
on(...args) {
return Management.on(...args);
},
off(...args) {
return Management.off(...args);
},
};

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

@ -1409,7 +1409,7 @@ class ChildAPIManager {
}
close() {
this.messageManager.sendAsyncMessage("API:CloseProxyContext", {childId: this.id});
this.messageManager.sendAsyncMessage("Extension:CloseProxyContext", {childId: this.id});
}
get cloneScope() {

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

@ -1,24 +0,0 @@
"use strict";
/* globals addMessageListener */
let {InternalTestAPI} = Components.utils.import("resource://gre/modules/Extension.jsm");
let events = [];
function record(type, extensionContext) {
let eventType = type == "page-load" ? "load" : "unload";
let url = extensionContext.uri.spec;
let {extensionId} = extensionContext;
events.push({eventType, url, extensionId});
}
InternalTestAPI.on("page-load", record);
InternalTestAPI.on("page-unload", record);
addMessageListener("cleanup", () => {
InternalTestAPI.off("page-load", record);
InternalTestAPI.off("page-unload", record);
});
addMessageListener("get-context-events", extensionId => {
sendAsyncMessage("context-events", events);
events = [];
});
sendAsyncMessage("chromescript-startup");

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

@ -34,7 +34,6 @@ support-files =
file_privilege_escalation.html
file_ext_test_api_injection.js
file_permission_xhr.html
file_teardown_test.js
[test_ext_inIncognitoContext_window.html]
skip-if = os == 'android' # Android does not currently support windows.
@ -48,7 +47,6 @@ skip-if = buildapp == 'b2g' # runat != document_idle is not supported.
[test_ext_contentscript_devtools_metadata.html]
[test_ext_contentscript_exporthelpers.html]
[test_ext_contentscript_css.html]
[test_ext_contentscript_teardown.html]
[test_ext_exclude_include_globs.html]
[test_ext_i18n_css.html]
[test_ext_generate.html]

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

@ -1,98 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for content script teardown</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
</head>
<body>
<script>
"use strict";
add_task(function* test_contentscript_reload_and_unload() {
function contentScript() {
browser.test.sendMessage("contentscript-run");
}
function backgroundScript() {
let removedTabs = 0;
browser.tabs.onRemoved.addListener(() => {
browser.test.assertEq(1, ++removedTabs,
"Expected only one tab to be removed during the test");
browser.test.sendMessage("tab-closed");
});
browser.test.sendMessage("background-ready");
}
let extensionData = {
background: `(${backgroundScript})();`,
manifest: {
content_scripts: [{
"matches": ["http://mochi.test/*/file_sample.html"],
"js": ["contentscript.js"],
}],
},
files: {
"contentscript.js": `(${contentScript})();`,
},
};
let extension = ExtensionTestUtils.loadExtension(extensionData);
yield extension.startup();
yield extension.awaitMessage("background-ready");
let chromeScript = SpecialPowers.loadChromeScript(
SimpleTest.getTestFileURL("file_teardown_test.js"));
yield chromeScript.promiseOneMessage("chromescript-startup");
function* getContextEvents() {
chromeScript.sendAsyncMessage("get-context-events");
let contextEvents = yield chromeScript.promiseOneMessage("context-events");
return contextEvents.filter(event => event.extensionId == extension.id);
}
let win = window.open("file_sample.html");
yield extension.awaitMessage("contentscript-run");
let tabUrl = win.location.href;
let contextEvents = yield* getContextEvents();
is(contextEvents.length, 1,
"ExtensionContext state change after loading a content script");
is(contextEvents[0].eventType, "load",
"Create ExtensionContext for content script");
is(contextEvents[0].url, tabUrl, "ExtensionContext URL = page");
let promiseReload = extension.awaitMessage("contentscript-run");
win.location.reload();
yield promiseReload;
contextEvents = yield* getContextEvents();
is(contextEvents.length, 2,
"ExtensionContext state changes after reloading a content script");
is(contextEvents[0].eventType, "unload", "Unload old ExtensionContext");
is(contextEvents[0].url, tabUrl, "ExtensionContext URL = page");
is(contextEvents[1].eventType, "load",
"Create new ExtensionContext for content script");
is(contextEvents[1].url, tabUrl, "ExtensionContext URL = page");
let tabClosePromise = extension.awaitMessage("tab-closed");
win.close();
yield tabClosePromise;
contextEvents = yield* getContextEvents();
is(contextEvents.length, 1,
"ExtensionContext state change after unloading a content script");
is(contextEvents[0].eventType, "unload",
"Unload ExtensionContext after closing the tab with the content script");
is(contextEvents[0].url, tabUrl, "ExtensionContext URL = page");
chromeScript.sendAsyncMessage("cleanup");
chromeScript.destroy();
yield extension.unload();
});
</script>
</body>
</html>