Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3161)

Unified Diff: chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js

Issue 684143002: Invalidate the previous frame when the window object is cleared. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use didCreateNewDocument notification Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js
diff --git a/chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js b/chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js
index c0a3918299a9ad29802932c16b137cb904fb5f05..5d08ce0a68dd5d10f773dea4f73eff7770fbdd86 100644
--- a/chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js
+++ b/chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js
@@ -2,25 +2,30 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+function checkFirstMessageEquals(expectedRequest) {
+ return function(request) {
+ if (request != expectedRequest)
+ chrome.test.fail('Unexpected request: ' + JSON.stringify(request));
+ // chrome.test.succeed() will be called by chrome.test.listenOnce().
+ // If this function is not used by chrome.test.listenOnce(), then
+ // call chrome.test.succeed() when you're done.
+ };
+}
+
+var onRequest = chrome.extension.onRequest;
chrome.test.getConfig(function(config) {
- chrome.extension.onRequest.addListener(
- function(request, sender, sendResponse) {
- if (request == 'parent')
- chrome.test.succeed();
- else
- chrome.test.fail('Unexpected request: ' + JSON.stringify(request));
- }
- );
chrome.test.runTests([
function testDontInjectInAboutBlankFrame() {
- chrome.test.log("Creating tab...");
+ chrome.test.listenOnce(onRequest, checkFirstMessageEquals('parent'));
+ chrome.test.log('Creating tab...');
var test_url =
- ("http://localhost:PORT/extensions/" +
- "test_file_with_about_blank_iframe.html")
+ ('http://localhost:PORT/extensions/' +
+ 'test_file_with_about_blank_iframe.html')
.replace(/PORT/, config.testServer.port);
chrome.tabs.create({ url: test_url });
},
function testDontInjectInAboutSrcdocFrame() {
+ chrome.test.listenOnce(onRequest, checkFirstMessageEquals('parent'));
chrome.test.log('Creating tab...');
var test_url =
('http://localhost:PORT/extensions/' +
@@ -29,12 +34,35 @@ chrome.test.getConfig(function(config) {
chrome.tabs.create({ url: test_url });
},
function testDontInjectInNestedAboutFrames() {
+ chrome.test.listenOnce(onRequest, checkFirstMessageEquals('parent'));
chrome.test.log('Creating tab...');
var test_url =
('http://localhost:PORT/extensions/' +
'test_file_with_about_blank_in_srcdoc.html')
.replace(/PORT/, config.testServer.port);
chrome.tabs.create({ url: test_url });
+ },
+ function testDocumentStartRunsInSameWorldAsDocumentEndOfJavaScriptUrl() {
+ var hasReceivedFirstMessage = false;
+ onRequest.addListener(function listener(request) {
+ if (!hasReceivedFirstMessage) {
+ hasReceivedFirstMessage = true;
+ // Step one: Empty document where the JavaScript code was executed.
+ checkFirstMessageEquals('jsresult/')(request);
+ } else {
+ onRequest.removeListener(listener);
+ // Step 2: The empty document was replaced with the result of
+ // the evaluated JavaScript code.
+ checkFirstMessageEquals('jsresult/something')(request);
+ chrome.test.succeed();
+ }
+ });
+ chrome.test.log('Creating tab...');
+ var test_url =
+ ('http://localhost:PORT/extensions/' +
+ 'test_file_with_javascript_url_iframe.html')
+ .replace(/PORT/, config.testServer.port);
+ chrome.tabs.create({ url: test_url });
}
]);
});

Powered by Google App Engine
This is Rietveld 408576698