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

Unified Diff: tools/testing/dart/browser_controller.dart

Issue 17489002: Add safari cache clearing browser functionality to the safari browser. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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: tools/testing/dart/browser_controller.dart
===================================================================
--- tools/testing/dart/browser_controller.dart (revision 24128)
+++ tools/testing/dart/browser_controller.dart (working copy)
@@ -183,7 +183,6 @@
*/
const String versionFile = "/Applications/Safari.app/Contents/version.plist";
-
Future<bool> allowPopUps() {
var command = "defaults";
var args = ["write", "com.apple.safari",
@@ -191,14 +190,30 @@
"WebKit2JavaScriptCanOpenWindowsAutomatically",
"1"];
return Process.run(command, args).then((result) {
- if (result.exitCode != 0) {
- _logEvent("Could not disable pop-up blocking for safari");
- return false;
- }
- return true;
+ if (result.exitCode != 0) {
+ _logEvent("Could not disable pop-up blocking for safari");
+ return false;
+ }
+ return true;
});
}
+ // Clears the cache if the static deleteCache flag is set.
+ // Returns false if the command to actually clear the cache did not complete.
+ Future<bool> clearCache() {
+ if (!deleteCache) return new Future.immediate(true);
+ var command = "rm";
+ var args = ["-rf", "\$HOME/Library/Caches/com.apple.Safari"];
kustermann 2013/06/20 09:21:04 As discussed offline, this doesn't work. Please re
ricow1 2013/06/20 10:24:05 Done.
+ _logEvent("Clearing safari cache: $command ${args.join(' ')}");
+ return Process.run(command, args).then((result) {
+ if (result.exitCode != 0) {
+ _logEvent("Could not clear safari cache");
+ return false;
+ }
+ return true;
+ });
+ }
+
Future<String> getVersion() {
/**
* Example of the file:
@@ -242,28 +257,35 @@
Future<bool> start(String url) {
_logEvent("Starting Safari browser on: $url");
- // Get the version and log that.
return allowPopUps().then((success) {
if (!success) {
return new Future.immediate(false);
}
- return getVersion().then((version) {
- _logEvent("Got version: $version");
- var args = ["'$url'"];
- return new Directory('').createTemp().then((userDir) {
- _cleanup = () { userDir.deleteSync(recursive: true); };
- _createLaunchHTML(userDir.path, url);
- var args = ["${userDir.path}/launch.html"];
- return startBrowser(binary, args);
+ return clearCache().then((cleared) {
+ if (!cleared) {
+ return new Future.immediate(false);
+ }
+ // Get the version and log that.
+ return getVersion().then((version) {
+ _logEvent("Got version: $version");
+ return new Directory('').createTemp().then((userDir) {
+ _cleanup = () { userDir.deleteSync(recursive: true); };
+ _createLaunchHTML(userDir.path, url);
+ var args = ["${userDir.path}/launch.html"];
+ return startBrowser(binary, args);
+ });
+ }).catchError((e) {
kustermann 2013/06/20 09:21:04 e -> error.
ricow1 2013/06/20 10:24:05 Done.
+ _logEvent("Running $binary --version failed with $e");
+ return false;
});
- }).catchError((e) {
- _logEvent("Running $binary --version failed with $e");
- return false;
});
});
}
String toString() => "Safari";
+
+ static bool deleteCache = false;
kustermann 2013/06/20 09:21:04 Add a comment here.
ricow1 2013/06/20 10:24:05 Done.
+
}

Powered by Google App Engine
This is Rietveld 408576698