| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview The way these tests work is as follows: | 6 * @fileoverview The way these tests work is as follows: |
| 7 * C++ in net_internals_ui_browsertest.cc does any necessary setup, and then | 7 * C++ in net_internals_ui_browsertest.cc does any necessary setup, and then |
| 8 * calls the entry point for a test with RunJavascriptTest. The called | 8 * calls the entry point for a test with RunJavascriptTest. The called |
| 9 * function can then use the assert/expect functions defined in test_api.js. | 9 * function can then use the assert/expect functions defined in test_api.js. |
| 10 * All callbacks from the browser are wrapped in such a way that they can | 10 * All callbacks from the browser are wrapped in such a way that they can |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 417 |
| 418 /** | 418 /** |
| 419 * Runs the function and then completes. | 419 * Runs the function and then completes. |
| 420 */ | 420 */ |
| 421 start: function() { | 421 start: function() { |
| 422 this.taskFunction_(); | 422 this.taskFunction_(); |
| 423 this.onTaskDone(); | 423 this.onTaskDone(); |
| 424 } | 424 } |
| 425 }; | 425 }; |
| 426 | 426 |
| 427 // Creates an incognito window. May not be called if there already is an | 427 /** |
| 428 // incognito in exitence. Returns immediately. | 428 * A Task that creates an incognito window and only completes once it has |
| 429 function getCreateIncognitoBrowserTask() { | 429 * navigated to about:blank. The waiting is required to avoid reentrancy |
| 430 return new CallFunctionTask( | 430 * issues, since the function to create the incognito browser also waits |
| 431 function() { | 431 * for the navigation to complete. May not be called if there's already an |
| 432 chrome.send('createIncognitoBrowser'); | 432 * incognito browser in existence. |
| 433 }); | 433 * @constructor |
| 434 */ |
| 435 function CreateIncognitoBrowserTask() { |
| 436 Task.call(this); |
| 437 } |
| 438 |
| 439 CreateIncognitoBrowserTask.prototype = { |
| 440 __proto__: Task.prototype, |
| 441 |
| 442 /** |
| 443 * Tells the browser process to create an incognito browser, and sets |
| 444 * up a callback to be called on completion. |
| 445 */ |
| 446 start: function() { |
| 447 // Reuse the BrowserBridge's callback mechanism, since it's already |
| 448 // wrapped in our test harness. |
| 449 assertEquals('undefined', |
| 450 typeof g_browser.onIncognitoBrowserCreatedForTest); |
| 451 g_browser.onIncognitoBrowserCreatedForTest = |
| 452 this.onIncognitoBrowserCreatedForTest.bind(this); |
| 453 |
| 454 chrome.send('createIncognitoBrowser'); |
| 455 }, |
| 456 |
| 457 /** |
| 458 * Deletes the callback function, and completes the task. |
| 459 */ |
| 460 onIncognitoBrowserCreatedForTest: function() { |
| 461 delete g_browser.onIncognitoBrowserCreatedForTest; |
| 462 this.onTaskDone(); |
| 463 } |
| 434 }; | 464 }; |
| 435 | 465 |
| 436 // Closes an incognito window created with the task above. May only be | 466 /** |
| 437 // called if there's an incognito window created by the above function | 467 * Returns a task that closes an incognito window created with the task |
| 438 // that has yet to be closed. Returns immediately. | 468 * above. May only be called if there's an incognito window created by |
| 469 * the above function that has yet to be closed. Returns immediately. |
| 470 * @return {Task} Task that closes incognito browser window. |
| 471 */ |
| 439 function getCloseIncognitoBrowserTask() { | 472 function getCloseIncognitoBrowserTask() { |
| 440 return new CallFunctionTask( | 473 return new CallFunctionTask( |
| 441 function() { | 474 function() { |
| 442 chrome.send('closeIncognitoBrowser'); | 475 chrome.send('closeIncognitoBrowser'); |
| 443 }); | 476 }); |
| 444 }; | 477 }; |
| 445 | 478 |
| 446 /** | 479 /** |
| 447 * Returns true if a node does not have a 'display' property of 'none'. | 480 * Returns true if a node does not have a 'display' property of 'none'. |
| 448 * @param {node}: node The node to check. | 481 * @param {node}: node The node to check. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 test: test, | 556 test: test, |
| 524 checkStyledTableRows: checkStyledTableRows, | 557 checkStyledTableRows: checkStyledTableRows, |
| 525 checkTabHandleVisibility: checkTabHandleVisibility, | 558 checkTabHandleVisibility: checkTabHandleVisibility, |
| 526 getStyledTableText: getStyledTableText, | 559 getStyledTableText: getStyledTableText, |
| 527 isDisplayed: isDisplayed, | 560 isDisplayed: isDisplayed, |
| 528 runTest: runTest, | 561 runTest: runTest, |
| 529 switchToView: switchToView, | 562 switchToView: switchToView, |
| 530 TaskQueue: TaskQueue, | 563 TaskQueue: TaskQueue, |
| 531 Task: Task, | 564 Task: Task, |
| 532 CallFunctionTask: CallFunctionTask, | 565 CallFunctionTask: CallFunctionTask, |
| 533 getCreateIncognitoBrowserTask: getCreateIncognitoBrowserTask, | 566 CreateIncognitoBrowserTask: CreateIncognitoBrowserTask, |
| 534 getCloseIncognitoBrowserTask: getCloseIncognitoBrowserTask, | 567 getCloseIncognitoBrowserTask: getCloseIncognitoBrowserTask, |
| 535 Source: Source, | 568 Source: Source, |
| 536 Event: Event, | 569 Event: Event, |
| 537 CreateBeginEvent: CreateBeginEvent, | 570 CreateBeginEvent: CreateBeginEvent, |
| 538 CreateEndEvent: CreateEndEvent, | 571 CreateEndEvent: CreateEndEvent, |
| 539 CreateMatchingEndEvent: CreateMatchingEndEvent | 572 CreateMatchingEndEvent: CreateMatchingEndEvent |
| 540 }; | 573 }; |
| 541 })(); | 574 })(); |
| 542 | 575 |
| 543 netInternalsTest.test('netInternalsDone', function() { | 576 netInternalsTest.test('netInternalsDone', function() { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 HostResolverInfoObserver.prototype.onHostResolverInfoChanged = function() { | 634 HostResolverInfoObserver.prototype.onHostResolverInfoChanged = function() { |
| 602 assertNotReached(); | 635 assertNotReached(); |
| 603 }; | 636 }; |
| 604 | 637 |
| 605 // Create the observer and add it to |g_browser|. | 638 // Create the observer and add it to |g_browser|. |
| 606 g_browser.addHostResolverInfoObserver(new HostResolverInfoObserver()); | 639 g_browser.addHostResolverInfoObserver(new HostResolverInfoObserver()); |
| 607 | 640 |
| 608 // Needed to trigger an update. | 641 // Needed to trigger an update. |
| 609 netInternalsTest.switchToView('dns'); | 642 netInternalsTest.switchToView('dns'); |
| 610 }); | 643 }); |
| OLD | NEW |