Skip to content

Commit

Permalink
remove backend API extraction
Browse files Browse the repository at this point in the history
Chrome hardened pageCapture API and it is no longer possible to read
chrome-devtools://devtools/bundled/shell.js

https://chromium.googlesource.com/chromium/src/+/0660e08731fd42076d7242068e9eaed1482b14d5
  • Loading branch information
darwin committed Dec 11, 2018
1 parent 34f2777 commit 07592b3
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 156 deletions.
3 changes: 0 additions & 3 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ DevTools frontend can adapt dynamically and does not fatally break when used wit
But you should not use "too old" DevTools with "too recent" Chrome and vice versa.
Such combinations are not tested and are likely to break because fundamental APIs could be missing / changed on either side.

Since [Dirac v0.6.4](https://github.com/binaryage/dirac/releases/tag/v0.6.4) this requirement was relaxed because Dirac can newly use protocol definitions from internal DevTools.
But still you should not diverge too far from recommended Chrome version.

### How do I stick to a particular Dirac version?

Unfortunately it is not easily possible to [disable auto-update feature of Chrome Canary](https://www.chromium.org/administrators/turning-off-auto-updates).
Expand Down
1 change: 0 additions & 1 deletion resources/release/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"storage",
"webRequest",
"http://*/json",
"pageCapture",
"tabs"
],
"manifest_version": 2
Expand Down
1 change: 0 additions & 1 deletion resources/unpacked/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"storage",
"webRequest",
"http://*/json",
"pageCapture",
"tabs"
],
"manifest_version": 2
Expand Down
13 changes: 0 additions & 13 deletions src/background/dirac/background/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,16 @@
[dirac.background.chrome :as chrome]
[dirac.background.logging :refer [error info log warn]]
[dirac.background.state :as state]
[dirac.background.thief :as thief]
[dirac.options.model :as options]
[dirac.shared.async :refer [<! go go-channel put!]]
[oops.core :refer [oapply ocall oget]]))

(defn go-extract-apis! []
(go
(let [extract-api? (options/get-option :use-backend-supported-api)
extract-css? (options/get-option :use-backend-supported-css)]
(if (or extract-api? extract-css?)
(let [[backend-api backend-css] (<! (thief/go-scrape-bundled-devtools!))]
(if (and extract-api? (some? backend-api))
(state/set-backend-api! backend-api))
(if (and extract-css? (some? backend-css))
(state/set-backend-css! backend-css)))))))

; -- main entry point -------------------------------------------------------------------------------------------------------


(defn init! []
(log "init")
(go
(<! (options/go-init!))
(<! (go-extract-apis!))
(<! (action/go-set-active-icons!)) ; by default we start with grayed-out icons, see manifest.json
(<! (chrome/go-init-and-run-chrome-event-loop!))))
80 changes: 0 additions & 80 deletions src/background/dirac/background/thief.cljs

This file was deleted.

28 changes: 0 additions & 28 deletions src/background/dirac/background/tools.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,6 @@
first-tab (aget tabs 0)]
(sugar/get-tab-id first-tab)))))

(defn go-create-bundled-devtools-window! [url]
(let [window-params #js {:url url
:type "normal"
:state "minimized"}]
(sugar/go-create-window-and-wait-for-first-tab-completed! window-params)))

(defn go-create-bundled-devtools-inspector-window! []
(go-create-bundled-devtools-window! "chrome-devtools://devtools/bundled/inspector.js"))

(defn go-create-bundled-devtools-shell-window! []
(go-create-bundled-devtools-window! "chrome-devtools://devtools/bundled/shell.js"))

(defn go-remove-window! [window-id]
(windows/remove window-id))

Expand Down Expand Up @@ -105,20 +93,6 @@
(assoc options :automate true)
options))

(defn provide-backend-api-if-available [options]
(or
(when (options/get-option :use-backend-supported-api)
(if-some [backend-api (state/get-backend-api)]
(assoc options :backend-api backend-api)))
options))

(defn provide-backend-css-if-available [options]
(or
(when (options/get-option :use-backend-supported-css)
(if-some [backend-css (state/get-backend-css)]
(assoc options :backend-css backend-css)))
options))

(defn provide-user-url-params [options]
(or
(if-some [user-url-params (options/get-option :user-frontend-url-params)]
Expand All @@ -128,8 +102,6 @@
(defn prepare-options [initial-options]
(-> initial-options
(automate-if-marion-present)
(provide-backend-api-if-available)
(provide-backend-css-if-available)
(provide-user-url-params)))

(defn go-wait-for-handshake-completion! [frontend-tab-id timeout-ms]
Expand Down
2 changes: 0 additions & 2 deletions src/options/dirac/options/model.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
:clean-urls true
:beautify-function-names true
:link-actions true
:use-backend-supported-api true
:use-backend-supported-css true
:user-frontend-url-params nil})

(defonce cached-options (atom nil))
Expand Down
4 changes: 1 addition & 3 deletions src/options/dirac/options/ui.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@
(switch-view data :inline-custom-formatters "Inline Custom Formatters" (inline-custom-formatters-details))
(switch-view data :clean-urls "Enable clean URLs" (clean-urls-details))
(switch-view data :beautify-function-names "Beautify function names" (beautify-function-names-details))
(switch-view data :link-actions "Enable link actions" (link-actions-details))
(switch-view data :use-backend-supported-api "Use backend-supported API" (api-details))
(switch-view data :use-backend-supported-css "Use backend-supported CSS" (api-details))]]
(switch-view data :link-actions "Enable link actions" (link-actions-details))]]
(extra-params-view data))
(f/form-buttons
(f/button "Reset to Defaults and Exit" reset-to-defaults-and-exit!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,14 @@
(with-options {:user-frontend-url-params user-params}
(with-devtools
(is (string/includes? (<!* a/go-get-frontend-url-params) user-params))))))
(testing "use backend-supported api and css"
(with-options {:use-backend-supported-api true
:use-backend-supported-css true}
(with-devtools
(<!* a/go-switch-to-console-panel!)
(<!* a/go-trigger-internal-error-as-error-log!)
(is (= (count (<!* a/go-scrape :find-logs "a fake error log")) 1))
(let [error-content (second (first (<!* a/go-scrape :find-logs-in-groups "a fake error log")))
info-line (first (utils/lines error-content))]
(is (string/includes? info-line "Backend API/external"))
(is (string/includes? info-line "Backend CSS/external"))
(is (> (get-registrations info-line) 400))
(is (> (get-definitions info-line) 400))))))
(testing "use baked-in api and css"
(with-options {:use-backend-supported-api false
:use-backend-supported-css false}
(with-devtools
(<!* a/go-switch-to-console-panel!)
(<!* a/go-trigger-internal-error-as-error-log!)
(is (= (count (<!* a/go-scrape :find-logs "a fake error log")) 1))
(let [error-content (second (first (<!* a/go-scrape :find-logs-in-groups "a fake error log")))
info-line (first (utils/lines error-content))]
(is (string/includes? info-line "Backend API/internal"))
(is (string/includes? info-line "Backend CSS/internal"))
(is (> (get-registrations info-line) 400))
(is (> (get-definitions info-line) 400))))))))
(with-devtools
(<!* a/go-switch-to-console-panel!)
(<!* a/go-trigger-internal-error-as-error-log!)
(is (= (count (<!* a/go-scrape :find-logs "a fake error log")) 1))
(let [error-content (second (first (<!* a/go-scrape :find-logs-in-groups "a fake error log")))
info-line (first (utils/lines error-content))]
(is (string/includes? info-line "Backend API/internal"))
(is (string/includes? info-line "Backend CSS/internal"))
(is (> (get-registrations info-line) 400))
(is (> (get-definitions info-line) 400)))))))

0 comments on commit 07592b3

Please sign in to comment.