Skip to content
Browse files

Bug 817896 related - Fixing uitests for window.open

  • Loading branch information...
1 parent 8ca3aa6 commit be77d7e68283c039c5d78e86fdb715ec16d11204 @albertopq albertopq committed Dec 7, 2012
Showing with 48 additions and 17 deletions.
  1. +33 −0 test_apps/uitest/js/window_open.js
  2. +15 −17 test_apps/uitest/tests/open.html
View
33 test_apps/uitest/js/window_open.js
@@ -0,0 +1,33 @@
+
+window.addEventListener('load', function() {
+ var buttons = document.querySelectorAll('button');
+
+ for(var i = 0; i < buttons.length; i++) {
+ var button = buttons[i];
+ button.addEventListener('click', function(e) {
+ var target = e.target;
+ var actualWindow = window;
+ if(target.classList.contains('mozbrowser')) {
+ actualWindow = window.parent;
+ }
+
+ switch(target.dataset.action) {
+ case 'open':
+ var param1 = null,
+ param2 = null;
+ var hash = target.dataset.url.split('#');
+ if(hash.length > 1) {
+ param1 = hash[1];
+ param2 = hash[1];
+ }
+ actualWindow.open(target.dataset.url, param1, param2);
+ break;
+ case 'close':
+ actualWindow.close();
+ break;
+ default:
+ break;
+ }
+ });
+ }
+});
View
32 test_apps/uitest/tests/open.html
@@ -4,34 +4,32 @@
<meta charset="utf-8">
<title>Open test</title>
<style>
- button {
+ button, input {
font-size: 40px;
+ width: 100%;
}
+
</style>
- <script>
- if (window.alert !== window.parent.alert)
- window.alert = window.parent.alert;
- </script>
+ <script type="text/javascript" src="../js/window_open.js"></script>
</head>
<body>
<h1>window.open</h1>
+ <h2> You should see the keyboard when focusing here </h2>
+ <input type="textarea"></input>
+
<h2>Call on mozbrowser frame:</h2>
- <p><button onclick="alert('Window: ' + window.parent.open('./popup.html'))">window.open</button></p>
- <p><button onclick="alert('Window: ' + window.parent.open('./popup.html#attention', 'at', 'attention'))">
- window.open(url, name, 'attention')</button></p>
- <p><button onclick="alert('Window: ' + window.parent.open('./popup.html#background', 'bg', 'background'))">
- window.open(url, name, 'background')</button></p>
- <p><button onclick="window.parent.close()">window.close()</button></p>
+ <p><button class="mozbrowser" data-action="open" data-url="./popup.html">window.open</button></p>
+ <p><button class="mozbrowser" data-action="open" data-url="./popup.html#attention">window.open(url, name, 'attention')</button></p>
+ <p><button class="mozbrowser" data-action="open" data-url="./popup.html#background">window.open(url, name, 'background')</button></p>
+ <p><button class="mozbrowser" data-action="close" >window.close()</button></p>
<h2>Call on this iframe within mozbrowser:</h2>
- <p><button onclick="alert('Window: ' + window.open('./popup.html'))">window.open</button></p>
- <p><button onclick="alert('Window: ' + window.open('./popup.html#attention', 'at', 'attention'))">
- window.open(url, name, 'attention')</button></p>
- <p><button onclick="alert('Window: ' + window.open('./popup.html#background', 'bg', 'background'))">
- window.open(url, name, 'background')</button></p>
+ <p><button data-action="open" data-url="./popup.html">window.open</button></p>
+ <p><button data-action="open" data-url="./popup.html#attention">window.open(url, name, 'attention')</button></p>
+ <p><button data-action="open" data-url="./popup.html#background">window.open(url, name, 'background')</button></p>
- <p><button onclick="window.open('https://www.google.com')">Open External URL</button></p>
+ <p><button data-action="open" data-url="https://google.com">Open External URL</button></p>
<p>Press back button to go back.</p>
</body>

0 comments on commit be77d7e

Please sign in to comment.
Something went wrong with that request. Please try again.