Update the data file of WebPackageRequestHandlerBrowserTest

Bug: 803774
Change-Id: Ic54c87c1549123af9a7943b5a65763770abadb8e
Reviewed-on: https://chromium-review.googlesource.com/910537
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Tsuyoshi Horo <horo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#535679}
diff --git a/content/browser/loader/web_package_request_handler_browsertest.cc b/content/browser/loader/web_package_request_handler_browsertest.cc
index 3ccba2b..662f31e 100644
--- a/content/browser/loader/web_package_request_handler_browsertest.cc
+++ b/content/browser/loader/web_package_request_handler_browsertest.cc
@@ -42,9 +42,8 @@
 IN_PROC_BROWSER_TEST_P(WebPackageRequestHandlerBrowserTest, Simple) {
   embedded_test_server()->ServeFilesFromSourceDirectory("content/test/data");
   ASSERT_TRUE(embedded_test_server()->Start());
-  GURL url =
-      embedded_test_server()->GetURL("/htxg/origin-signed-response.html");
-  base::string16 title = base::ASCIIToUTF16("https://example.com/test.html");
+  GURL url = embedded_test_server()->GetURL("/htxg/test.example.org_test.htxg");
+  base::string16 title = base::ASCIIToUTF16("https://test.example.org/test/");
   TitleWatcher title_watcher(shell()->web_contents(), title);
   NavigateToURL(shell(), url);
   EXPECT_EQ(title, title_watcher.WaitAndGetTitle());
diff --git a/content/test/data/htxg/.gitattributes b/content/test/data/htxg/.gitattributes
index 2a4fcb3bc..e1697f7 100644
--- a/content/test/data/htxg/.gitattributes
+++ b/content/test/data/htxg/.gitattributes
@@ -1 +1,2 @@
 *.htxg binary
+*.msg binary
diff --git a/content/test/data/htxg/README b/content/test/data/htxg/README
new file mode 100644
index 0000000..b41f2cd
--- /dev/null
+++ b/content/test/data/htxg/README
@@ -0,0 +1,37 @@
+The certificate message files (*.msg) and the signed exchange files (*.htxg) in
+this directory are generated using the following commands.
+
+gen-certurl and gen-signedexchange are available in webpackage repository [1].
+But currently, these commands are under review yet [2].
+ [1] https://github.com/WICG/webpackage
+ [2] https://github.com/WICG/webpackage/pull/119
+TODO(https://crbug.com/803774): Update when the commands are upstreamed.
+
+
+# Get the private key of "*.example.org".
+sed -ne '/-BEGIN PRIVATE KEY-/,/-END PRIVATE KEY-/p' \
+  ../../../../net/data/ssl/certificates/wildcard.pem \
+  > /tmp/wildcard_example.org.private.pem
+
+# Get the public key of "*.example.org".
+sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' \
+  ../../../../net/data/ssl/certificates/wildcard.pem \
+  > /tmp/wildcard_example.org.public.pem
+
+# Generate the certificate message file.
+gen-certurl  \
+  /tmp/wildcard_example.org.public.pem > wildcard_example.org.public.pem.msg
+
+# Generate the signed exchange file.
+gen-signedexchange \
+  -uri https://test.example.org/test/ \
+  -status 200 \
+  -content test.html \
+  -certificate /tmp/wildcard_example.org.public.pem \
+  -certUrl https://cert.example.org/cert.msg \
+  -validityUrl https://cert.example.org/resource.validity.msg \
+  -privateKey /tmp/wildcard_example.org.private.pem \
+  -o test.example.org_test.htxg \
+  -miRecordSize=100
+
+
diff --git a/content/test/data/htxg/origin-signed-response-iframe.htxg b/content/test/data/htxg/origin-signed-response-iframe.htxg
deleted file mode 100644
index 3da6160..0000000
--- a/content/test/data/htxg/origin-signed-response-iframe.htxg
+++ /dev/null
Binary files differ
diff --git a/content/test/data/htxg/origin-signed-response.html b/content/test/data/htxg/origin-signed-response.html
deleted file mode 100644
index 0d04b3f..0000000
--- a/content/test/data/htxg/origin-signed-response.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!DOCTYPE html>
-<title>Location of origin-signed HTTP response</title>
-<body>
-<script>
-function with_iframe(url) {
-  return new Promise(function(resolve) {
-      const frame = document.createElement('iframe');
-      frame.src = url;
-      frame.onload = function() { resolve(frame); };
-      document.body.appendChild(frame);
-    });
-}
-
-const url = 'origin-signed-response-iframe.htxg';
-with_iframe(url)
-  .then((frame) => {
-    const channel = new MessageChannel();
-    const promise =
-        new Promise((resolve) => { channel.port1.onmessage = resolve; });
-    frame.contentWindow.postMessage(
-      {port: channel.port2}, '*', [channel.port2]);
-    return promise;
-  })
-  .then((event) => {
-    document.title = event.data.location;
-  });
-</script>
-</body>
-
diff --git a/content/test/data/htxg/test.example.org_test.htxg b/content/test/data/htxg/test.example.org_test.htxg
new file mode 100644
index 0000000..7e6f06e2
--- /dev/null
+++ b/content/test/data/htxg/test.example.org_test.htxg
Binary files differ
diff --git a/content/test/data/htxg/origin-signed-response-iframe.htxg.mock-http-headers b/content/test/data/htxg/test.example.org_test.htxg.mock-http-headers
similarity index 100%
rename from content/test/data/htxg/origin-signed-response-iframe.htxg.mock-http-headers
rename to content/test/data/htxg/test.example.org_test.htxg.mock-http-headers
diff --git a/content/test/data/htxg/test.html b/content/test/data/htxg/test.html
new file mode 100644
index 0000000..90288d53
--- /dev/null
+++ b/content/test/data/htxg/test.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<title>Location of origin-signed HTTP response</title>
+<body>
+<script>
+document.title = document.location.href;
+</script>
+</body>
+
diff --git a/content/test/data/htxg/wildcard_example.org.public.pem.msg b/content/test/data/htxg/wildcard_example.org.public.pem.msg
new file mode 100644
index 0000000..8a02ed0
--- /dev/null
+++ b/content/test/data/htxg/wildcard_example.org.public.pem.msg
Binary files differ