OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 var embedder = {}; |
| 6 |
| 7 embedder.setUp_ = function(config) { |
| 8 if (!config || !config.testServer) { |
| 9 return; |
| 10 } |
| 11 embedder.baseGuestURL = 'http://localhost:' + config.testServer.port; |
| 12 embedder.emptyGuestURL = embedder.baseGuestURL + |
| 13 '/extensions/platform_apps/web_view/shim/empty_guest.html'; |
| 14 }; |
| 15 |
| 16 window.runTest = function(testName, appToEmbed) { |
| 17 if (!embedder.test.testList[testName]) { |
| 18 window.console.log('Incorrect testName: ' + testName); |
| 19 embedder.test.fail(); |
| 20 return; |
| 21 } |
| 22 |
| 23 // Run the test. |
| 24 embedder.test.testList[testName](appToEmbed); |
| 25 }; |
| 26 |
| 27 var LOG = function(msg) { |
| 28 window.console.log(msg); |
| 29 }; |
| 30 |
| 31 embedder.test = {}; |
| 32 embedder.test.succeed = function() { |
| 33 chrome.test.sendMessage('TEST_PASSED'); |
| 34 }; |
| 35 |
| 36 embedder.test.fail = function() { |
| 37 chrome.test.sendMessage('TEST_FAILED'); |
| 38 }; |
| 39 |
| 40 embedder.test.assertTrue = function(condition) { |
| 41 if (!condition) { |
| 42 console.log('Assertion failed: true != ' + condition); |
| 43 embedder.test.fail(); |
| 44 } |
| 45 }; |
| 46 |
| 47 embedder.test.assertFalse = function(condition) { |
| 48 if (condition) { |
| 49 console.log('Assertion failed: false != ' + condition); |
| 50 embedder.test.fail(); |
| 51 } |
| 52 }; |
| 53 |
| 54 // Tests begin. |
| 55 function testExtensionViewCreationShouldSucceed(appToEmbed) { |
| 56 LOG('Checking that there are no instances of <extensionview>.'); |
| 57 embedder.test.assertFalse(document.querySelector('extensionview')); |
| 58 var extensionview = new ExtensionView(); |
| 59 |
| 60 LOG('Appending new <extensionview> to DOM.'); |
| 61 document.body.appendChild(extensionview); |
| 62 |
| 63 LOG('Checking that <extensionview> exists.'); |
| 64 if (document.querySelector('extensionview')) { |
| 65 embedder.test.succeed(); |
| 66 return; |
| 67 } |
| 68 embedder.test.fail(); |
| 69 }; |
| 70 |
| 71 embedder.test.testList = { |
| 72 'testExtensionViewCreationShouldSucceed': |
| 73 testExtensionViewCreationShouldSucceed |
| 74 }; |
| 75 |
| 76 onload = function() { |
| 77 chrome.test.getConfig(function(config) { |
| 78 embedder.setUp_(config); |
| 79 chrome.test.sendMessage('Launched'); |
| 80 }); |
| 81 }; |
OLD | NEW |