| <!DOCTYPE html> |
| <!-- |
| Copyright 2011 WebDriver committers |
| Copyright 2011 Google Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <title>frame_test.html</title> |
| <link rel="stylesheet" href="/filez/_main/third_party/js/qunit/qunit.css"> |
| <script src="/filez/_main/third_party/js/qunit/qunit.js"></script> |
| <script src="/filez/_main/third_party/js/qunit/qunit_test_runner.js"></script> |
| <script src="../../test_bootstrap.js"></script> |
| <script src="../../../atoms/inject/deps.js"></script> |
| <script type="text/javascript"> |
| goog.require('goog.json'); |
| goog.require('goog.userAgent'); |
| goog.require('bot.inject.cache'); |
| goog.require('webdriver.atoms.inject.frame'); |
| </script> |
| |
| <script type="text/javascript"> |
| function getWindowFromCache(rawResult) { |
| var id = goog.json.parse(rawResult).value.WINDOW; |
| return bot.inject.cache.getElement(id); |
| } |
| |
| QUnit.test('injectFindFrameByIdOrName', function(assert) { |
| if (goog.userAgent.IE) { |
| assert.ok(true, 'Test skipped for IE'); |
| return; |
| } |
| |
| var res = webdriver.atoms.inject.frame.findFrameByIdOrName("first"); |
| assert.strictEqual(getWindowFromCache(res), window.frames[0]); |
| }); |
| |
| QUnit.test('injectFindFrameByIdOrNameWithWindowRoot', function(assert) { |
| if (goog.userAgent.IE) { |
| assert.ok(true, 'Test skipped for IE'); |
| return; |
| } |
| |
| var wrappedWindow = |
| {"WINDOW": bot.inject.cache.addElement(window.frames[1])}; |
| var res2 = webdriver.atoms.inject.frame.findFrameByIdOrName("iframe1", wrappedWindow); |
| assert.strictEqual(getWindowFromCache(res2), window.frames[1].frames[0]); |
| }); |
| |
| QUnit.test('injectFindFrameByIndex', function(assert) { |
| if (goog.userAgent.IE) { |
| assert.ok(true, 'Test skipped for IE'); |
| return; |
| } |
| |
| var win = webdriver.atoms.inject.frame.findFrameByIndex(1); |
| assert.strictEqual(getWindowFromCache(win), window.frames[1]); |
| }); |
| |
| QUnit.test('injectFindFrameByIndexWithWindowRoot', function(assert) { |
| if (goog.userAgent.IE) { |
| assert.ok(true, 'Test skipped for IE'); |
| return; |
| } |
| |
| var wrappedWindow = {"ELEMENT": bot.inject.cache.addElement(window.frames[1])}; |
| var win = webdriver.atoms.inject.frame.findFrameByIndex(0, wrappedWindow); |
| assert.strictEqual(getWindowFromCache(win), window.frames[1].frames[0]); |
| }); |
| |
| QUnit.test('injectDefaultContent', function(assert) { |
| if (goog.userAgent.IE) { |
| assert.ok(true, 'Test skipped for IE'); |
| return; |
| } |
| |
| var win = webdriver.atoms.inject.frame.defaultContent(); |
| assert.strictEqual(getWindowFromCache(win), window); |
| }); |
| |
| QUnit.test('injectGetFrameWindow', function(assert) { |
| if (goog.userAgent.IE) { |
| assert.ok(true, 'Test skipped for IE'); |
| return; |
| } |
| |
| var wrappedElement = {"ELEMENT": bot.inject.cache.addElement( |
| window.document.getElementById("first"))}; |
| var win = webdriver.atoms.inject.frame.getFrameWindow(wrappedElement); |
| assert.strictEqual(getWindowFromCache(win), window.frames[0]); |
| }); |
| </script> |
| </head> |
| <body> |
| <div id="qunit"></div> |
| <div id="qunit-fixture"></div> |
| <iframe src="nested_frames.html" id="first"></iframe> |
| <iframe src="nested_iframes.html" id="second"></iframe> |
| </body> |
| </html> |