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

Unified Diff: chrome/test/data/webui/net_internals/net_internals_test.js

Issue 8892006: Fix reentrancy bug in NetInternalsTest.NetInternalsDnsViewIncognitoClears. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Update comments Created 9 years 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 | « chrome/test/data/webui/net_internals/dns_view.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/net_internals/net_internals_test.js
===================================================================
--- chrome/test/data/webui/net_internals/net_internals_test.js (revision 113807)
+++ chrome/test/data/webui/net_internals/net_internals_test.js (working copy)
@@ -424,18 +424,51 @@
}
};
- // Creates an incognito window. May not be called if there already is an
- // incognito in exitence. Returns immediately.
- function getCreateIncognitoBrowserTask() {
- return new CallFunctionTask(
- function() {
- chrome.send('createIncognitoBrowser');
- });
+ /**
+ * A Task that creates an incognito window and only completes once it has
+ * navigated to about:blank. The waiting is required to avoid reentrancy
+ * issues, since the function to create the incognito browser also waits
+ * for the navigation to complete. May not be called if there's already an
+ * incognito browser in existence.
+ * @constructor
+ */
+ function CreateIncognitoBrowserTask() {
+ Task.call(this);
+ }
+
+ CreateIncognitoBrowserTask.prototype = {
+ __proto__: Task.prototype,
+
+ /**
+ * Tells the browser process to create an incognito browser, and sets
+ * up a callback to be called on completion.
+ */
+ start: function() {
+ // Reuse the BrowserBridge's callback mechanism, since it's already
+ // wrapped in our test harness.
+ assertEquals('undefined',
+ typeof g_browser.onIncognitoBrowserCreatedForTest);
+ g_browser.onIncognitoBrowserCreatedForTest =
+ this.onIncognitoBrowserCreatedForTest.bind(this);
+
+ chrome.send('createIncognitoBrowser');
+ },
+
+ /**
+ * Deletes the callback function, and completes the task.
+ */
+ onIncognitoBrowserCreatedForTest: function() {
+ delete g_browser.onIncognitoBrowserCreatedForTest;
+ this.onTaskDone();
+ }
};
- // Closes an incognito window created with the task above. May only be
- // called if there's an incognito window created by the above function
- // that has yet to be closed. Returns immediately.
+ /**
+ * Returns a task that closes an incognito window created with the task
+ * above. May only be called if there's an incognito window created by
+ * the above function that has yet to be closed. Returns immediately.
+ * @return {Task} Task that closes incognito browser window.
+ */
function getCloseIncognitoBrowserTask() {
return new CallFunctionTask(
function() {
@@ -530,7 +563,7 @@
TaskQueue: TaskQueue,
Task: Task,
CallFunctionTask: CallFunctionTask,
- getCreateIncognitoBrowserTask: getCreateIncognitoBrowserTask,
+ CreateIncognitoBrowserTask: CreateIncognitoBrowserTask,
getCloseIncognitoBrowserTask: getCloseIncognitoBrowserTask,
Source: Source,
Event: Event,
« no previous file with comments | « chrome/test/data/webui/net_internals/dns_view.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698