Skip to content

jquery breaks when running $(window).text() while an iframe with different doamin exist on the page. #4038

Closed
@adi-darachi

Description

@adi-darachi

When running $.text() on window, while there are cors iframes on the page throws an exception.

STR:

  1. Open a page with that have at least one iframe from a different domain.
  2. run $(window).text() .
  • What do you expect to happen?

Return empty string/undefined

  • What actually happens?

Throws exception (cors/security 18)

  • Which browsers are affected?

(WebKit/gecko based at least)

minimal testcase -> https://jsfiddle.net/xpvt214o/127474/

  • why is it happening?

a. it seems that Sizzel.getText function assumes that if the parameter sent have no .nodeType property, it must be an array, so it's start iterating the element indexes,
b. when adding iframes to the document there is a reference also on the window object
window[0...n] (n - the number of frames on the page)

so when sending the window object, it iterates also the inaccessible windows and try to access their .nodeType prop which throws an exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions