Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Conversation

@jasonsanjose
Copy link
Member

Fix for #6830

  • Add styleSheetAdded and styleSheetRemoved event handling to inspector protocol
  • Fallback to getAllStylesheets for Chrome < 34

Fix for #6912

  • Use styleSheetAdded to keep styleSheetId values up to date to fix "No style sheet with given id found, code: -32000" when pushing change events from Brackets to Chrome

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since getStylesheetURLs depended on getAllStylesheets, most of this code now moves into the styleSheetAdded event handler.

@jasonsanjose
Copy link
Member Author

Doh. I just realized that we should check for the original API in case the user is using an older version of Chrome.

@jasonsanjose
Copy link
Member Author

Added fallback for getAllStyleSheets and duplicate detection if both the deleted API and the events are working. Tested on Mac 10.9 with Chrome 33.

Even though Chrome 33 should support both, I found that the styleSheetAdded and styleSheetRemoved events were not consistently fired by Chrome. The fallback was necessary in my testing otherwise live CSS editing would be broken.

@jasonsanjose
Copy link
Member Author

Somewhat related to these changes is PR #7010 to update the inspector protocol to the latest stable version.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this dump out an error in the console if the API doesn't exist? I wonder if we should bother doing this, since the events seem to have been around for awhile, and I don't think we need to support people who don't regularly update Chrome. (Although I guess we don't know exactly which version they were introduced in.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will yes. We can suppress a subset of protocol errors, particularly this one where the method is not defined. The basic set of error codes are defined here http://www.jsonrpc.org/specification#error_object. I can't find any documentation for Chrome that defines implementation-specific error codes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow enable during LiveDevelopment _onInterstitialPageLoad(). The old behavior would wait all the way until loadEventFired to enable the CSS domain. This also allows loadAgents() to complete faster since we no longer wait for the sequence of (1) loadEventFired, (2) enable and (3) getAllStylesheets.

@redmunds
Copy link
Contributor

I'm seeing the this LiveDevelopment unit test fail every time on Win7 (both HD and SSD) and Chrome 33:

"should reload the page when editing a non-live document"

timeout: timed out after 1000 msec waiting for success [FILE_SAVE]

UPDATE: seeing same failure with Win7 (SSD) with Chrome 34.0.1847.11 beta-m.

@redmunds
Copy link
Contributor

FYI, Win7 (HD) with Chrome 35 (canary) is a train wreck (7 of 9 fail). Getting "External Changes: simple1.css has been modified on disk, but also has unsaved changes in Brackets" warning dialog.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since code no longer checks if (_urlToStyle) then _urlToStyle should be initialized to _urlToStyle = {} on line 43 to be safe. Same for _styleSheetIdToUrl.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@redmunds
Copy link
Contributor

There are a lot of conflicts with PR #6889 -- should these be merged?

@jasonsanjose
Copy link
Member Author

@redmunds Looking at the unit test failures now. Will send an update later today.

@JeffryBooher JeffryBooher removed their assignment Feb 28, 2014
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer necessary to check for existence of _urlToStyle object.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@jasonsanjose
Copy link
Member Author

@redmunds let me know if you see a unit test failure at the end of the live dev suite due to removeTempDirectory. I can only reproduce on windows, not mac. I've scrubbed this code all morning looking for some material change that would maybe cause file watchers to hang on to a ref, which would maybe cause the error during cleanup, but I don't see anything.

@redmunds
Copy link
Contributor

@jasonsanjose Yes, I just saw it on Win7 (SSD) but not on Win7 (HD).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems out-of-place since the 2 things listed are not done here. The one item that is done here ("agent loading") was removed from the comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Removed the whole thing.

@redmunds
Copy link
Contributor

@jasonsanjose I tried to manually delete the test/temp folder and got the message: "The action can't be completed because the folder or file is open in another program". I shutdown Brackets and could then remove the folder. Now the tests pass. Interesting because I know that I had a clean git status when I started.

@jasonsanjose
Copy link
Member Author

@redmunds cleaned up those last few comments. Still no luck with the removeTempDirectory problem.

@redmunds
Copy link
Contributor

redmunds commented Mar 4, 2014

@jasonsanjose Do you have a repeatable recipe for the removeTempDirectory problem? If so, I can take a look.

@jasonsanjose
Copy link
Member Author

Unfortunately no. It happens about 90% of the time I run the live dev test suite.

@redmunds
Copy link
Contributor

redmunds commented Mar 5, 2014

I'm getting an exception in HighlightAgent unit test on Win7 (SSD) with Chrome 33:

should redraw highlights when the document changes

TypeError: Cannot call method 'done' of undefined
    at CSSDocumentModule.CSSDocument._updateBrowser (file:///C:/Users/redmunds/dev/github/brackets-shell/Release/dev/src/LiveDevelopment/Documents/CSSDocument.js:136:27)
    at CSSDocument.onChange (file:///C:/Users/redmunds/dev/github/brackets-shell/Release/dev/src/LiveDevelopment/Documents/CSSDocument.js:208:14)
    at Document.o.event.dispatch (file:///C:/Users/redmunds/dev/github/brackets-shell/Release/dev/src/thirdparty/jquery-2.1.0.min.js:3:6055)
    at Document.r.handle (file:///C:/Users/redmunds/dev/github/brackets-shell/Release/dev/src/thirdparty/jquery-2.1.0.min.js:3:2830)
    at Object.o.event.trigger (file:///C:/Users/redmunds/dev/github/brackets-shell/Release/dev/src/thirdparty/jquery-2.1.0.min.js:3:5163)
    at o.fn.extend.triggerHandler (file:///C:/Users/redmunds/dev/github/brackets-shell/Release/dev/src/thirdparty/jquery-2.1.0.min.js:3:11081)
    at Document.docToShim._handleEditorChange (file:///C:/Users/redmunds/dev/github/brackets-shell/Release/dev/test/spec/SpecRunnerUtils.js:334:21)
    at Editor.o.event.dispatch (file:///C:/Users/redmunds/dev/github/brackets-shell/Release/dev/src/thirdparty/jquery-2.1.0.min.js:3:6055)
    at Editor.r.handle (file:///C:/Users/redmunds/dev/github/brackets-shell/Release/dev/src/thirdparty/jquery-2.1.0.min.js:3:2830)
    at Object.o.event.trigger (file:///C:/Users/redmunds/dev/github/brackets-shell/Release/dev/src/thirdparty/jquery-2.1.0.min.js:3:5163)

@jasonsanjose
Copy link
Member Author

@redmunds fixed the HighlightAgent test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the path null if it's not an external stylesheet (i.e. embedded) ?

@redmunds
Copy link
Contributor

redmunds commented Mar 5, 2014

@jasonsanjose I can still hit the removeTempDirectory problem, but not very often. When I hit it, I manually delete test/temp folder, and it's ok for a while.

But, we need to get this in master so people start using it. We also need to figure out which pieces of #6889 we need to take. Merging.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants