Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(613)

Unified Diff: sky/framework/inspector/page-agent.sky

Issue 837933003: Convert the inspector framework to use ES6 classes. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: prevent extensions Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/framework/inspector/inspector.sky ('k') | sky/framework/inspector/runtime-agent.sky » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/inspector/page-agent.sky
diff --git a/sky/framework/inspector/page-agent.sky b/sky/framework/inspector/page-agent.sky
index 2157b770bd0983519ffb9e6e3c6509e79131b15a..a489e4be50e233feb493ca8133545423ca4cfabe 100644
--- a/sky/framework/inspector/page-agent.sky
+++ b/sky/framework/inspector/page-agent.sky
@@ -1,37 +1,57 @@
<import src="/sky/framework/xmlhttprequest.sky" as="XMLHttpRequest" />
<script>
-function Page(delegate) {
- this.delegate_ = delegate;
-}
-
-Page.prototype.enable = function() {
-};
+class Page {
+ constructor(delegate) {
+ this.delegate_ = delegate;
+ Object.preventExtensions(this);
+ }
-Page.prototype.canScreencast = function() {
- return {
- result: false
- };
-};
+ enable() {
+ }
-Page.prototype.canEmulate = function() {
- return {
- result: false
- };
-};
+ canScreencast() {
+ return {
+ result: false
+ };
+ }
-Page.prototype.getResourceContent = function(params, messageId) {
- var request = new XMLHttpRequest;
- request.onload = function() {
- var message = {
- 'content' : request.responseText,
+ canEmulate() {
+ return {
+ result: false
};
- this.delegate_.sendResponse(messageId, message);
- }.bind(this);
- request.open("GET", params.url);
- request.send();
+ }
+
+ getResourceContent(params, messageId) {
+ var request = new XMLHttpRequest;
+ request.onload = function() {
+ var message = {
+ 'content' : request.responseText,
+ };
+ this.delegate_.sendResponse(messageId, message);
+ }.bind(this);
+ request.open("GET", params.url);
+ request.send();
- return this.delegate_.ASYNC_RESPONSE;
-};
+ return this.delegate_.ASYNC_RESPONSE;
+ }
+
+ getResourceTree() {
+ // Unclear if this is all needed, but if we don't return something here
+ // the inspector hits an exception in WebInspector.ResourceTreeModel.
+ return {
+ "frameTree": {
+ "frame": {
+ "id": "1",
+ "loaderId": "1",
+ "url": String(document.URL),
+ "mimeType": "text/html",
+ "securityOrigin": String(document.URL),
+ },
+ "resources": arrayFromIterator(resourcesMapForSubtree(document).values()),
+ }
+ };
+ }
+}
// FIXME: ES6 has Array.from which theoretically does this.
function arrayFromIterator(iterator) {
@@ -46,7 +66,7 @@ function forEachInNodeList(array, callback, scope) {
for (var i = 0; i < array.length; i++) {
callback.call(scope, array[i]);
}
-};
+}
function addResource(map, url, type, mimeType) {
// Be sure to string the url object since has(new Object)
@@ -84,22 +104,5 @@ function resourcesMapForSubtree(root_doc) {
return map;
}
-Page.prototype.getResourceTree = function() {
- // Unclear if this is all needed, but if we don't return something here
- // the inspector hits an exception in WebInspector.ResourceTreeModel.
- return {
- "frameTree": {
- "frame": {
- "id": "1",
- "loaderId": "1",
- "url": String(document.URL),
- "mimeType": "text/html",
- "securityOrigin": String(document.URL),
- },
- "resources": arrayFromIterator(resourcesMapForSubtree(document).values()),
- }
- };
-};
-
module.exports = Page;
</script>
« no previous file with comments | « sky/framework/inspector/inspector.sky ('k') | sky/framework/inspector/runtime-agent.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698