Index: chrome/test/data/extensions/api_test/popup/popup_main/dom_ui.html |
=================================================================== |
--- chrome/test/data/extensions/api_test/popup/popup_main/dom_ui.html (revision 74596) |
+++ chrome/test/data/extensions/api_test/popup/popup_main/dom_ui.html (working copy) |
@@ -1,307 +0,0 @@ |
-<html xmlns="http://www.w3.org/1999/xhtml"> |
-<head> |
-<script> |
-// A token assigned to the global context of this script so that subsequently |
-// created tabs/views may find this view. |
-var TESTING_TOKEN = true; |
- |
-// Constant storing the maximal size to which the popup may expand in the |
-// following tests: popupRectangleMaxBoundsSizing, popupChromeMaxBoundsSizing |
-var MAXIMAL_POPUP_SIZE = { |
- "width": 320, |
- "height": 240 |
-}; |
- |
-var globalValue = "I am not 42."; |
- |
-// Some helper functions that track the focus state of a form on the toolbar. |
-var formFocused = false; |
-function onFormFocused() { |
- formFocused = true; |
-} |
- |
-function onFormBlurred() { |
- formFocused = false; |
-} |
- |
-// Global variable accessed by tests that run in popup views to indicate which |
-// suite of tests to execute. |
-var currentTest = null; |
- |
-// Callback that validates popup repositioning, and is invoked during execution |
-// of the following tests: |
-// popupRectangleSizing and popupChromeSizing. |
-// |offset| specifies the delta in screen-space by which the browser was moved. |
-// |initialSize| specfies the rect of the popup before the brower move. |
-// |movedSize| specifies the rect of the popup after the browser move. |
-function onWindowMoveCompleted(offset, initialSize, movedSize) { |
- chrome.test.assertEq(initialSize.width, movedSize.width); |
- chrome.test.assertEq(initialSize.height, movedSize.height); |
- chrome.test.assertTrue( |
- initialSize.top + offset.y == movedSize.top && |
- initialSize.left + offset.x == movedSize.left, |
- "Popup repositioned incorrectly after browser move."); |
-} |
- |
-// Callback invoked upon completion of popup bounds validation tests. |
-// |newSize| is the size of the popup window after a resize operation. |
-function onPopupWindowResizeCompleted(newSize) { |
- // Note, we do not test for equality because the popup chrome may slightly |
- // boost the size of the popup. For example, the rectangle chrome adds |
- // a pixel to the dimensions of the popup. |
- chrome.test.assertTrue(newSize.width - MAXIMAL_POPUP_SIZE.width <= 2); |
- chrome.test.assertTrue(newSize.height - MAXIMAL_POPUP_SIZE.height <= 2); |
-} |
- |
-// Assert function used by tests executed in separate extension views. |
-// Used by the following test: popupTeardownDismissal |
-// |value| is value upon which to assert. |
-// |message| is displayed if |value| is false. |
-function assertTrue(value, message) { |
- chrome.test.assertTrue(value, message); |
-} |
- |
-// Function used to signal completion of tests run in separate extension views. |
-// Used by the following test: popupTeardownDismissal |
-function testCompleted() { |
- chrome.test.succeed(); |
-} |
- |
-window.onload = function() { |
- chrome.test.runTests([ |
- function showNoFocusShift() { |
- var entryForm = document.getElementById("entryForm").focus(); |
- chrome.test.assertTrue(formFocused); |
- |
- // Validate that displaying a pop-up with the giveFocus parameter assigned |
- // to false does not touch the focus setting of the input field. |
- var showDetails = { |
- "relativeTo": document.getElementById("anchorHere"), |
- "giveFocus": false |
- }; |
- |
- // The focus should also remain untouched during closing of the popup. |
- chrome.test.listenOnce(chrome.experimental.popup.onClosed, function() { |
- chrome.test.assertTrue(formFocused); |
- }); |
- |
- chrome.experimental.popup.show("dom_ui_popup.html", |
- showDetails, |
- chrome.test.callbackPass(function() { |
- chrome.test.assertTrue(formFocused); |
- chrome.experimental.extension.getPopupView().close(); |
- })); |
- }, |
- function noPopup() { |
- chrome.test.assertTrue( |
- undefined === chrome.experimental.extension.getPopupView(), |
- "Popup view is defined when no popup shown."); |
- chrome.test.succeed(); |
- }, |
- function noParentWindow() { |
- chrome.test.assertTrue( |
- undefined === chrome.experimental.popup.getParentWindow(), |
- "Parent window accessible outside of popup view."); |
- chrome.test.succeed(); |
- }, |
- function show() { |
- var showDetails = { |
- "relativeTo": document.getElementById("anchorHere") |
- }; |
- chrome.experimental.popup.show("dom_ui_popup.html", |
- showDetails, |
- chrome.test.callbackPass(function() { |
- chrome.test.assertTrue( |
- chrome.experimental.extension.getPopupView() != undefined); |
- })); |
- }, |
- function accessPopup() { |
- var popupView = chrome.experimental.extension.getPopupView(); |
- chrome.test.assertTrue(popupView != undefined, |
- "Unable to access popup view."); |
- |
- chrome.test.assertTrue(popupView.theAnswer != undefined, |
- "Unable to access popup contents."); |
- |
- chrome.test.assertEq(42, popupView.theAnswer()); |
- chrome.test.succeed(); |
- }, |
- function accessHost() { |
- var popupView = chrome.experimental.extension.getPopupView(); |
- chrome.test.assertTrue(popupView != undefined, |
- "Unable to access popup view."); |
- |
- chrome.test.assertTrue(popupView.manipulateHost != undefined, |
- "Unable to access popup contents."); |
- |
- popupView.manipulateHost(); |
- chrome.test.assertEq(42, globalValue); |
- chrome.test.succeed(); |
- }, |
- function closePopup() { |
- // Ensure that the test waits until the popup is dismissed. |
- chrome.test.listenOnce(chrome.experimental.popup.onClosed, function() { |
- // TODO(twiz): The following assert is disabled, because it makes |
- // the test flaky on the build-bots. See issue: 46601 |
- // The popup should not be accessible during the onClosed handler. |
- //chrome.test.assertTrue( |
- // chrome.experimental.extension.getPopupView() == undefined); |
- }); |
- chrome.experimental.extension.getPopupView().close(); |
- }, |
- function popupBlackBorder() { |
- // Ensure that the test waits until the popup is dismissed. |
- chrome.test.listenOnce(chrome.experimental.popup.onClosed); |
- |
- // Validate that displaying a pop-up with a black border still invokes |
- // the callback successfully. Note that this test does not validate |
- // the actual style of the border displayed. |
- var showDetails = { |
- "relativeTo": document.getElementById("anchorHere"), |
- "borderStyle": "rectangle" |
- }; |
- chrome.experimental.popup.show("dom_ui_popup.html", |
- showDetails, |
- chrome.test.callbackPass(function() { |
- chrome.experimental.extension.getPopupView().close(); |
- })); |
- }, |
- function disallowMultiplePopups() { |
- // This test ensures that for a given extension with a popup displayed, |
- // displaying a subsequent popup will dismiss the first. |
- var showDetails1 = { |
- "relativeTo": document.getElementById("anchorHere"), |
- }; |
- |
- var showDetails2 = { |
- "relativeTo": document.getElementById("anchorHere2"), |
- "borderStyle": "rectangle" |
- }; |
- |
- // Track the number of popups opened and closed, so that we can signal |
- // the test as completed when appropriate. |
- var numberClosed = 0; |
- var doneListening = chrome.test.listenForever( |
- chrome.experimental.popup.onClosed, |
- function() { |
- // This test expects to open and close two popups, so signify that |
- // the test has succeeded, after closing the second popup. |
- if (++numberClosed == 2) { |
- doneListening(); |
- } |
- }); |
- |
- chrome.experimental.popup.show("dom_ui_popup_a.html", |
- showDetails1, |
- function() { |
- // Validate that the popup view returned is the one we expect. |
- chrome.test.assertEq( |
- 'a', |
- chrome.experimental.extension.getPopupView().getIdentity()); |
- |
- // Ensure that only one popup is open. |
- chrome.test.assertEq( |
- 1, |
- chrome.extension.getViews({type: "popup"}).length); |
- |
- chrome.experimental.popup.show("dom_ui_popup_b.html", |
- showDetails2, |
- function() { |
- // Validate that the first popup view is fully closed, and that |
- // getPopupView returns the most recently opened popup. |
- chrome.test.assertEq( |
- 'b', |
- chrome.experimental.extension.getPopupView().getIdentity()); |
- |
- // Ensure that only one popup is open. |
- chrome.test.assertEq( |
- 1, |
- chrome.extension.getViews({type: 'popup'}).length); |
- |
- chrome.experimental.extension.getPopupView().close(); |
- }); |
- }); |
- }, |
- function popupChromeSizing() { |
- // Ensure that the test waits until the popup is dismissed. |
- chrome.test.listenOnce(chrome.experimental.popup.onClosed); |
- |
- // Ensure that popups with a chrome border are repositioned and sized |
- // correctly. |
- var showDetails = { |
- "relativeTo": document.getElementById("anchorHere") |
- }; |
- |
- currentTest = "doSizingValidation"; |
- chrome.experimental.popup.show("dom_ui_popup_sizing.html", |
- showDetails); |
- }, |
- function popupRectangleSizing() { |
- // Ensure that the test waits until the popup is dismissed. |
- chrome.test.listenOnce(chrome.experimental.popup.onClosed); |
- |
- // Ensure that popups with a rectangle border are repositioned and sized |
- // correctly. |
- var showDetails = { |
- "relativeTo": document.getElementById("anchorHere"), |
- "borderStyle": "rectangle" |
- }; |
- |
- currentTest = "doSizingValidation"; |
- chrome.experimental.popup.show("dom_ui_popup_sizing.html", |
- showDetails); |
- }, |
- function popupChromeMaxBoundsSizing() { |
- // Ensure that the test waits until the popup is dismissed. |
- chrome.test.listenOnce(chrome.experimental.popup.onClosed); |
- |
- // Ensure that popups with a chrome border are repositioned and sized |
- // correctly. |
- var showDetails = { |
- "relativeTo": document.getElementById("anchorHere"), |
- "maxSize": MAXIMAL_POPUP_SIZE |
- }; |
- |
- currentTest = "doMaximalBoundsValidation"; |
- chrome.experimental.popup.show("dom_ui_popup_sizing.html", |
- showDetails); |
- }, |
- function popupRectangleMaxBoundsSizing() { |
- // Ensure that the test waits until the popup is dismissed. |
- chrome.test.listenOnce(chrome.experimental.popup.onClosed); |
- |
- // Ensure that popups with a rectangle border respects the maximal bounds. |
- var showDetails = { |
- "relativeTo": document.getElementById("anchorHere"), |
- "borderStyle": "rectangle", |
- "maxSize": MAXIMAL_POPUP_SIZE |
- }; |
- |
- currentTest = "doMaximalBoundsValidation"; |
- chrome.experimental.popup.show("dom_ui_popup_sizing.html", |
- showDetails); |
- }, |
- function popupTeardownDismissal() { |
- // This test verifies that closing of views that launched active popups |
- // results in a popup dismissal. |
- var tabProperties = { |
- "url": "dom_ui_popup_dismissal.html" |
- }; |
- chrome.tabs.create(tabProperties); |
- } |
- ]); |
-} |
-</script> |
-</head> |
-<body> |
-<div id="anchorHere"> |
-<span>TEST</span> |
-</div> |
-<div id="anchorHere2"> |
-<span>TESTING 2</span> |
-</div> |
-<form> |
-<input id="entryForm" onfocus="onFormFocused();" onblur="onFormBlurred();"/> |
-</form> |
-</body> |
-</html> |