| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 chrome.test.getConfig(function(config) { | 5 chrome.test.getConfig(function(config) { |
| 6 var IN_APP_URL = 'nav-target.html'; | 6 var IN_APP_URL = 'nav-target.html'; |
| 7 var REMOTE_URL = 'http://localhost:' + config.testServer.port | 7 var REMOTE_URL = 'http://localhost:' + config.testServer.port |
| 8 '/files/extensions/platform_apps/navigation/nav-target.html'; | 8 '/files/extensions/platform_apps/navigation/nav-target.html'; |
| 9 | 9 |
| 10 var testForm = document.getElementById('test-form'); | 10 var testForm = document.getElementById('test-form'); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 function() { | 49 function() { |
| 50 testForm.method = 'POST'; | 50 testForm.method = 'POST'; |
| 51 testForm.action = REMOTE_URL; | 51 testForm.action = REMOTE_URL; |
| 52 testForm.submit(); | 52 testForm.submit(); |
| 53 }, | 53 }, |
| 54 | 54 |
| 55 // Clicks on links (in-app and remote). | 55 // Clicks on links (in-app and remote). |
| 56 function() { testLink.href = IN_APP_URL; clickTestLink(); }, | 56 function() { testLink.href = IN_APP_URL; clickTestLink(); }, |
| 57 function() { testLink.href = REMOTE_URL; clickTestLink(); }, | 57 function() { testLink.href = REMOTE_URL; clickTestLink(); }, |
| 58 | 58 |
| 59 // Links with target blank and a remote URL open a new tab in the browser |
| 60 // (verified in C++). |
| 61 function() { |
| 62 testLink.target = '_blank'; |
| 63 testLink.href = IN_APP_URL; |
| 64 clickTestLink(); |
| 65 }, |
| 66 function() { testLink.href = 'http://chromium.org'; clickTestLink(); }, |
| 67 |
| 59 // If we manage to execute this test case, then we haven't navigated away. | 68 // If we manage to execute this test case, then we haven't navigated away. |
| 60 function() { chrome.test.notifyPass(); } | 69 function() { chrome.test.notifyPass(); } |
| 61 ]; | 70 ]; |
| 62 | 71 |
| 63 var testIndex = 0; | 72 var testIndex = 0; |
| 64 | 73 |
| 65 function runTest() { | 74 function runTest() { |
| 66 var test = tests[testIndex++]; | 75 var test = tests[testIndex++]; |
| 67 | 76 |
| 68 console.log('Testing ' + (testIndex - 1) + ': ' + test); | 77 console.log('Testing ' + (testIndex - 1) + ': ' + test); |
| 69 test(); | 78 test(); |
| 70 | 79 |
| 71 if (testIndex < tests.length) { | 80 if (testIndex < tests.length) { |
| 72 // Don't run the next test immediately, since navigation happens | 81 // Don't run the next test immediately, since navigation happens |
| 73 // asynchronously, and if we do end up navigating, we don't want to still | 82 // asynchronously, and if we do end up navigating, we don't want to still |
| 74 // execute the final test case (which signals success). | 83 // execute the final test case (which signals success). |
| 75 window.setTimeout(runTest, 100); | 84 window.setTimeout(runTest, 100); |
| 76 } | 85 } |
| 77 } | 86 } |
| 78 | 87 |
| 79 runTest(); | 88 runTest(); |
| 80 }); | 89 }); |
| OLD | NEW |