@@ -945,7 +945,13 @@ private void doProcessPostponedActions() {
945945
946946 // verify that the page that registered this PostponedAction is still alive
947947 if (action .isStillAlive ()) {
948- action .execute ();
948+ if (postponedActionsBlocker_ == null
949+ || !postponedActionsBlocker_ .blocks (action )) {
950+ action .execute ();
951+ }
952+ else {
953+ addPostponedAction (action );
954+ }
949955 }
950956 }
951957 }
@@ -1033,13 +1039,13 @@ protected void handleJavaScriptTimeoutError(final HtmlPage page, final TimeoutEr
10331039 * {@inheritDoc}
10341040 */
10351041 @ Override
1036- public PostponedActionsBlocker blockPostponedActions () {
1042+ public PostponedActionsBlocker blockPostponedActions (final Page page ) {
10371043 if (postponedActionsBlocker_ == null ) {
1038- postponedActionsBlocker_ = new RootPostponedActionsBlocker (this );
1044+ postponedActionsBlocker_ = new RootPostponedActionsBlocker (this , page );
10391045 return postponedActionsBlocker_ ;
10401046 }
10411047
1042- return new ChildPostponedActionsBlocker ();
1048+ return new ChildPostponedActionsBlocker (postponedActionsBlocker_ );
10431049 }
10441050
10451051 /**
@@ -1048,9 +1054,7 @@ public PostponedActionsBlocker blockPostponedActions() {
10481054 */
10491055 @ Override
10501056 public void processPostponedActions () {
1051- if (postponedActionsBlocker_ == null ) {
1052- doProcessPostponedActions ();
1053- }
1057+ doProcessPostponedActions ();
10541058 }
10551059
10561060 /**
@@ -1396,9 +1400,16 @@ public static String evaluateProxyAutoConfig(final BrowserVersion browserVersion
13961400 */
13971401 private final class RootPostponedActionsBlocker implements PostponedActionsBlocker {
13981402 private final JavaScriptEngine jsEngine_ ;
1403+ private final Page owningPage_ ;
13991404
1400- private RootPostponedActionsBlocker (final JavaScriptEngine jsEngine ) {
1405+ private RootPostponedActionsBlocker (final JavaScriptEngine jsEngine , final Page owningPage ) {
14011406 jsEngine_ = jsEngine ;
1407+ owningPage_ = owningPage ;
1408+ }
1409+
1410+ @ Override
1411+ public boolean blocks (final PostponedAction postponedAction ) {
1412+ return owningPage_ == postponedAction .getOwningPage ();
14021413 }
14031414
14041415 @ Override
@@ -1412,9 +1423,16 @@ public void release() {
14121423 * {@link PostponedActionsBlocker} - noop blocker.
14131424 */
14141425 private final class ChildPostponedActionsBlocker implements PostponedActionsBlocker {
1426+ private final RootPostponedActionsBlocker root_ ;
14151427
1416- private ChildPostponedActionsBlocker () {
1428+ private ChildPostponedActionsBlocker (final RootPostponedActionsBlocker root ) {
14171429 super ();
1430+ root_ = root ;
1431+ }
1432+
1433+ @ Override
1434+ public boolean blocks (final PostponedAction postponedAction ) {
1435+ return root_ .blocks (postponedAction );
14181436 }
14191437
14201438 @ Override
0 commit comments