OLD | NEW |
1 <html xmlns="http://www.w3.org/1999/xhtml"> | 1 <html xmlns="http://www.w3.org/1999/xhtml"> |
2 <head> | 2 <head> |
3 <script> | 3 <script> |
4 var globalValue = "I am not 42."; | 4 var globalValue = "I am not 42."; |
5 | 5 |
| 6 // Some helper functions that track the focus state of a form on the toolbar. |
| 7 var formFocused = false; |
| 8 function onFormFocused() { |
| 9 formFocused = true; |
| 10 } |
| 11 |
| 12 function onFormBlurred() { |
| 13 formFocused = false; |
| 14 } |
| 15 |
6 window.onload = function() { | 16 window.onload = function() { |
7 chrome.test.runTests([ | 17 chrome.test.runTests([ |
| 18 function showNoFocusShift() { |
| 19 var entryForm = document.getElementById("entryForm").focus(); |
| 20 chrome.test.assertTrue(formFocused); |
| 21 |
| 22 // Validate that displaying a pop-up with the giveFocus parameter assigned |
| 23 // to false does not touch the focus setting of the input field. |
| 24 var showDetails = { |
| 25 "relativeTo": document.getElementById("anchorHere"), |
| 26 "giveFocus": false |
| 27 }; |
| 28 |
| 29 // The focus should also remain untouched during closing of the popup. |
| 30 chrome.test.listenOnce(chrome.experimental.popup.onClosed, function(){ |
| 31 chrome.test.assertTrue(formFocused); |
| 32 }); |
| 33 |
| 34 chrome.experimental.popup.show("toolband_popup.html", |
| 35 showDetails, |
| 36 chrome.test.callbackPass(function() { |
| 37 chrome.test.assertTrue(formFocused); |
| 38 chrome.experimental.extension.getPopupView().close(); |
| 39 })); |
| 40 }, |
8 function noPopup() { | 41 function noPopup() { |
9 chrome.test.assertTrue( | 42 chrome.test.assertTrue( |
10 undefined === chrome.experimental.extension.getPopupView(), | 43 undefined === chrome.experimental.extension.getPopupView(), |
11 "Popup view is defined when no popup shown."); | 44 "Popup view is defined when no popup shown."); |
12 chrome.test.succeed(); | 45 chrome.test.succeed(); |
13 }, | 46 }, |
14 function noParentWindow() { | 47 function noParentWindow() { |
15 chrome.test.assertTrue( | 48 chrome.test.assertTrue( |
16 undefined === chrome.experimental.popup.getParentWindow(), | 49 undefined === chrome.experimental.popup.getParentWindow(), |
17 "Parent ); | 50 "Parent window accessible outside of popup view."); |
18 chrome.test.succeed(); | 51 chrome.test.succeed(); |
19 }, | 52 }, |
20 function show() { | 53 function show() { |
21 var showDetails = { | 54 var showDetails = { |
22 "relativeTo": document.getElementById("anchorHere") | 55 "relativeTo": document.getElementById("anchorHere") |
23 }; | 56 }; |
24 chrome.experimental.popup.show("toolband_popup.html", | 57 chrome.experimental.popup.show("toolband_popup.html", |
25 showDetails, | 58 showDetails, |
26 chrome.test.callbackPass(function() { | 59 chrome.test.callbackPass(function() { |
27 chrome.test.assertTrue( | 60 chrome.test.assertTrue( |
28 chrome.experimental.extension.getPopupView() != undefined); | 61 chrome.experimental.extension.getPopupView() != undefined); |
29 })); | 62 })); |
30 }, | 63 }, |
31 function accessPopup() { | 64 function accessPopup() { |
32 var popupView = chrome.experimental.extension.getPopupView(); | 65 var popupView = chrome.experimental.extension.getPopupView(); |
33 chrome.test.assertTrue(popupView != undefined, | 66 chrome.test.assertTrue(popupView != undefined, |
34 "Unable to access popup view."); | 67 "Unable to access popup view."); |
35 | 68 |
36 chrome.test.assertTrue(popupView.theAnswer != undefined, | 69 chrome.test.assertTrue(popupView.theAnswer != undefined, |
37 "Unable to access popup contents."); | 70 "Unable to access popup contents."); |
38 | 71 |
39 chrome.test.assertEq(42, popupView.theAnswer()); | 72 chrome.test.assertEq(42, popupView.theAnswer()); |
40 chrome.test.succeed(); | 73 chrome.test.succeed(); |
41 }, | 74 }, |
42 | |
43 function accessHost() { | 75 function accessHost() { |
44 var popupView = chrome.experimental.extension.getPopupView(); | 76 var popupView = chrome.experimental.extension.getPopupView(); |
45 chrome.test.assertTrue(popupView != undefined, | 77 chrome.test.assertTrue(popupView != undefined, |
46 "Unable to access popup view."); | 78 "Unable to access popup view."); |
47 | 79 |
48 chrome.test.assertTrue(popupView.manipulateHost != undefined, | 80 chrome.test.assertTrue(popupView.manipulateHost != undefined, |
49 "Unable to access popup contents."); | 81 "Unable to access popup contents."); |
50 | 82 |
51 popupView.manipulateHost(); | 83 popupView.manipulateHost(); |
52 chrome.test.assertEq(42, globalValue); | 84 chrome.test.assertEq(42, globalValue); |
53 chrome.test.succeed(); | 85 chrome.test.succeed(); |
54 }, | 86 }, |
55 | |
56 function closePopup() { | 87 function closePopup() { |
57 chrome.test.listenOnce(chrome.experimental.popup.onClosed, function(){ | 88 chrome.test.listenOnce(chrome.experimental.popup.onClosed, function(){ |
58 // TODO(twiz): getPopupView() should return undefined, but, due to | 89 // TODO(twiz): getPopupView() should return undefined, but, due to |
59 // shut-down races, it is sometimes still defined. See BUG | 90 // shut-down races, it is sometimes still defined. See BUG 27658. |
60 //chrome.test.assertTrue( | 91 // chrome.test.assertTrue( |
61 // chrome.experimental.extension.getPopupView() == undefined); | 92 // chrome.experimental.extension.getPopupView() == undefined); |
62 }); | 93 }); |
63 chrome.experimental.extension.getPopupView().close(); | 94 chrome.experimental.extension.getPopupView().close(); |
64 } | 95 } |
65 ]); | 96 ]); |
66 } | 97 } |
67 </script> | 98 </script> |
68 </head> | 99 </head> |
69 <body> | 100 <body> |
70 <div> | 101 <div> |
71 <span id="anchorHere">TEST</span> | 102 <span id="anchorHere">TEST</span> |
72 </div> | 103 </div> |
| 104 <form> |
| 105 <input id="entryForm" onfocus="onFormFocused();" onblur="onFormBlurred();"/> |
| 106 </form> |
73 </body> | 107 </body> |
74 </html> | 108 </html> |
OLD | NEW |