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

Unified Diff: chrome/test/data/extensions/platform_apps/web_view/clear_data_cache/guest.js

Issue 1056793002: Move clear cache code from chrome/ (ChromeWVGDelegate) to extensions/ (WVGuest) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-spbdr
Patch Set: fix test on windows Created 5 years, 8 months 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/platform_apps/web_view/clear_data_cache/guest.js
diff --git a/chrome/test/data/extensions/platform_apps/web_view/clear_data_cache/guest.js b/chrome/test/data/extensions/platform_apps/web_view/clear_data_cache/guest.js
index 6b90df3fabbf1d16cf71503ae8e3fe6e4a24e77d..72b5aea7aece42d7e90b3154464299f959f25524 100644
--- a/chrome/test/data/extensions/platform_apps/web_view/clear_data_cache/guest.js
+++ b/chrome/test/data/extensions/platform_apps/web_view/clear_data_cache/guest.js
@@ -5,24 +5,33 @@
var LOG = function(msg) { window.console.log(msg); };
LOG('Guest script loading.');
-// The window reference of the embedder to send post message reply.
-var embedderWindowChannel = null;
+var fail = function() {
+ // Embedder catches this message and fails the test.
+ LOG('ERROR');
+};
-// A value that uniquely identifies the guest sending the messages to the
-// embedder.
-var channelId = 0;
-var notifyEmbedder = function(msg_array) {
- var msg = msg_array.concat([channelId]);
- embedderWindowChannel.postMessage(JSON.stringify(msg), '*');
+var sendXhr = function() {
+ var xhr = new XMLHttpRequest();
+ xhr.onload = function() {
+ LOG('xhr.onload');
+ if (xhr.responseText != 'dummy text') {
+ fail();
+ }
+ };
+ xhr.onerror = function() {
+ fail();
+ };
+ xhr.open('GET', '/cache-control-response', true);
+ xhr.send();
};
var onPostMessageReceived = function(e) {
- embedderWindowChannel = e.source;
var data = JSON.parse(e.data);
- if (data[0] == 'connect') {
- channelId = data[1];
- notifyEmbedder(['connected']);
+ if (data[0] != 'sendXhr') {
+ fail();
return;
}
+
+ sendXhr();
};
window.addEventListener('message', onPostMessageReceived, false);

Powered by Google App Engine
This is Rietveld 408576698