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

JS deprecated document.write for loading scripts caused by defer missing #26518

Open
casesolved-co-uk opened this issue May 21, 2024 · 0 comments
Labels

Comments

@casesolved-co-uk
Copy link
Contributor

casesolved-co-uk commented May 21, 2024

When testing frappe using automated browser (chrome) testing, the below error was received from the console.

Errors for the following bundles:

  • libs
  • desk
  • list
  • form
  • controls
  • report
  • telemetry
  • erpnext
  • hrms
  • report

This is caused by puppeteer setcontent using document.write.
The errors can be cured by adding the defer attribute to the script tag in jinja_globals.py include_script function.

Logged here: puppeteer/puppeteer#12476

Context information (for bug reports)

Output of bench version

v16 develop

Should probably change these to be set via innerHTML:

w.document.write(html);
w.document.close();
}),
(frappe.render_tree = function (opts) {
opts.base_url = frappe.urllib.get_base_url();
opts.landscape = false;
opts.print_css = frappe.boot.print_css;
opts.print_format_css_path = frappe.assets.bundled_asset("print_format.bundle.css");
var tree = frappe.render_template("print_tree", opts);
var w = window.open();
if (!w) {
frappe.msgprint(__("Please enable pop-ups in your browser"));
}
w.document.write(tree);

Steps to reproduce the issue

  1. install puppeteer
  2. use it for automated load of the html from a frappe page using page.setcontent(html)

Related: https://developer.chrome.com/blog/removing-document-write

Stacktrace / full error message

A parser-blocking, cross site (i.e. different eTLD+1) script, /assets/frappe/dist/js/desk.bundle.KQ2KIVUJ.js, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message. See https://www.chromestatus.com/feature/5718547946799104 for more details.

@casesolved-co-uk casesolved-co-uk changed the title JS deprecated document.write for loading scripts JS deprecated document.write for loading scripts caused by async missing May 22, 2024
@casesolved-co-uk casesolved-co-uk changed the title JS deprecated document.write for loading scripts caused by async missing JS deprecated document.write for loading scripts caused by defer missing May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant