1 38 package com.gargoylesoftware.htmlunit.javascript.host; 39 40 import java.util.ArrayList; 41 import java.util.Arrays; 42 import java.util.List; 43 44 import com.gargoylesoftware.htmlunit.CollectingAlertHandler; 45 import com.gargoylesoftware.htmlunit.MockWebConnection; 46 import com.gargoylesoftware.htmlunit.WebClient; 47 import com.gargoylesoftware.htmlunit.WebTestCase; 48 import com.gargoylesoftware.htmlunit.html.HtmlPage; 49 50 56 public class FrameTest extends WebTestCase { 57 61 public FrameTest( final String name ) { 62 super(name); 63 } 64 65 95 96 99 public void testFrameName() throws Exception { 100 final WebClient webClient = new WebClient(); 101 final MockWebConnection webConnection = 102 new MockWebConnection(webClient); 103 final List collectedAlerts = new ArrayList(); 104 105 webClient.setAlertHandler(new CollectingAlertHandler(collectedAlerts)); 106 107 final String firstContent 108 = "<html><head><title>first</title></head>" 109 + "<frameset cols='20%,80%'>" 110 + " <frame id='frame1'>" 111 + " <frame name='Frame2' onload='alert(this.name)' id='frame2'>" 112 + "</frameset></html>"; 113 final List expectedAlerts = Arrays.asList( new String[]{"Frame2"} ); 114 115 webConnection.setResponse(URL_FIRST, firstContent); 116 webClient.setWebConnection(webConnection); 117 118 final HtmlPage page = (HtmlPage) webClient.getPage(URL_FIRST); 119 assertEquals("first", page.getTitleText()); 120 121 assertEquals(expectedAlerts, collectedAlerts); 122 } 123 } 124 | Popular Tags |