| OLD | NEW |
| 1 <script> | 1 <script> |
| 2 var normalWindow, normalTab; | 2 var normalWindow, normalTab; |
| 3 var incognitoWindow, incognitoTab; | 3 var incognitoWindow, incognitoTab; |
| 4 | 4 |
| 5 var pass = chrome.test.callbackPass; | 5 var pass = chrome.test.callbackPass; |
| 6 var assertEq = chrome.test.assertEq; | 6 var assertEq = chrome.test.assertEq; |
| 7 var assertTrue = chrome.test.assertTrue; | 7 var assertTrue = chrome.test.assertTrue; |
| 8 | 8 |
| 9 chrome.test.runTests([ | 9 chrome.test.runTests([ |
| 10 function setupWindows() { | 10 function setupWindows() { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 pass(function(tab) { | 69 pass(function(tab) { |
| 70 assertEq(incognitoTab.incognito, tab.incognito); | 70 assertEq(incognitoTab.incognito, tab.incognito); |
| 71 chrome.tabs.remove(tab.id, pass()); | 71 chrome.tabs.remove(tab.id, pass()); |
| 72 })); | 72 })); |
| 73 })); | 73 })); |
| 74 }, | 74 }, |
| 75 | 75 |
| 76 // Tests content script injection to verify that the script can tell its | 76 // Tests content script injection to verify that the script can tell its |
| 77 // in incongnito. | 77 // in incongnito. |
| 78 function contentScriptTestIncognito() { | 78 function contentScriptTestIncognito() { |
| 79 // The property is undefined outside of content scripts. | 79 assertTrue(!chrome.extension.inIncognitoContext); |
| 80 assertEq(undefined, chrome.extension.inIncognitoTab); | |
| 81 | 80 |
| 82 var testUrl = "http://localhost:1337/files/extensions/test_file.html"; | 81 var testUrl = "http://localhost:1337/files/extensions/test_file.html"; |
| 83 | 82 |
| 84 // Test that chrome.extension.inIncognitoTab is true for incognito tabs. | 83 // Test that chrome.extension.inIncognitoTab is true for incognito tabs. |
| 85 chrome.tabs.create({windowId: incognitoWindow.id, url: testUrl}, | 84 chrome.tabs.create({windowId: incognitoWindow.id, url: testUrl}, |
| 86 pass(function(tab) { | 85 pass(function(tab) { |
| 87 chrome.tabs.executeScript(tab.id, | 86 chrome.tabs.executeScript(tab.id, |
| 88 {code: 'document.title = chrome.extension.inIncognitoTab'}, | 87 {code: 'document.title = chrome.extension.inIncognitoContext'}, |
| 89 pass(function() { | 88 pass(function() { |
| 90 assertEq(undefined, chrome.extension.lastError); | 89 assertEq(undefined, chrome.extension.lastError); |
| 91 chrome.tabs.get(tab.id, pass(function(tab) { | 90 chrome.tabs.get(tab.id, pass(function(tab) { |
| 92 assertEq("true", tab.title); | 91 assertEq("true", tab.title); |
| 93 })); | 92 })); |
| 94 })); | 93 })); |
| 95 })); | 94 })); |
| 96 | 95 |
| 97 // ... and false for normal tabs. | 96 // ... and false for normal tabs. |
| 98 chrome.tabs.create({windowId: normalWindow.id, url: testUrl}, | 97 chrome.tabs.create({windowId: normalWindow.id, url: testUrl}, |
| 99 pass(function(tab) { | 98 pass(function(tab) { |
| 100 chrome.tabs.executeScript(tab.id, | 99 chrome.tabs.executeScript(tab.id, |
| 101 {code: 'document.title = chrome.extension.inIncognitoTab'}, | 100 {code: 'document.title = chrome.extension.inIncognitoContext'}, |
| 102 pass(function() { | 101 pass(function() { |
| 103 assertEq(undefined, chrome.extension.lastError); | 102 assertEq(undefined, chrome.extension.lastError); |
| 104 chrome.tabs.get(tab.id, pass(function(tab) { | 103 chrome.tabs.get(tab.id, pass(function(tab) { |
| 105 assertEq("false", tab.title); | 104 assertEq("false", tab.title); |
| 106 })); | 105 })); |
| 107 })); | 106 })); |
| 108 })); | 107 })); |
| 109 } | 108 } |
| 110 ]); | 109 ]); |
| 111 </script> | 110 </script> |
| OLD | NEW |