forked from aosabook/500lines
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorigin.als
More file actions
30 lines (26 loc) · 717 Bytes
/
Copy pathorigin.als
File metadata and controls
30 lines (26 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* origin.als
* A model of the notion of origin per the SOP
*/
module origin
open http
open browser
// An origin is defined as a triple (protocol, host, port) where port is
// optional
sig Origin {
protocol: Protocol,
host: Domain,
port: lone Port
}
fun origin[u: Url] : Origin {
{o: Origin | o.protocol = u.protocol and o.host = u.host and o.port = u.port }
}
fun origin[d: Document] : Origin { origin[d.src] }
fun currOrigin[d : Document, t : Time] : Origin {
{o: Origin | let u = d.src | o.protocol = u.protocol and o.host = d.domain.t and o.port = u.port }
}
fact {
no disj o1, o2: Origin |
o1 != o2 and o1.protocol = o2.protocol and o1.host = o2.host and
o1.port = o2.port
}