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

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
« no previous file with comments | « tools/test.dart ('k') | tools/testing/dart/test_options.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,27 @@
"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 home = Platform.environment['HOME'];
+ var cache = "$home/Library/Caches/com.apple.Safari";
+ _logEvent("Clearing safari cache: $cache}");
+ return new Directory(cache).delete(recursive: true)
+ .then((_) => true)
+ // This normally means that the directory was not there.
+ .catchError((error) => true);
+ }
+
Future<String> getVersion() {
/**
* Example of the file:
@@ -242,28 +254,34 @@
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((_) {
+ // 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((error) {
+ _logEvent("Running $binary --version failed with $error");
+ return false;
});
- }).catchError((e) {
- _logEvent("Running $binary --version failed with $e");
- return false;
});
});
}
String toString() => "Safari";
+
+ // Delete the user specific browser cache and profile data.
+ // Safari only have one per user, and you can't specify one by command line.
+ static bool deleteCache = false;
+
}
« no previous file with comments | « tools/test.dart ('k') | tools/testing/dart/test_options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698