Testing iframe Window Object Isolation in NW.js
This test suite validates iframe behavior and window object access in NW.js applications using Selenium WebDriver. It checks proper object isolation and undefined property handling between iframes and the main window context.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
nwjs/nwJs
test/sanity/iframe-nw/test.py
import time
import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("nwapp=" + os.path.dirname(os.path.abspath(__file__)))
driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
try:
print(driver.current_url)
result = driver.find_element_by_id('result').get_attribute('innerHTML')
print(result)
assert("object" == result)
result2 = driver.find_element_by_id('result2').get_attribute('innerHTML')
print(result2)
assert("undefined" == result2)
finally:
driver.quit()