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

Script inserted into iframes in page #959

Open
jacksonrayhamilton opened this issue Jan 7, 2016 · 2 comments
Open

Script inserted into iframes in page #959

jacksonrayhamilton opened this issue Jan 7, 2016 · 2 comments

Comments

@jacksonrayhamilton
Copy link

In Firefox 43 on Mac OS Yosemite, if I have an <iframe> element on my page, BrowserSync will inject its <script> element inside the frame. I'd rather if this did not happen. How can I disable this?

The <iframe> does not have an src="" attribute so I don't think the solution from #553 (which looks like blacklisting URLs) will work.

@shakyShane
Copy link
Contributor

Could you provide a working example of this issue?

@jacksonrayhamilton
Copy link
Author

Sorry, after reproducing the issue, I realize that my use case is a bit more specific. It seems that on the latest Firefox (43.0.4 on Linux Mint, and also on Mac OS Yosemite) BrowserSync injects its script into html content loaded via AJAX, which I observed after injecting said content into an iframe and upon inspection of the responseText.

Interestingly, this does not occur on the latest Chromium (48.0.2564.82 on Linux Mint).

index.html:

<body>
    <script src="inject.js"></script>
</body>

inject.js:

(function () {

    'use strict';

    function insertContent(html) {
        var iframe = document.createElement('iframe');
        document.body.appendChild(iframe);
        var contentDocument = iframe.contentDocument;
        contentDocument.open();
        contentDocument.write(html);
        contentDocument.close();
    }

    var xhr = new XMLHttpRequest();
    xhr.addEventListener('load', function () {
        insertContent(xhr.responseText);
    });
    xhr.open('GET', '/page.html');
    xhr.send();

}());

page.html:

<body>Hello World!</body>

From the CWD with the above files:

$ browser-sync --version
2.11.1
$ browser-sync start --server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants