Commit 7ad4c92a authored by mmenke@chromium.org's avatar mmenke@chromium.org

net-internals: Fix cookies not being hidden

when clicking "stop loading" and then creating a log
dump.  Also fix a regression where we don't display
a file name when loading a log dump.

R=eroman@chromium.org
BUG=128425
Review URL: https://chromiumcodereview.appspot.com/10332238

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138489 0039d316-1c4b-4281-b951-d872f2087c98
parent ecdb2772
...@@ -146,7 +146,7 @@ var ImportView = (function() { ...@@ -146,7 +146,7 @@ var ImportView = (function() {
}, },
onLoadLogFile: function(logFile, event) { onLoadLogFile: function(logFile, event) {
var result = log_util.loadLogFile(event.target.result, logFile.fileName); var result = log_util.loadLogFile(event.target.result, logFile.name);
this.setLoadFileStatus(result, false); this.setLoadFileStatus(result, false);
}, },
......
...@@ -169,14 +169,17 @@ var MainView = (function() { ...@@ -169,14 +169,17 @@ var MainView = (function() {
onLoadLog: function(opt_fileName) { onLoadLog: function(opt_fileName) {
isViewingLoadedLog = true; isViewingLoadedLog = true;
SourceTracker.getInstance().setSecurityStripping(false);
this.stopCapturing(); this.stopCapturing();
if (opt_fileName != undefined) { if (opt_fileName != undefined) {
// If there's a file name, a log file was loaded, so swap out the status // If there's a file name, a log file was loaded, so swap out the status
// bar to indicate we're no longer capturing events. // bar to indicate we're no longer capturing events. Also disable
// hiding cookies, so if the log dump has them, they'll be displayed.
this.statusView_.switchToSubView('loaded').setFileName(opt_fileName); this.statusView_.switchToSubView('loaded').setFileName(opt_fileName);
SourceTracker.getInstance().setSecurityStripping(false);
} else { } else {
// Otherwise, the "Stop Capturing" button was presumably pressed. // Otherwise, the "Stop Capturing" button was presumably pressed.
// Don't disable hiding cookies, so created log dumps won't have them,
// unless the user toggles the option.
this.statusView_.switchToSubView('halted'); this.statusView_.switchToSubView('halted');
} }
}, },
......
...@@ -37,6 +37,8 @@ CreateAndLoadLogTask.prototype = { ...@@ -37,6 +37,8 @@ CreateAndLoadLogTask.prototype = {
* ones, depending on whether or not we're currently viewing a log. * ones, depending on whether or not we're currently viewing a log.
*/ */
start: function() { start: function() {
this.initialSecurityStripping_ =
SourceTracker.getInstance().getSecurityStripping();
$(ExportView.USER_COMMENTS_TEXT_AREA_ID).value = this.userComments_; $(ExportView.USER_COMMENTS_TEXT_AREA_ID).value = this.userComments_;
ExportView.getInstance().createLogDump_(this.onLogDumpCreated.bind(this), ExportView.getInstance().createLogDump_(this.onLogDumpCreated.bind(this),
true); true);
...@@ -48,7 +50,10 @@ CreateAndLoadLogTask.prototype = { ...@@ -48,7 +50,10 @@ CreateAndLoadLogTask.prototype = {
* @param {string} logDumpText Log dump, as a string. * @param {string} logDumpText Log dump, as a string.
*/ */
onLogDumpCreated: function(logDumpText) { onLogDumpCreated: function(logDumpText) {
expectEquals(this.initialSecurityStripping_,
SourceTracker.getInstance().getSecurityStripping());
expectEquals('Log loaded.', log_util.loadLogFile(logDumpText, 'log.txt')); expectEquals('Log loaded.', log_util.loadLogFile(logDumpText, 'log.txt'));
expectFalse(SourceTracker.getInstance().getSecurityStripping());
NetInternalsTest.expectStatusViewNodeVisible(LoadedStatusView.MAIN_BOX_ID); NetInternalsTest.expectStatusViewNodeVisible(LoadedStatusView.MAIN_BOX_ID);
...@@ -120,6 +125,11 @@ function checkViewsAfterLogLoaded() { ...@@ -120,6 +125,11 @@ function checkViewsAfterLogLoaded() {
NetInternalsTest.checkTabHandleVisibility(tabVisibilityState, false); NetInternalsTest.checkTabHandleVisibility(tabVisibilityState, false);
} }
function checkSecurityStripping(expectedValue) {
expectEquals(expectedValue,
SourceTracker.getInstance().getSecurityStripping());
}
/** /**
* Exports a log dump to a string and loads it. Makes sure no errors occur, * Exports a log dump to a string and loads it. Makes sure no errors occur,
* and checks visibility of tabs aftwards. Does not actually save the log to a * and checks visibility of tabs aftwards. Does not actually save the log to a
...@@ -129,6 +139,7 @@ function checkViewsAfterLogLoaded() { ...@@ -129,6 +139,7 @@ function checkViewsAfterLogLoaded() {
*/ */
TEST_F('NetInternalsTest', 'netInternalsExportImportDump', function() { TEST_F('NetInternalsTest', 'netInternalsExportImportDump', function() {
expectFalse(g_browser.isDisabled()); expectFalse(g_browser.isDisabled());
expectTrue(SourceTracker.getInstance().getSecurityStripping());
NetInternalsTest.expectStatusViewNodeVisible(CaptureStatusView.MAIN_BOX_ID); NetInternalsTest.expectStatusViewNodeVisible(CaptureStatusView.MAIN_BOX_ID);
var taskQueue = new NetInternalsTest.TaskQueue(true); var taskQueue = new NetInternalsTest.TaskQueue(true);
...@@ -163,6 +174,7 @@ TEST_F('NetInternalsTest', 'netInternalsStopCapturing', function() { ...@@ -163,6 +174,7 @@ TEST_F('NetInternalsTest', 'netInternalsStopCapturing', function() {
NetInternalsTest.expectStatusViewNodeVisible.bind( NetInternalsTest.expectStatusViewNodeVisible.bind(
null, HaltedStatusView.MAIN_BOX_ID)); null, HaltedStatusView.MAIN_BOX_ID));
taskQueue.addFunctionTask(checkViewsAfterLogLoaded); taskQueue.addFunctionTask(checkViewsAfterLogLoaded);
taskQueue.addFunctionTask(checkSecurityStripping.bind(null, true));
taskQueue.run(); taskQueue.run();
// Simulate a click on the stop capturing button. // Simulate a click on the stop capturing button.
...@@ -182,6 +194,7 @@ TEST_F('NetInternalsTest', 'netInternalsStopCapturingExportImport', function() { ...@@ -182,6 +194,7 @@ TEST_F('NetInternalsTest', 'netInternalsStopCapturingExportImport', function() {
NetInternalsTest.expectStatusViewNodeVisible.bind( NetInternalsTest.expectStatusViewNodeVisible.bind(
null, HaltedStatusView.MAIN_BOX_ID)); null, HaltedStatusView.MAIN_BOX_ID));
taskQueue.addFunctionTask(checkViewsAfterLogLoaded); taskQueue.addFunctionTask(checkViewsAfterLogLoaded);
taskQueue.addFunctionTask(checkSecurityStripping.bind(null, true));
taskQueue.addTask(new CreateAndLoadLogTask('Detailed explanation.')); taskQueue.addTask(new CreateAndLoadLogTask('Detailed explanation.'));
taskQueue.addFunctionTask(checkViewsAfterLogLoaded); taskQueue.addFunctionTask(checkViewsAfterLogLoaded);
taskQueue.run(); taskQueue.run();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment