OLD | NEW |
(Empty) | |
| 1 <script> |
| 2 |
| 3 var firstEnter = true; |
| 4 |
| 5 chrome.test.getConfig(function(config) { |
| 6 chrome.test.log('Creating tab...'); |
| 7 |
| 8 var URL = 'http://localhost:PORT/files/extensions/test_file_with_body.html'; |
| 9 var TEST_FILE_URL = URL.replace(/PORT/, config.testServer.port); |
| 10 |
| 11 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { |
| 12 if (changeInfo.status != 'complete') |
| 13 return; |
| 14 if (!firstEnter) |
| 15 return; |
| 16 firstEnter = false; |
| 17 |
| 18 // We need to test two different paths, because the message bundles used |
| 19 // for localization are loaded differently in each case: |
| 20 // (1) localization upon loading extension scripts |
| 21 // (2) localization upon injecting CSS with JavaScript |
| 22 chrome.test.runTests([ |
| 23 |
| 24 // Tests that CSS loaded automatically from the files specified in the |
| 25 // manifest has had __MSG_@@extension_id__ replaced with the actual |
| 26 // extension id. |
| 27 function extensionIDMessageGetsReplacedInContentScriptCSS() { |
| 28 chrome.extension.onRequest.addListener( |
| 29 function(request, sender, sendResponse) { |
| 30 if (request.tag == 'extension_id') { |
| 31 if (request.message == 'passed') { |
| 32 chrome.test.succeed(); |
| 33 } else { |
| 34 chrome.test.fail(request.message); |
| 35 } |
| 36 } |
| 37 } |
| 38 ); |
| 39 var script_file = {}; |
| 40 script_file.file = 'test_extension_id.js'; |
| 41 chrome.tabs.executeScript(tabId, script_file); |
| 42 }, |
| 43 |
| 44 // First injects CSS into the page through chrome.tabs.insertCSS and then |
| 45 // checks that it has had __MSG_text_color__ replaced with the correct |
| 46 // message value. |
| 47 function textDirectionMessageGetsReplacedInInsertCSSCall() { |
| 48 chrome.extension.onRequest.addListener( |
| 49 function(request, sender, sendResponse) { |
| 50 if (request.tag == 'paragraph_style') { |
| 51 if (request.message == 'passed') { |
| 52 chrome.test.succeed(); |
| 53 } else { |
| 54 chrome.test.fail(request.message); |
| 55 } |
| 56 } |
| 57 } |
| 58 ); |
| 59 var css_file = {}; |
| 60 css_file.file = 'test.css'; |
| 61 chrome.tabs.insertCSS(tabId, css_file, function() { |
| 62 var script_file = {}; |
| 63 script_file.file = 'test_paragraph_style.js'; |
| 64 chrome.tabs.executeScript(tabId,script_file); |
| 65 }); |
| 66 } |
| 67 |
| 68 ]); |
| 69 }); |
| 70 |
| 71 chrome.tabs.create({ url: TEST_FILE_URL }); |
| 72 }); |
| 73 |
| 74 </script> |
OLD | NEW |