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

javascript.options.discardSystemSource breaks injection in v1.5.0..v1.5.2 #570

Closed
eternaleye opened this issue Nov 20, 2018 · 11 comments
Closed
Projects

Comments

@eternaleye
Copy link

  • Browser: Firefox 62.0.3
  • Operating System: Fedora 29 (x86_64)
  • Stylus Version: 1.5.0

I've managed to track down the failure to line 106 in prefs.js.

This promisify call results in a rejected promise, with the thoroughly unhelpful message "Error: An unexpected error occurred", no stack, and no source information.

Attempting to import my styles (exported under 1.4.23) produces results that make it clear the styles are still there; downgrading to 1.4.23 restores functionality completely.

@eight04
Copy link
Collaborator

eight04 commented Nov 21, 2018

It seems that the browser failed to get the setting from storage.sync. What would you get if you run browser.storage.sync.get().then(console.log) in the background console?

@xtradev
Copy link

xtradev commented Nov 21, 2018

I have the same issue. Everything worked fine until the latest update.
Windows XP SP2, Google Chrome 49, Stylus 1.5.0

In Chrome "browser is not defined".

@eight04
Copy link
Collaborator

eight04 commented Nov 21, 2018

@xtradev it is not the same issue. See #560.

@xtradev
Copy link

xtradev commented Nov 21, 2018

Oh, I see. Thank you eight04.

@athanro
Copy link

athanro commented Nov 21, 2018

I had the same problem in FF 63.0.3. Solution was to set webextensions.storage.sync.enabled to true (from false)

@eternaleye
Copy link
Author

eternaleye commented Nov 22, 2018

Hm. Not sure what's changed, but after (an unrelated) browser restart, the manager now does list styles (and prefs.initializing shows as fulfilled) - however, they are still not applied to pages. It looks like there may be two bugs.

The webextensions.storage.sync.enabled setting is true, and the expression you asked me to run produces the following, though it's likely no longer relevant:

Long JSON dump
{
  "settings": {
    "openEditInWindow": false,
    "windowPosition": {},
    "show-badge": true,
    "disableAll": false,
    "exposeIframes": false,
    "newStyleAsUsercss": true,
    "config.autosave": true,
    "popup.breadcrumbs": true,
    "popup.breadcrumbs.usePath": false,
    "popup.enabledFirst": true,
    "popup.stylesFirst": true,
    "popup.borders": false,
    "popup.findStylesInline": true,
    "manage.onlyEnabled": false,
    "manage.onlyLocal": false,
    "manage.onlyUsercss": false,
    "manage.onlyEnabled.invert": false,
    "manage.onlyLocal.invert": false,
    "manage.onlyUsercss.invert": false,
    "manage.backup.expanded": true,
    "manage.filters.expanded": true,
    "manage.options.expanded": true,
    "manage.newUI": true,
    "manage.newUI.favicons": true,
    "manage.newUI.faviconsGray": true,
    "manage.newUI.targets": 3,
    "manage.newUI.sort": "usercss,asc, title,asc",
    "editor.options": {},
    "editor.options.expanded": true,
    "editor.lint.expanded": true,
    "editor.lineWrapping": true,
    "editor.smartIndent": false,
    "editor.indentWithTabs": false,
    "editor.tabSize": 4,
    "editor.keyMap": "default",
    "editor.theme": "default",
    "editor.beautify": {
      "selector_separator_newline": true,
      "newline_before_open_brace": false,
      "newline_after_open_brace": true,
      "newline_between_properties": true,
      "newline_before_close_brace": true,
      "newline_between_rules": false,
      "end_with_newline": false,
      "indent_conditional": true,
      "indent_size": 4,
      "indent_char": " ",
      "translate_positions": [
        {
          "line": 127,
          "ch": 0,
          "sticky": null
        },
        {
          "line": 127,
          "ch": 0,
          "sticky": null
        }
      ]
    },
    "editor.lintDelay": 300,
    "editor.linter": "csslint",
    "editor.lintReportDelay": 500,
    "editor.matchHighlight": "token",
    "editor.autoCloseBrackets": false,
    "editor.autocompleteOnTyping": false,
    "editor.contextDelete": false,
    "editor.appliesToLineWidget": true,
    "editor.livePreview": true,
    "editor.colorpicker": true,
    "editor.colorpicker.hexUppercase": false,
    "editor.colorpicker.hotkey": "",
    "editor.colorpicker.color": "#ff0000",
    "iconset": 1,
    "badgeDisabled": "#8B0000",
    "badgeNormal": "#006666",
    "popupWidth": 246,
    "updateInterval": 24
  }
}

@eight04
Copy link
Collaborator

eight04 commented Nov 22, 2018

they are still not applied to pages.

Which style? Which page? Is there any error in the console? It might be the CSP bug in 1.5.0. See #562 (comment).

@eternaleye
Copy link
Author

The one I've been using to check is one I wrote; https://gitlab.com/snippets/1698968 on https://riot.im/develop

I'm not at the computer in question right now; will check logs in the morning.

@eight04
Copy link
Collaborator

eight04 commented Nov 22, 2018

I can't reproduce on FF 62.0.3 + Windows 7. Fonts are changed to monospace:
image

I suggest testing in a new profile to see if it is a problem of setting or other extensions.

@Mottie Mottie added this to To prioritize in Priorities Nov 22, 2018
@Mottie
Copy link
Member

Mottie commented Nov 30, 2018

Please try v1.5.1 and report if the problem persists.

@Mottie Mottie moved this from To prioritize to High priority in Priorities Nov 30, 2018
@eternaleye
Copy link
Author

eternaleye commented Dec 21, 2018

Finally got back to this, and I've figured out the root cause - the issue manifests exactly when javascript.options.discardSystemSource is true, resulting in the code snippet sent over to the tab containing:

(EVENT_NAME => {
    [native code]
})("{7a7a4a92-a2a0-41d1-9fd7-1e92480d612d}")

when it should contain the following:

(EVENT_NAME => {
        document.currentScript.remove();
        const available = checkStyleApplied();
        if (available) {
          window.addEventListener(EVENT_NAME, function handler(e) {
            const {method, id, content} = e.detail;
            if (method === 'setStyleContent') {
              const el = document.getElementById(id);
              if (!el) {
                return;
              }
              const disabled = el.disabled;
              el.textContent = content;
              el.disabled = disabled;
            } else if (method === 'orphan') {
              window.removeEventListener(EVENT_NAME, handler);
            }
          }, true);
        }
        window.dispatchEvent(new CustomEvent(EVENT_NAME, {detail: {
          method: 'init',
          available
        }}));

        function checkStyleApplied() {
          const style = document.createElement('style');
          style.textContent = ':root{--stylus-applied:1}';
          document.documentElement.appendChild(style);
          const applied = getComputedStyle(document.documentElement)
            .getPropertyValue('--stylus-applied');
          style.remove();
          return Boolean(applied);
        }
      })("{7a7a4a92-a2a0-41d1-9fd7-1e92480d612d}")

The page's console then contains a rather opaque error:

SyntaxError: missing ] after element list[Learn More] data:KGZ1bmN0aW9uKCkgewogICAgW25hdGl2ZSBjb2RlXQp9KSgiezdhN2E0YTkyLWEyYTAtNDFkMS05ZmQ3LTFlOTI0ODBkNjE:2:12 note: [ opened at line 2, column 4

This is true as of 1.5.2; updating title to match.

@eternaleye eternaleye changed the title v1.5.0: Styles not applied to pages, not listed in manager javascript.options.discardSystemSource breaks injection in v1.5.0..v1.5.2 Dec 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Priorities
  
High priority
Development

No branches or pull requests

5 participants