(final WebWindow opener, final String name)
| 1158 | } |
| 1159 | |
| 1160 | private WebWindow resolveWindow(final WebWindow opener, final String name) { |
| 1161 | if (name == null || name.isEmpty() || TARGET_SELF.equals(name)) { |
| 1162 | return opener; |
| 1163 | } |
| 1164 | |
| 1165 | if (TARGET_PARENT.equals(name)) { |
| 1166 | return opener.getParentWindow(); |
| 1167 | } |
| 1168 | |
| 1169 | if (TARGET_TOP.equals(name)) { |
| 1170 | return opener.getTopWindow(); |
| 1171 | } |
| 1172 | |
| 1173 | if (TARGET_BLANK.equals(name)) { |
| 1174 | return null; |
| 1175 | } |
| 1176 | |
| 1177 | // first search for frame windows inside our window hierarchy |
| 1178 | WebWindow window = opener; |
| 1179 | while (true) { |
| 1180 | final Page page = window.getEnclosedPage(); |
| 1181 | if (page != null && page.isHtmlPage()) { |
| 1182 | try { |
| 1183 | final FrameWindow frame = ((HtmlPage) page).getFrameByName(name); |
| 1184 | final HtmlUnitScriptable scriptable = frame.getFrameElement().getScriptableObject(); |
| 1185 | if (scriptable instanceof HTMLIFrameElement element) { |
| 1186 | element.onRefresh(); |
| 1187 | } |
| 1188 | return frame; |
| 1189 | } |
| 1190 | catch (final ElementNotFoundException expected) { |
| 1191 | // Fall through |
| 1192 | } |
| 1193 | } |
| 1194 | |
| 1195 | if (window == window.getParentWindow()) { |
| 1196 | // TODO: should getParentWindow() return null on top windows? |
| 1197 | break; |
| 1198 | } |
| 1199 | window = window.getParentWindow(); |
| 1200 | } |
| 1201 | |
| 1202 | try { |
| 1203 | return getWebWindowByName(name); |
| 1204 | } |
| 1205 | catch (final WebWindowNotFoundException expected) { |
| 1206 | // Fall through - a new window will be created below |
| 1207 | } |
| 1208 | return null; |
| 1209 | } |
| 1210 | |
| 1211 | /** |
| 1212 | * <p><span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span></p> |
no test coverage detected