Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Unexpected iframe URL change #27357

Closed
rcebulko opened this issue Mar 23, 2020 · 10 comments
Closed

Error: Unexpected iframe URL change #27357

rcebulko opened this issue Mar 23, 2020 · 10 comments
Labels
P3: When Possible Stale Inactive for one year or more Type: Bug Type: Error Report An error reported by AMP Error Reporting WG: runtime

Comments

@rcebulko
Copy link
Contributor

rcebulko commented Mar 23, 2020

Error: Unexpected iframe URL change: https://www-thegamer-com.cdn.ampproject.org/v/s/www.thegamer.com/best-sims-4-expansion-packs/amp/?amp_js_v=0.1&usqp=mq331AQFKAGwASA= https://www-thegamer-com.cdn.ampproject.org/v/s/www.thegamer.com/best-sims-4-expansion-packs/amp/
    at message (https://raw.githubusercontent.com/ampproject/amphtml/2003101714470/src/log.js:714)
    at (https://raw.githubusercontent.com/ampproject/amphtml/2003101714470/src/log.js:309)
    at (https://raw.githubusercontent.com/ampproject/amphtml/2003101714470/src/log.js:323)
    at TAG (https://raw.githubusercontent.com/ampproject/amphtml/2003101714470/src/service/navigation.js:36)
    at (https://raw.githubusercontent.com/ampproject/amphtml/2003101714470/src/service/navigation.js:609)

Thrown by this function:

removeViewerQueryBeforeNavigation_(win, fromLocation, target) {
  dev().info(
    TAG,
    'Removing iframe query string before navigation:',
    fromLocation.search
  );
  const original = fromLocation.href;
  const noQuery = `${fromLocation.origin}${fromLocation.pathname}${fromLocation.hash}`;
  win.history.replaceState(null, '', noQuery);

  const restoreQuery = () => {
    const currentHref = win.location.href;
    if (currentHref == noQuery) {
      dev().info(TAG, 'Restored iframe URL with query string:', original);
      win.history.replaceState(null, '', original);
    } else {
      dev().error(TAG, 'Unexpected iframe URL change:', currentHref, noQuery);
    }
  };

  // For blank_, restore query params after the new page opens.
  if (target === '_blank') {
    win.setTimeout(restoreQuery, 0);
  } else {
    // For _top etc., wait until page is restored from page cache (bfcache).
    // https://webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/
    win.addEventListener('pageshow', function onPageShow(e) {
      if (e.persisted) {
        restoreQuery();
        win.removeEventListener('pageshow', onPageShow);
      }
    });
  }
}
@rcebulko rcebulko added Type: Bug Type: Error Report An error reported by AMP Error Reporting labels Mar 23, 2020
@rcebulko
Copy link
Contributor Author

/cc @ampproject/wg-viewers for viewer-related code
/cc @choumx for last PR to touch the function (though after it had already started appearing)

@ampprojectbot
Copy link
Member

A duplicate error report was linked to this issue (link)

@ampprojectbot
Copy link
Member

A duplicate error report was linked to this issue (link)

@ampprojectbot
Copy link
Member

A duplicate error report was linked to this issue (link)

@ampprojectbot
Copy link
Member

A duplicate error report was linked to this issue (link)

@ampprojectbot
Copy link
Member

A duplicate error report was linked to this issue (link)

@ampprojectbot
Copy link
Member

A duplicate error report was linked to this issue (link)

@ampprojectbot
Copy link
Member

A duplicate error report was linked to this issue (link)

@ampprojectbot
Copy link
Member

A duplicate error report was linked to this issue (link)

This was referenced Dec 23, 2020
@stale
Copy link

stale bot commented Jun 12, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale Inactive for one year or more label Jun 12, 2022
@stale stale bot closed this as completed Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3: When Possible Stale Inactive for one year or more Type: Bug Type: Error Report An error reported by AMP Error Reporting WG: runtime
Projects
None yet
Development

No branches or pull requests

3 participants