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

Unified Diff: telemetry/third_party/snap-it/content_script.js

Issue 3010063002: [Telemetry] Add script to snapshot page's HTML (Closed)
Patch Set: fix --interactive flag spec Created 3 years, 3 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
Index: telemetry/third_party/snap-it/content_script.js
diff --git a/telemetry/third_party/snap-it/content_script.js b/telemetry/third_party/snap-it/content_script.js
new file mode 100644
index 0000000000000000000000000000000000000000..1abfc1f5bcf61c6adeda10a6df6d49a81b763420
--- /dev/null
+++ b/telemetry/third_party/snap-it/content_script.js
@@ -0,0 +1,31 @@
+/**
+ * Send the neccessary HTMLSerializer properties back to the extension.
+ *
+ * @param {HTMLSerializer} htmlSerializer The HTMLSerializer.
+ */
+function sendHTMLSerializerToExtension(htmlSerializer) {
+ var result = {
+ 'html': htmlSerializer.html,
+ 'frameHoles': htmlSerializer.frameHoles,
+ 'idToStyleIndex': htmlSerializer.idToStyleIndex,
+ 'idToStyleMap': htmlSerializer.idToStyleMap,
+ 'windowHeight': htmlSerializer.windowHeight,
+ 'windowWidth': htmlSerializer.windowWidth,
+ 'rootId': htmlSerializer.rootId,
+ 'rootStyleIndex': htmlSerializer.rootStyleIndex,
+ 'pseudoElementSelectorToCSSMap':
+ htmlSerializer.pseudoElementSelectorToCSSMap,
+ 'pseudoElementPlaceHolderIndex':
+ htmlSerializer.pseudoElementPlaceHolderIndex,
+ 'pseudoElementTestingStyleIndex':
+ htmlSerializer.pseudoElementStyleTestingIndex,
+ 'pseudoElementTestingStyleId': htmlSerializer.pseudoElementTestingStyleId,
+ 'unusedId': htmlSerializer.generateId(document),
+ 'frameIndex': htmlSerializer.iframeFullyQualifiedName(window)
+ };
+ chrome.runtime.sendMessage(result);
+}
+
+var htmlSerializer = new HTMLSerializer();
+htmlSerializer.processDocument(document);
+htmlSerializer.fillHolesAsync(document, sendHTMLSerializerToExtension);

Powered by Google App Engine
This is Rietveld 408576698